id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,845
|
cross_process_sync.h
|
anbox_anbox/external/process-cpp-minimal/include/core/testing/cross_process_sync.h
|
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voss <thomas.voss@canonical.com>
*/
#ifndef CORE_TESTING_CROSS_PROCESS_SYNC_H_
#define CORE_TESTING_CROSS_PROCESS_SYNC_H_
#include <core/posix/visibility.h>
#include <cstdint>
#include <chrono>
#include <stdexcept>
namespace core
{
namespace testing
{
/**
* @brief A cross-process synchronization primitive that supports simple wait-condition-like scenarios.
*/
class CORE_POSIX_DLL_PUBLIC CrossProcessSync
{
public:
struct Error
{
Error() = delete;
~Error() = delete;
/**
* @brief Thrown if any of the *_for functions times out.
*/
struct Timeout : public std::runtime_error
{
Timeout() : std::runtime_error("Timeout while waiting for event to happen.")
{
}
};
};
/**
* @brief Constructs a new sync element.
*/
CrossProcessSync();
/**
* @brief Copy c'tor, duping the underlying fds.
* @param rhs The instance to copy.
*/
CrossProcessSync(const CrossProcessSync& rhs);
/**
* @brief Closes the underlying fds.
*/
~CrossProcessSync() noexcept;
/**
* @brief operator =, dup's the underlying fds.
* @param rhs The instance to assign from.
* @return A mutable reference to this instance.
*/
CrossProcessSync& operator=(const CrossProcessSync& rhs);
/**
* @brief Try to signal the other side that we are ready for at most duration milliseconds.
* @throw Error::Timeout in case of a timeout.
* @throw std::system_error for problems with the underlying pipe.
*/
void try_signal_ready_for(const std::chrono::milliseconds& duration);
/**
* @brief Wait for the other sides to signal readiness for at most duration milliseconds.
* @return The number of ready signals that have been collected since creation.
* @throw Error::Timeout in case of a timeout.
* @throw std::system_error for problems with the underlying pipe.
*/
std::uint32_t wait_for_signal_ready_for(const std::chrono::milliseconds& duration);
private:
int fds[2]; ///< The cross-process pipe.
std::uint32_t counter; ///< Counts the number of times the sync has been signalled.
};
}
}
#endif // CORE_TESTING_CROSS_PROCESS_SYNC_H_
| 2,923
|
C++
|
.h
| 86
| 29.418605
| 103
| 0.685907
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,846
|
fork_and_run.h
|
anbox_anbox/external/process-cpp-minimal/include/core/testing/fork_and_run.h
|
/*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef CORE_TESTING_FORK_AND_RUN_H_
#define CORE_TESTING_FORK_AND_RUN_H_
#include <core/posix/exit.h>
#include <core/posix/fork.h>
#include <core/posix/visibility.h>
#include <functional>
namespace core
{
namespace testing
{
/**
* @brief The ForkAndRunResult enum models the different failure modes of fork_and_run.
*/
enum class ForkAndRunResult
{
empty = 0, ///< Special value indicating no bit being set.
client_failed = 1 << 0, ///< The client failed.
service_failed = 1 << 1 ///< The service failed.
};
CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator|(ForkAndRunResult lhs, ForkAndRunResult rhs);
CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator&(ForkAndRunResult lhs, ForkAndRunResult rhs);
/**
* @brief Forks two processes for both the service and the client.
*
* The function does the following:
* - Forks a process for the service and runs the respective closure.
* - Forks a process for the client and runs the respective closure.
* - After the client has finished, the service is signalled with sigterm.
*
* @throw std::system_error if an error occured during process interaction.
* @throw std::runtime_error for signalling all other error conditions.
* @param [in] service The service to be executed in a child process.
* @param [in] client The client to be executed in a child process.
* @return ForkAndRunResult indicating if either of service or client failed.
*/
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run(
const std::function<core::posix::exit::Status()>& service,
const std::function<core::posix::exit::Status()>& client);
}
}
/**
* Test definition macro which runs a TEST in a forked process.
* Note that you can only use EXPECT_*, not
* ASSERT_*!
*
* Usage:
* TESTP(test_suite, test_name, {
* test code ...
* EXPECT_* ...
* })
*/
#define TESTP(test_suite, test_name, CODE) \
TEST(test_suite, test_name) { \
auto test = [&]() { \
CODE \
return HasFailure() ? core::posix::exit::Status::failure \
: core::posix::exit::Status::success; \
}; \
auto child = core::posix::fork( \
test, \
core::posix::StandardStream::empty); \
auto result = child.wait_for(core::posix::wait::Flags::untraced); \
EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \
EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \
} \
/**
* Test definition macro which runs a TEST_F in a forked process.
* Note that you can only use EXPECT_*, not ASSERT_*!
*
* Usage:
* TESTP_F(FixtureName, TestName, {
* ... test code ...
* EXPECT_* ...
* })
*/
#define TESTP_F(test_fixture, test_name, CODE) \
TEST_F(test_fixture, test_name) { \
auto test = [&]() { \
CODE \
return HasFailure() ? core::posix::exit::Status::failure \
: core::posix::exit::Status::success; \
}; \
auto child = core::posix::fork( \
test, \
core::posix::StandardStream::empty); \
auto result = child.wait_for(core::posix::wait::Flags::untraced); \
EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \
EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \
} \
#endif // CORE_TESTING_FORK_AND_RUN_H_
| 5,170
|
C++
|
.h
| 107
| 44.028037
| 93
| 0.530378
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,847
|
backtrace.h
|
anbox_anbox/external/process-cpp-minimal/src/core/posix/backtrace.h
|
/*
* Copyright © 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef CORE_POSIX_BACKTRACE_H_
#define CORE_POSIX_BACKTRACE_H_
#include <core/posix/visibility.h>
#include <functional>
#include <memory>
#include <string>
namespace core
{
namespace posix
{
namespace backtrace
{
/**
* @brief The Frame class models an individual frame of a backtrace.
*/
class Frame
{
public:
/**
* @brief The Symbol class models the symbolic representation of a frame pointer.
*/
class Symbol
{
public:
static std::shared_ptr<Symbol> for_testing_from_raw_symbol(const char* symbol);
Symbol(const Symbol&) = delete;
virtual ~Symbol() = default;
Symbol& operator=(const Symbol&) = delete;
/**
* @brief is_cxx checks whether the symbol refers to a mangled C++ symbol.
* @return true iff the symbol refers to a mangled C++ symbol.
*/
virtual bool is_cxx() const = 0;
/**
* @brief demangled returns the demangled C++ symbol name or raw.
*/
virtual std::string demangled() const = 0;
/**
* @brief raw The raw symbolic representation of a frame pointer.
* @return
*/
virtual std::string raw() const = 0;
protected:
Symbol() = default;
};
Frame(const Frame&) = delete;
virtual ~Frame() = default;
Frame& operator=(const Frame&) = delete;
/**
* @brief depth returns the depth of this frame in the overall backtrace.
*/
virtual std::size_t depth() const = 0;
/**
* @brief frame_pointer returns the the raw frame pointer of this frame.
* @return
*/
virtual void* frame_pointer() const = 0;
/**
* @brief symbol returns the symbolic representation of this frame.
*/
virtual const Symbol& symbol() const = 0;
protected:
Frame() = default;
};
/**
* @brief FrameHandler is the functor invoked for every frame of a backtrace.
*
* A FrameHandler should return true if it wants to continue walking the stack
* or false otherwise.
*/
typedef std::function<bool(const Frame& frame)> FrameHandler;
/**
*@brief visit_with_handler iterates the backtrace of the calling program,
*invoking the handler for every frame.
*
* A FrameHandler should return true if it wants to continue walking the stack
* or false otherwise
*
* @param handler The handler invoked for every frame.
*/
void CORE_POSIX_DLL_PUBLIC visit_with_handler(const FrameHandler& handler);
}
}
}
#endif // CORE_POSIX_BACKTRACE_H_
| 3,200
|
C++
|
.h
| 102
| 27.215686
| 87
| 0.687906
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,850
|
daemon.h
|
anbox_anbox/src/anbox/daemon.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DAEMON_H_
#define ANBOX_DAEMON_H_
#include <string>
#include <vector>
#include "anbox/cli.h"
#include "anbox/do_not_copy_or_move.h"
namespace anbox {
class Daemon : public DoNotCopyOrMove {
public:
Daemon();
int Run(const std::vector<std::string> &arguments);
private:
cli::CommandWithSubcommands cmd;
};
} // namespace anbox
#endif
| 1,037
|
C++
|
.h
| 32
| 30.46875
| 76
| 0.756513
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,851
|
not_reachable.h
|
anbox_anbox/src/anbox/not_reachable.h
|
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*
*/
#ifndef ANBOX_UTIL_NOT_REACHABLE_H_
#define ANBOX_UTIL_NOT_REACHABLE_H_
#include <stdexcept>
#include <string>
namespace anbox::util {
/// @brief NotReachable is thrown from not_reachable.
struct NotReachable : public std::logic_error {
/// @brief NotImplemented initializes a new instance for the given function
/// name.
NotReachable(const std::string& function, const std::string& file,
std::uint32_t line);
};
/// @brief not_reachable throws NotReachable.
[[noreturn]] void not_reachable(const std::string& function,
const std::string& file, std::uint32_t line);
}
#endif
| 1,347
|
C++
|
.h
| 35
| 35.342857
| 78
| 0.729916
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,853
|
do_not_copy_or_move.h
|
anbox_anbox/src/anbox/do_not_copy_or_move.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DO_NOT_COPY_OR_MOVE_H_
#define ANBOX_DO_NOT_COPY_OR_MOVE_H_
namespace anbox {
class DoNotCopyOrMove {
public:
DoNotCopyOrMove(const DoNotCopyOrMove&) = delete;
DoNotCopyOrMove(DoNotCopyOrMove&&) = delete;
virtual ~DoNotCopyOrMove() = default;
DoNotCopyOrMove& operator=(const DoNotCopyOrMove&) = delete;
DoNotCopyOrMove& operator=(DoNotCopyOrMove&&) = delete;
protected:
DoNotCopyOrMove() = default;
};
}
#endif
| 1,119
|
C++
|
.h
| 31
| 34
| 76
| 0.764543
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,855
|
defer_action.h
|
anbox_anbox/src/anbox/defer_action.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DEFER_ACTION_H_
#define ANBOX_DEFER_ACTION_H_
#include <functional>
#include "anbox/do_not_copy_or_move.h"
namespace anbox {
class DeferAction : public DoNotCopyOrMove {
public:
DeferAction(const std::function<void()> action) : action_(action) {}
~DeferAction() {
if (action_) action_();
}
private:
std::function<void()> action_;
};
} // namespace anbox
#endif
| 1,073
|
C++
|
.h
| 32
| 31.34375
| 76
| 0.744186
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,858
|
cli.h
|
anbox_anbox/src/anbox/cli.h
|
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*
*/
#ifndef BIOMETRY_UTIL_CLI_H_
#define BIOMETRY_UTIL_CLI_H_
#include <iomanip>
#include <iostream>
#include <memory>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include "anbox/do_not_copy_or_move.h"
#include "anbox/optional.h"
#include <boost/program_options.hpp>
namespace anbox {
namespace cli {
template <std::size_t max>
class SizeConstrainedString {
public:
SizeConstrainedString(const std::string& s) : s{s} {
if (s.size() > max)
throw std::logic_error{"Max size exceeded " + std::to_string(max)};
}
const std::string& as_string() const { return s; }
operator std::string() const { return s; }
private:
std::string s;
};
template <std::size_t max>
bool operator<(const SizeConstrainedString<max>& lhs,
const SizeConstrainedString<max>& rhs) {
return lhs.as_string() < rhs.as_string();
}
template <std::size_t max>
bool operator==(const SizeConstrainedString<max>& lhs,
const SizeConstrainedString<max>& rhs) {
return lhs.as_string() == rhs.as_string();
}
template <std::size_t max>
std::ostream& operator<<(std::ostream& out,
const SizeConstrainedString<max>& scs) {
return out << std::setw(max) << std::left << scs.as_string();
}
// We are imposing size constraints to ensure a consistent CLI layout.
typedef SizeConstrainedString<30> Name;
typedef SizeConstrainedString<60> Usage;
typedef SizeConstrainedString<100> Description;
/// @brief Flag models an input parameter to a command.
class Flag : public DoNotCopyOrMove {
public:
typedef boost::program_options::value_semantic* Specification;
// Safe us some typing.
typedef std::shared_ptr<Flag> Ptr;
/// @brief name returns the name of the Flag.
const Name& name() const;
/// @brief description returns a human-readable description of the flag.
const Description& description() const;
/// @brief specify the program option of the flag.
virtual void specify_option(Specification& spec) = 0;
protected:
/// @brief Flag creates a new instance, initializing name and description
/// from the given values.
Flag(const Name& name, const Description& description);
private:
Name name_;
Description description_;
};
/// @brief TypedFlag implements Flag relying on operator<< and operator>> to
/// read/write values to/from strings.
template <typename T>
class TypedFlag : public Flag {
public:
typedef std::shared_ptr<TypedFlag<T>> Ptr;
TypedFlag(const Name& name, const Description& description)
: Flag{name, description} {}
/// @brief value installs the given value in the flag.
TypedFlag& value(const T& value) {
value_ = value;
return *this;
}
/// @brief value returns the optional value associated with the flag.
const Optional<T>& value() const { return value_; }
/// @brief Option generated by specify_option tries to unwrap a value
/// of type T from value.
void specify_option(Flag::Specification& spec) override {
spec = boost::program_options::value<std::string>()->notifier([&](const std::string& s) {
std::stringstream ss{s};
T value;
ss >> value;
value_ = value;
});
}
private:
Optional<T> value_;
};
/// @brief TypedReferenceFlag implements Flag, relying on operator<</>> to
/// convert to/from string representations,
/// updating the given mutable reference to a value of type T.
template <typename T>
class TypedReferenceFlag : public Flag {
public:
// Safe us some typing.
typedef std::shared_ptr<TypedReferenceFlag<T>> Ptr;
/// @brief TypedReferenceFlag initializes a new instance with name,
/// description and value.
TypedReferenceFlag(const Name& name, const Description& description, T& value)
: Flag{name, description}, value_{value} {}
/// @brief Option generated by specify_option tries to unwrap a value of type T
/// from value, relying on operator>> to read from given string s.
void specify_option(Flag::Specification& spec) override {
spec = boost::program_options::value<std::string>()->notifier([&](const std::string& s) {
std::stringstream ss{s};
ss >> value_.get();
});
}
private:
std::reference_wrapper<T> value_;
};
/// @brief OptionalTypedReferenceFlag handles Optional<T> references, making
/// sure that a value is always read on notify, even if the Optional<T> wasn't
/// initialized previously.
template <typename T>
class OptionalTypedReferenceFlag : public Flag {
public:
typedef std::shared_ptr<OptionalTypedReferenceFlag<T>> Ptr;
OptionalTypedReferenceFlag(const Name& name, const Description& description,
Optional<T>& value)
: Flag{name, description}, value_{value} {}
/// @brief Option generated by specify_option tries to unwrap a value of
/// type T from value.
void specify_option(Flag::Specification& spec) override {
spec = boost::program_options::value<std::string>()->notifier([&](const std::string& s) {
std::stringstream ss{s};
T value;
ss >> value;
value_.get() = value;
});
}
private:
std::reference_wrapper<Optional<T>> value_;
};
/// @brief BoolSwitchFlag implements Flag, updating the given mutable reference
/// to a boolean value.
class BoolSwitchFlag : public Flag {
public:
typedef std::shared_ptr<BoolSwitchFlag> Ptr;
BoolSwitchFlag(const Name& name, const Description& description, bool& value)
: Flag{name, description}, value_(value) {}
/// @brief Option generated by specify_option tries to unwrap a boolean
/// value from value.
void specify_option(Flag::Specification& spec) override {
spec = boost::program_options::bool_switch(&value_.get());
}
private:
std::reference_wrapper<bool> value_;
};
/// @brief Command abstracts an individual command available from the daemon.
class Command : public DoNotCopyOrMove {
public:
// Safe us some typing
typedef std::shared_ptr<Command> Ptr;
/// @brief FlagsMissing is thrown if at least one required flag is missing.
struct FlagsMissing : public std::runtime_error {
/// @brief FlagsMissing initializes a new instance.
FlagsMissing();
};
/// @brief FlagsWithWrongValue is thrown if a value passed on the command line
/// is invalid.
struct FlagsWithInvalidValue : public std::runtime_error {
/// @brief FlagsWithInvalidValue initializes a new instance.
FlagsWithInvalidValue();
};
/// @brief Context bundles information passed to Command::run invocations.
struct Context {
std::istream& cin; ///< The std::istream that should be used for reading.
std::ostream& cout; ///< The std::ostream that should be used for writing.
std::vector<std::string> args; ///< The command line args.
};
/// @brief name returns the Name of the command.
virtual Name name() const;
/// @brief usage returns a short usage string for the command.
virtual Usage usage() const;
/// @brief description returns a longer string explaining the command.
virtual Description description() const;
/// @brief hidden returns if the command is hidden from the user or not.
virtual bool hidden() const;
/// @brief run puts the command to execution.
virtual int run(const Context& context) = 0;
/// @brief help prints information about a command to out.
virtual void help(std::ostream& out) = 0;
protected:
/// @brief Command initializes a new instance with the given name, usage and
/// description.
Command(const Name& name, const Usage& usage, const Description& description, bool hidden = false);
/// @brief name adjusts the name of the command to n.
// virtual void name(const Name& n);
/// @brief usage adjusts the usage string of the comand to u.
// virtual void usage(const Usage& u);
/// @brief description adjusts the description string of the command to d.
// virtual void description(const Description& d);
private:
Name name_;
Usage usage_;
Description description_;
bool hidden_;
};
/// @brief CommandWithSubcommands implements Command, selecting one of a set of
/// actions.
class CommandWithSubcommands : public Command {
public:
typedef std::shared_ptr<CommandWithSubcommands> Ptr;
typedef std::function<int(const Context&)> Action;
/// @brief CommandWithSubcommands initializes a new instance with the given
/// name, usage and description.
CommandWithSubcommands(const Name& name, const Usage& usage,
const Description& description);
/// @brief command adds the given command to the set of known commands.
CommandWithSubcommands& command(const Command::Ptr& command);
/// @brief flag adds the given flag to the set of known flags.
CommandWithSubcommands& flag(const Flag::Ptr& flag);
// From Command
int run(const Context& context) override;
void help(std::ostream& out) override;
private:
std::unordered_map<std::string, Command::Ptr> commands_;
std::set<Flag::Ptr> flags_;
};
/// @brief CommandWithFlagsAction implements Command, executing an Action after
/// handling
class CommandWithFlagsAndAction : public Command {
public:
typedef std::shared_ptr<CommandWithFlagsAndAction> Ptr;
typedef std::function<int(const Context&)> Action;
/// @brief CommandWithFlagsAndAction initializes a new instance with the given
/// name, usage and description. Optionally the command can be marked as hidden.
CommandWithFlagsAndAction(const Name& name, const Usage& usage,
const Description& description, bool hidden = false);
/// @brief flag adds the given flag to the set of known flags.
CommandWithFlagsAndAction& flag(const Flag::Ptr& flag);
/// @brief action installs the given action.
CommandWithFlagsAndAction& action(const Action& action);
// From Command
int run(const Context& context) override;
void help(std::ostream& out) override;
private:
std::set<Flag::Ptr> flags_;
Action action_;
};
namespace cmd {
/// @brief HelpFor prints a help message for the given command on execution.
class Help : public Command {
public:
/// @brief HelpFor initializes a new instance with the given reference to a
/// cmd.
explicit Help(Command& cmd);
// From Command
int run(const Context& context) override;
void help(std::ostream& out) override;
private:
/// @cond
Command& command;
/// @endcond
};
}
/// @brief args returns a vector of strings assembled from argc and argv.
std::vector<std::string> args(int argc, char** argv);
/// @brief make_flag returns a flag with the given name and description.
template <typename T>
typename TypedFlag<T>::Ptr make_flag(const Name& name,
const Description& description) {
return std::make_shared<TypedFlag<T>>(name, description);
}
/// @brief make_flag returns a flag with the given name and description,
/// notifying updates to value.
template <typename T>
typename TypedReferenceFlag<T>::Ptr make_flag(const Name& name,
const Description& desc,
T& value) {
return std::make_shared<TypedReferenceFlag<T>>(name, desc, value);
}
/// @brief make_flag returns a flag with the given name and description,
/// updating the given optional value.
template <typename T>
typename OptionalTypedReferenceFlag<T>::Ptr make_flag(const Name& name,
const Description& desc,
Optional<T>& value) {
return std::make_shared<OptionalTypedReferenceFlag<T>>(name, desc, value);
}
/// @brief make_flag returns a flag with the given name and description,
/// updating the given boolean value.
inline BoolSwitchFlag::Ptr make_flag(const Name& name,
const Description &desc,
bool &value) {
return std::make_shared<BoolSwitchFlag>(name, desc, value);
}
} // namespace cli
} // namespace anbox
#endif
| 12,719
|
C++
|
.h
| 315
| 36.231746
| 101
| 0.709628
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,862
|
client.h
|
anbox_anbox/src/anbox/container/client.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_CLIENT_H_
#define ANBOX_CONTAINER_CLIENT_H_
#include "anbox/container/configuration.h"
#include "anbox/runtime.h"
namespace anbox::rpc {
class PendingCallCache;
class Channel;
class MessageProcessor;
}
namespace anbox::network {
class LocalSocketMessenger;
}
namespace anbox::container {
class ManagementApiStub;
class Client {
public:
typedef std::function<void()> TerminateCallback;
Client(const std::shared_ptr<Runtime> &rt);
~Client();
void start(const Configuration &configuration);
void stop();
void register_terminate_handler(const TerminateCallback &callback);
private:
void read_next_message();
void on_read_size(const boost::system::error_code &ec,
std::size_t bytes_read);
std::shared_ptr<network::LocalSocketMessenger> messenger_;
std::shared_ptr<rpc::PendingCallCache> pending_calls_;
std::shared_ptr<rpc::Channel> rpc_channel_;
std::shared_ptr<ManagementApiStub> management_api_;
std::shared_ptr<rpc::MessageProcessor> processor_;
std::array<std::uint8_t, 8192> buffer_;
TerminateCallback terminate_callback_;
};
}
#endif
| 1,804
|
C++
|
.h
| 52
| 32.057692
| 76
| 0.76062
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,863
|
management_api_message_processor.h
|
anbox_anbox/src/anbox/container/management_api_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_MANAGEMENT_API_MESSAGE_PROCESSOR_H_
#define ANBOX_CONTAINER_MANAGEMENT_API_MESSAGE_PROCESSOR_H_
#include "anbox/rpc/message_processor.h"
namespace anbox {
namespace container {
class ManagementApiSkeleton;
class ManagementApiMessageProcessor : public rpc::MessageProcessor {
public:
ManagementApiMessageProcessor(
const std::shared_ptr<network::MessageSender> &sender,
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
const std::shared_ptr<ManagementApiSkeleton> &server);
~ManagementApiMessageProcessor();
void dispatch(rpc::Invocation const &invocation) override;
void process_event_sequence(const std::string &event) override;
private:
std::shared_ptr<ManagementApiSkeleton> server_;
};
} // namespace anbox
} // namespace network
#endif
| 1,489
|
C++
|
.h
| 37
| 37.864865
| 76
| 0.779391
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,864
|
lxc_container.h
|
anbox_anbox/src/anbox/container/lxc_container.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_LXC_CONTAINER_H_
#define ANBOX_CONTAINER_LXC_CONTAINER_H_
#include "anbox/container/container.h"
#include "anbox/network/credentials.h"
#include <string>
#include <vector>
#include <lxc/lxccontainer.h>
namespace anbox::common {
class BinderDevice;
}
namespace anbox::container {
class LxcContainer : public Container {
public:
LxcContainer(bool privileged,
bool rootfs_overlay,
const std::string &container_network_address,
const std::string &container_network_gateway,
const std::vector<std::string> &container_network_dns_servers,
const network::Credentials &creds);
~LxcContainer();
void start(const Configuration &configuration) override;
void stop() override;
State state() override;
private:
void set_config_item(const std::string &key, const std::string &value);
void setup_id_map();
void setup_network();
void add_device(const std::string& device, const DeviceSpecification& spec);
bool create_binder_devices(unsigned int device_count, std::vector<std::unique_ptr<common::BinderDevice>>& devices);
State state_;
lxc_container *container_;
bool privileged_;
bool rootfs_overlay_;
std::string container_network_address_;
std::string container_network_gateway_;
std::vector<std::string> container_network_dns_servers_;
network::Credentials creds_;
std::vector<std::unique_ptr<common::BinderDevice>> binder_devices_;
};
// get_id_map() is published for unit testing
std::vector<std::string> get_id_map(uid_t uid, gid_t gid);
}
#endif
| 2,263
|
C++
|
.h
| 59
| 34.949153
| 117
| 0.741568
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,865
|
container.h
|
anbox_anbox/src/anbox/container/container.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_CONTAINER_H_
#define ANBOX_CONTAINER_CONTAINER_H_
#include "anbox/container/configuration.h"
#include <map>
#include <string>
namespace anbox::container {
class Container {
public:
virtual ~Container();
enum class State {
inactive,
running,
};
// Start the container in background
virtual void start(const Configuration &configuration) = 0;
// Stop a running container
virtual void stop() = 0;
// Get the current container state
virtual State state() = 0;
};
}
#endif
| 1,201
|
C++
|
.h
| 38
| 29.289474
| 76
| 0.752381
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,866
|
configuration.h
|
anbox_anbox/src/anbox/container/configuration.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_CONFIGURATION_H_
#define ANBOX_CONTAINER_CONFIGURATION_H_
#include <string>
#include <vector>
#include <unordered_map>
namespace anbox::container {
struct DeviceSpecification {
uint32_t permission;
std::string old_device_name = "";
};
struct Configuration {
std::unordered_map<std::string, std::string> bind_mounts;
std::unordered_map<std::string, DeviceSpecification> devices;
std::vector<std::string> extra_properties;
};
}
#endif
| 1,145
|
C++
|
.h
| 33
| 32.818182
| 76
| 0.766245
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,867
|
management_api_stub.h
|
anbox_anbox/src/anbox/container/management_api_stub.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_MANAGEMENT_API_STUB_H_
#define ANBOX_CONTAINER_MANAGEMENT_API_STUB_H_
#include "anbox/common/wait_handle.h"
#include "anbox/container/configuration.h"
#include "anbox/do_not_copy_or_move.h"
#include <memory>
namespace anbox::protobuf::rpc {
class Void;
}
namespace anbox::rpc {
class Channel;
}
namespace anbox::container {
class ManagementApiStub : public DoNotCopyOrMove {
public:
ManagementApiStub(const std::shared_ptr<rpc::Channel> &channel);
~ManagementApiStub();
void start_container(const Configuration &configuration);
void stop_container();
private:
template <typename Response>
struct Request {
Request() : response(std::make_shared<Response>()), success(true) {}
std::shared_ptr<Response> response;
bool success;
common::WaitHandle wh;
};
void container_started(Request<protobuf::rpc::Void> *request);
void container_stopped(Request<protobuf::rpc::Void> *request);
mutable std::mutex mutex_;
std::shared_ptr<rpc::Channel> channel_;
static const std::chrono::milliseconds stop_waiting_timeout;
};
}
#endif
| 1,771
|
C++
|
.h
| 51
| 32.333333
| 76
| 0.759649
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,868
|
management_api_skeleton.h
|
anbox_anbox/src/anbox/container/management_api_skeleton.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_MANAGEMENT_API_SKELETON_H_
#define ANBOX_CONTAINER_MANAGEMENT_API_SKELETON_H_
#include <memory>
namespace google {
namespace protobuf {
class Closure;
}
}
namespace anbox::protobuf::rpc {
class Void;
}
namespace anbox::protobuf::container {
class StartContainer;
class StopContainer;
}
namespace anbox::rpc {
class PendingCallCache;
}
namespace anbox::container {
class Container;
class ManagementApiSkeleton {
public:
ManagementApiSkeleton(
const std::shared_ptr<Container> &container);
~ManagementApiSkeleton();
void start_container(
anbox::protobuf::container::StartContainer const *request,
anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done);
void stop_container(
anbox::protobuf::container::StopContainer const *request,
anbox::protobuf::rpc::Void *response, google::protobuf::Closure *done);
private:
std::shared_ptr<Container> container_;
};
}
#endif
| 1,643
|
C++
|
.h
| 52
| 29.019231
| 77
| 0.761062
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,869
|
service.h
|
anbox_anbox/src/anbox/container/service.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CONTAINER_SERVICE_H_
#define ANBOX_CONTAINER_SERVICE_H_
#include "anbox/common/dispatcher.h"
#include "anbox/container/container.h"
#include "anbox/network/connections.h"
#include "anbox/network/credentials.h"
#include "anbox/network/published_socket_connector.h"
#include "anbox/network/socket_connection.h"
#include "anbox/runtime.h"
namespace anbox::container {
class Service : public std::enable_shared_from_this<Service> {
public:
struct Configuration {
bool privileged = false;
bool rootfs_overlay = true;
std::string container_network_address;
std::string container_network_gateway;
std::vector<std::string> container_network_dns_servers;
};
static std::shared_ptr<Service> create(const std::shared_ptr<Runtime> &rt,
const Configuration &config);
~Service();
private:
Service(const std::shared_ptr<Runtime> &rt, const Configuration &config);
int next_id();
void new_client(std::shared_ptr<
boost::asio::local::stream_protocol::socket> const &socket);
std::shared_ptr<common::Dispatcher> dispatcher_;
std::shared_ptr<network::PublishedSocketConnector> connector_;
std::atomic<int> next_connection_id_;
std::shared_ptr<network::Connections<network::SocketConnection>> connections_;
std::shared_ptr<Container> backend_;
Configuration config_;
};
}
#endif
| 2,062
|
C++
|
.h
| 52
| 36.153846
| 80
| 0.742258
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,870
|
database.h
|
anbox_anbox/src/anbox/application/database.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_APPLICATION_DATABASE_H_
#define ANBOX_APPLICATION_DATABASE_H_
#include "anbox/android/intent.h"
#include <string>
#include <map>
#include <memory>
namespace anbox::application {
class LauncherStorage;
class Database {
public:
struct Item {
std::string name;
std::string package;
android::Intent launch_intent;
std::vector<char> icon;
bool valid() const { return package.length() > 0; }
};
static const Item Unknown;
Database();
~Database();
void store_or_update(const Item &item);
void remove(const Item &item);
const Item& find_by_package(const std::string &package) const;
private:
std::shared_ptr<LauncherStorage> storage_;
std::map<std::string,Item> items_;
bool done_reset = false;
};
}
#endif
| 1,441
|
C++
|
.h
| 46
| 28.826087
| 76
| 0.74296
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,871
|
gps_info_broker.h
|
anbox_anbox/src/anbox/application/gps_info_broker.h
|
#ifndef ANBOX_APPLICATION_GPS_INFO_BROKER_H_
#define ANBOX_APPLICATION_GPS_INFO_BROKER_H_
#include <boost/signals2.hpp>
#include <string>
#include "anbox/do_not_copy_or_move.h"
namespace anbox::application {
struct GpsInfoBroker : public DoNotCopyOrMove {
boost::signals2::signal<void(const std::string&)> newNmeaSentence;
};
}
#endif
| 340
|
C++
|
.h
| 11
| 29.454545
| 68
| 0.791411
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,872
|
manager.h
|
anbox_anbox/src/anbox/application/manager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_APPLICATION_MANAGER_H_
#define ANBOX_APPLICATION_MANAGER_H_
#include "anbox/android/intent.h"
#include "anbox/do_not_copy_or_move.h"
#include "anbox/graphics/rect.h"
#include "anbox/wm/stack.h"
#include <string>
#include <core/property.h>
namespace anbox::application {
class Manager : public DoNotCopyOrMove {
public:
virtual void launch(const android::Intent &intent,
const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
const wm::Stack::Id &stack = wm::Stack::Id::Default) = 0;
virtual core::Property<bool>& ready() = 0;
};
class RestrictedManager : public Manager {
public:
RestrictedManager(
const std::shared_ptr<Manager> &other,
const wm::Stack::Id &launch_stack = wm::Stack::Id::Invalid) :
other_(other),
launch_stack_(launch_stack) {}
virtual ~RestrictedManager() {}
void launch(const android::Intent &intent,
const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
const wm::Stack::Id &stack = wm::Stack::Id::Default) override {
auto selected_stack = stack;
// If we have a static launch stack set use that one instead of
// the one the caller gave us.
if (launch_stack_ != wm::Stack::Id::Invalid)
selected_stack = launch_stack_;
other_->launch(intent, launch_bounds, selected_stack);
}
core::Property<bool>& ready() override { return other_->ready(); }
private:
std::shared_ptr<Manager> other_;
wm::Stack::Id launch_stack_;
};
}
#endif
| 2,202
|
C++
|
.h
| 57
| 34.736842
| 84
| 0.705248
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,873
|
launcher_storage.h
|
anbox_anbox/src/anbox/application/launcher_storage.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_APPLICATION_LAUNCHER_STORAGE_H_
#define ANBOX_APPLICATION_LAUNCHER_STORAGE_H_
#include "anbox/application/database.h"
#include "anbox/android/intent.h"
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/predicate.hpp>
namespace anbox::application {
class LauncherStorage {
public:
LauncherStorage(const boost::filesystem::path &path);
~LauncherStorage();
void reset();
void add_or_update(const Database::Item &item);
void remove(const Database::Item &item);
private:
std::string clean_package_name(const std::string &package_name);
boost::filesystem::path path_for_item(const std::string &package_name);
boost::filesystem::path path_for_item_icon(const std::string &package_name);
boost::filesystem::path path_;
};
}
#endif
| 1,490
|
C++
|
.h
| 40
| 35.175
| 78
| 0.767684
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,874
|
sensor_type.h
|
anbox_anbox/src/anbox/application/sensor_type.h
|
#ifndef ANBOX_APPLICATION_SENSOR_TYPE_H_
#define ANBOX_APPLICATION_SENSOR_TYPE_H_
#include <string>
namespace anbox::application {
enum SensorType {
UnknownSensor = 0,
AccelerationSensor = (1 << 0),
MagneticFieldSensor = (1 << 1),
OrientationSensor = (1 << 2),
TemperatureSensor = (1 << 3),
ProximitySensor = (1 << 4),
LightSensor = (1 << 5),
PressureSensor = (1 << 6),
HumiditySensor = (1 << 7),
};
class SensorTypeHelper {
public:
static SensorType FromString(const std::string& str);
};
}
#endif
| 522
|
C++
|
.h
| 21
| 22.761905
| 55
| 0.697395
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,875
|
sensors_state.h
|
anbox_anbox/src/anbox/application/sensors_state.h
|
#ifndef ANBOX_APPLICATION_SENSORS_STATE_H_
#define ANBOX_APPLICATION_SENSORS_STATE_H_
#include <cstdint>
#include <tuple>
#include "anbox/do_not_copy_or_move.h"
#include "anbox/logger.h"
namespace anbox::application {
struct SensorsState : public DoNotCopyOrMove {
SensorsState() {
disabled_sensors = 0;
acceleration = {0, 0, 9.80665};
magneticField = {25, 25, 5};
orientation = {0, 0, 0};
temperature = 25;
proximity = 5;
light = 1240;
pressure = 1013.25;
humidity = 45.1;
}
int disabled_sensors;
std::tuple<double, double, double> acceleration;
std::tuple<double, double, double> magneticField;
std::tuple<double, double, double> orientation;
double temperature;
double proximity;
double light;
double pressure;
double humidity;
};
}
#endif
| 804
|
C++
|
.h
| 31
| 22.967742
| 51
| 0.716883
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,876
|
sensors_server.h
|
anbox_anbox/src/anbox/dbus/sensors_server.h
|
/*
* Copyright (C) 2020 Tomasz Grobelny <tomasz@grobelny.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DBUS_SENSORS_SERVER_H_
#define ANBOX_DBUS_SENSORS_SERVER_H_
#include <sdbus-c++/sdbus-c++.h>
#include "anbox/application/sensors_state.h"
#include "sensors_server_glue.h"
class SensorsServer : public sdbus::AdaptorInterfaces<org::anbox::Sensors_adaptor> {
public:
SensorsServer(sdbus::IConnection& connection, std::string objectPath, const std::shared_ptr<anbox::application::SensorsState>& impl)
: sdbus::AdaptorInterfaces<org::anbox::Sensors_adaptor>(connection, std::move(objectPath)), impl_(impl) {
registerAdaptor();
}
virtual ~SensorsServer() {
unregisterAdaptor();
}
sdbus::Struct<double, double, double> Acceleration() override;
void Acceleration(const sdbus::Struct<double, double, double>& value) override;
sdbus::Struct<double, double, double> MagneticField() override;
void MagneticField(const sdbus::Struct<double, double, double>& value) override;
sdbus::Struct<double, double, double> Orientation() override;
void Orientation(const sdbus::Struct<double, double, double>& value) override;
double Temperature() override;
void Temperature(const double& value) override;
double Proximity() override;
void Proximity(const double& value) override;
double Light() override;
void Light(const double& value) override;
double Pressure() override;
void Pressure(const double& value) override;
double Humidity() override;
void Humidity(const double& value) override;
private:
const std::shared_ptr<anbox::application::SensorsState> impl_;
};
#endif
| 2,212
|
C++
|
.h
| 50
| 41.62
| 134
| 0.763695
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,877
|
bus.h
|
anbox_anbox/src/anbox/dbus/bus.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DBUS_BUS_H_
#define ANBOX_DBUS_BUS_H_
#include "anbox/do_not_copy_or_move.h"
#include <atomic>
#include <memory>
#include <mutex>
#include <thread>
#include <systemd/sd-bus.h>
namespace anbox::dbus {
class Bus : public DoNotCopyOrMove {
public:
enum class Type {
System,
Session
};
Bus(Type type);
~Bus();
sd_bus* raw();
bool has_service_with_name(const std::string& name);
void run_async();
void stop();
private:
void worker_main();
sd_bus *bus_ = nullptr;
std::thread worker_thread_;
std::atomic_bool running_{false};
};
using BusPtr = std::shared_ptr<Bus>;
}
#endif
| 1,301
|
C++
|
.h
| 46
| 26
| 76
| 0.730924
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,878
|
gps_server.h
|
anbox_anbox/src/anbox/dbus/gps_server.h
|
/*
* Copyright (C) 2020 Tomasz Grobelny <tomasz@grobelny.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DBUS_GPS_SERVER_H_
#define ANBOX_DBUS_GPS_SERVER_H_
#include <sdbus-c++/sdbus-c++.h>
#include "gps_server_glue.h"
#include "anbox/application/gps_info_broker.h"
class GpsServer : public sdbus::AdaptorInterfaces<org::anbox::Gps_adaptor> {
public:
GpsServer(sdbus::IConnection& connection, std::string objectPath, const std::shared_ptr<anbox::application::GpsInfoBroker>& gpsInfoBroker)
: sdbus::AdaptorInterfaces<org::anbox::Gps_adaptor>(connection, std::move(objectPath)), gps_info_broker_(gpsInfoBroker) {
registerAdaptor();
}
virtual ~GpsServer() {
unregisterAdaptor();
}
void PushSentence(const std::string& sentence) override;
private:
const std::shared_ptr<anbox::application::GpsInfoBroker> gps_info_broker_;
};
#endif
| 1,455
|
C++
|
.h
| 35
| 39.114286
| 140
| 0.75779
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,879
|
interface.h
|
anbox_anbox/src/anbox/dbus/interface.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_DBUS_INTERFACE_H_
#define ANBOX_DBUS_INTERFACE_H_
namespace anbox::dbus::interface {
struct Service {
static inline const char* name() { return "org.anbox"; }
static inline const char* path() { return "/org/anbox"; }
};
}
#endif
| 923
|
C++
|
.h
| 25
| 35.08
| 76
| 0.75
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,880
|
application_manager_client.h
|
anbox_anbox/src/anbox/dbus/application_manager_client.h
|
/*
* Copyright (C) 2020 Tomasz Grobelny <tomasz@grobelny.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <sdbus-c++/sdbus-c++.h>
#include <sstream>
#include "application_manager_client_glue.h"
#include "anbox/android/intent.h"
#include "anbox/logger.h"
#include "anbox/wm/stack.h"
class ApplicationManagerClient : public sdbus::ProxyInterfaces<org::anbox::ApplicationManager_proxy> {
public:
ApplicationManagerClient(sdbus::IConnection& connection, std::string destination, std::string objectPath)
: sdbus::ProxyInterfaces<org::anbox::ApplicationManager_proxy>(connection, std::move(destination), std::move(objectPath)) {
registerProxy();
}
virtual ~ApplicationManagerClient() {
unregisterProxy();
}
bool TryLaunch(anbox::android::Intent intent, anbox::wm::Stack::Id stack);
};
| 1,393
|
C++
|
.h
| 33
| 39.818182
| 129
| 0.762186
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,881
|
application_manager_server.h
|
anbox_anbox/src/anbox/dbus/application_manager_server.h
|
/*
* Copyright (C) 2020 Tomasz Grobelny <tomasz@grobelny.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <sdbus-c++/sdbus-c++.h>
#include "application_manager_server_glue.h"
#include "anbox/application/manager.h"
class ApplicationManagerServer : public sdbus::AdaptorInterfaces<org::anbox::ApplicationManager_adaptor> {
public:
ApplicationManagerServer(sdbus::IConnection& connection, std::string objectPath, const std::shared_ptr<anbox::application::Manager>& impl)
: sdbus::AdaptorInterfaces<org::anbox::ApplicationManager_adaptor>(connection, std::move(objectPath)), impl_(impl) {
registerAdaptor();
}
virtual ~ApplicationManagerServer() {
unregisterAdaptor();
}
protected:
void Launch(const std::map<std::string, sdbus::Variant>& intentDict, const std::string& arg1) override;
bool Ready() override;
private:
const std::shared_ptr<anbox::application::Manager> impl_;
};
| 1,495
|
C++
|
.h
| 34
| 41.441176
| 140
| 0.762199
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,882
|
platform_message_processor.h
|
anbox_anbox/src/anbox/bridge/platform_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_BRIDGE_PLATFORM_MESSAGE_PROCESSOR_H_
#define ANBOX_BRIDGE_PLATFORM_MESSAGE_PROCESSOR_H_
#include "anbox/rpc/message_processor.h"
namespace anbox::bridge {
class PlatformApiSkeleton;
class PlatformMessageProcessor : public rpc::MessageProcessor {
public:
PlatformMessageProcessor(
const std::shared_ptr<network::MessageSender> &sender,
const std::shared_ptr<PlatformApiSkeleton> &server,
const std::shared_ptr<rpc::PendingCallCache> &pending_calls);
~PlatformMessageProcessor();
void dispatch(rpc::Invocation const &invocation) override;
void process_event_sequence(const std::string &event) override;
private:
std::shared_ptr<PlatformApiSkeleton> server_;
};
}
#endif
| 1,392
|
C++
|
.h
| 35
| 37.314286
| 76
| 0.775722
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,883
|
android_api_stub.h
|
anbox_anbox/src/anbox/bridge/android_api_stub.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_BRIDGE_ANDROID_API_STUB_H_
#define ANBOX_BRIDGE_ANDROID_API_STUB_H_
#include "anbox/application/manager.h"
#include "anbox/common/wait_handle.h"
#include "anbox/graphics/rect.h"
#include <memory>
#include <vector>
namespace anbox::protobuf::rpc {
class Void;
}
namespace anbox::rpc {
class Channel;
}
namespace anbox::bridge {
class AndroidApiStub : public anbox::application::Manager {
public:
AndroidApiStub();
~AndroidApiStub();
void set_rpc_channel(const std::shared_ptr<rpc::Channel> &channel);
void reset_rpc_channel();
void set_focused_task(const std::int32_t &id);
void remove_task(const std::int32_t &id);
void resize_task(const std::int32_t &id, const anbox::graphics::Rect &rect,
const std::int32_t &resize_mode);
void launch(const android::Intent &intent,
const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
const wm::Stack::Id &stack = wm::Stack::Id::Default) override;
core::Property<bool>& ready() override;
private:
void ensure_rpc_channel();
template <typename Response>
struct Request {
Request() : response(std::make_shared<Response>()), success(true) {}
std::shared_ptr<Response> response;
bool success;
};
void application_launched(Request<protobuf::rpc::Void> *request);
void focused_task_set(Request<protobuf::rpc::Void> *request);
void task_removed(Request<protobuf::rpc::Void> *request);
void task_resized(Request<protobuf::rpc::Void> *request);
mutable std::mutex mutex_;
std::shared_ptr<rpc::Channel> channel_;
common::WaitHandle launch_wait_handle_;
common::WaitHandle set_focused_task_handle_;
common::WaitHandle remove_task_handle_;
common::WaitHandle resize_task_handle_;
graphics::Rect launch_bounds_ = graphics::Rect::Invalid;
core::Property<bool> ready_;
};
}
#endif
| 2,529
|
C++
|
.h
| 67
| 34.597015
| 77
| 0.732843
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,885
|
buffer_queue.h
|
anbox_anbox/src/anbox/graphics/buffer_queue.h
|
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ANBOX_GRAPHICS_BUFFER_QUEUE_H_
#define ANBOX_GRAPHICS_BUFFER_QUEUE_H_
#include "anbox/common/small_vector.h"
#include <condition_variable>
#include <memory>
#include <mutex>
namespace anbox::graphics {
using Buffer = anbox::common::SmallFixedVector<char, 512>;
class BufferQueue {
public:
BufferQueue(size_t capacity);
bool can_push_locked() const { return !closed_ && (count_ < capacity_); }
bool can_pop_locked() const { return count_ > 0U; }
bool is_closed_locked() const { return closed_; }
int try_push_locked(Buffer &&buffer);
int push_locked(Buffer &&buffer, std::unique_lock<std::mutex> &lock);
int try_pop_locked(Buffer *buffer);
int pop_locked(Buffer *buffer, std::unique_lock<std::mutex> &lock);
void close_locked();
private:
size_t capacity_ = 0;
size_t pos_ = 0;
size_t count_ = 0;
bool closed_ = false;
std::unique_ptr<Buffer[]> buffers_;
std::condition_variable can_push_;
std::condition_variable can_pop_;
};
}
#endif
| 1,594
|
C++
|
.h
| 43
| 35.046512
| 75
| 0.736535
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,886
|
layer_composer.h
|
anbox_anbox/src/anbox/graphics/layer_composer.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_LAYER_COMPOSER_H_
#define ANBOX_GRAPHICS_LAYER_COMPOSER_H_
#include "anbox/graphics/renderer.h"
#include <memory>
#include <map>
namespace anbox::wm {
class Manager;
class Window;
}
namespace anbox::graphics {
class LayerComposer {
public:
class Strategy {
public:
typedef std::map<std::shared_ptr<wm::Window>, RenderableList> WindowRenderableList;
virtual ~Strategy() {}
virtual WindowRenderableList process_layers(const RenderableList &renderables) = 0;
};
LayerComposer(const std::shared_ptr<Renderer> renderer,
const std::shared_ptr<Strategy> &strategy);
~LayerComposer();
void submit_layers(const RenderableList &renderables);
private:
std::shared_ptr<Renderer> renderer_;
std::shared_ptr<Strategy> strategy_;
};
}
#endif
| 1,484
|
C++
|
.h
| 44
| 31.022727
| 87
| 0.754717
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,887
|
renderer.h
|
anbox_anbox/src/anbox/graphics/renderer.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_RENDERER_H_
#define ANBOX_GRAPHICS_RENDERER_H_
#include "anbox/graphics/emugl/Renderable.h"
#include <EGL/egl.h>
namespace anbox::graphics {
class Renderer {
public:
virtual ~Renderer() {}
virtual bool draw(EGLNativeWindowType native_window,
const anbox::graphics::Rect& window_frame,
const RenderableList& renderables) = 0;
};
}
#endif
| 1,084
|
C++
|
.h
| 30
| 32.966667
| 76
| 0.739752
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,888
|
buffered_io_stream.h
|
anbox_anbox/src/anbox/graphics/buffered_io_stream.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_BUFFERED_IO_STREAM_H_
#define ANBOX_GRAPHICS_BUFFERED_IO_STREAM_H_
#include "external/android-emugl/host/include/libOpenglRender/IOStream.h"
#include "anbox/graphics/buffer_queue.h"
#include "anbox/network/socket_messenger.h"
#include <memory>
#include <thread>
namespace anbox::graphics {
class BufferedIOStream : public IOStream {
public:
static const size_t default_buffer_size{384};
explicit BufferedIOStream(
const std::shared_ptr<anbox::network::SocketMessenger> &messenger,
size_t buffer_size = default_buffer_size);
virtual ~BufferedIOStream();
void *allocBuffer(size_t min_size) override;
size_t commitBuffer(size_t size) override;
const unsigned char *read(void *buf, size_t *inout_len) override;
void forceStop() override;
void post_data(Buffer &&data);
bool needs_data();
private:
void thread_main();
std::shared_ptr<anbox::network::SocketMessenger> messenger_;
std::mutex lock_;
std::mutex out_lock_;
Buffer write_buffer_;
Buffer read_buffer_;
size_t read_buffer_left_ = 0;
BufferQueue in_queue_;
BufferQueue out_queue_;
std::thread worker_thread_;
};
}
#endif
| 1,834
|
C++
|
.h
| 51
| 33.431373
| 76
| 0.757901
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,889
|
opengles_message_processor.h
|
anbox_anbox/src/anbox/graphics/opengles_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_
#define ANBOX_GRAPHICS_OPENGLES_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_connection.h"
#include "anbox/network/socket_messenger.h"
#include "anbox/runtime.h"
#include "anbox/common/small_vector.h"
#include "anbox/graphics/buffered_io_stream.h"
#include <boost/asio.hpp>
#include <memory>
#include <mutex>
class IOStream;
class RenderThread;
class Renderer;
namespace anbox::graphics {
class OpenGlesMessageProcessor : public network::MessageProcessor {
public:
OpenGlesMessageProcessor(
const std::shared_ptr<Renderer> &renderer,
const std::shared_ptr<network::SocketMessenger> &messenger);
~OpenGlesMessageProcessor();
bool process_data(network::MessageBuffer &&data) override;
private:
static std::mutex global_lock;
std::shared_ptr<network::SocketMessenger> messenger_;
std::shared_ptr<IOStream> stream_;
std::shared_ptr<RenderThread> render_thread_;
};
}
#endif
| 1,686
|
C++
|
.h
| 46
| 34.521739
| 76
| 0.779277
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,890
|
gl_extensions.h
|
anbox_anbox/src/anbox/graphics/gl_extensions.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_GL_EXTENSIONS_H_
#define ANBOX_GRAPHICS_GL_EXTENSIONS_H_
#include <stdexcept>
#include <string.h>
namespace anbox::graphics {
class GLExtensions {
public:
GLExtensions(char const* extensions) : extensions{extensions} {
if (!extensions)
throw std::runtime_error("Couldn't get list of GL extensions");
}
bool support(char const* ext) const {
if (!ext)
throw std::invalid_argument("Invalid extension name");
char const* ext_ptr = extensions;
size_t const len = strlen(ext);
while ((ext_ptr = strstr(ext_ptr, ext)) != nullptr) {
if (ext_ptr[len] == ' ' || ext_ptr[len] == '\0')
break;
ext_ptr += len;
}
return ext_ptr != nullptr;
}
char const* raw() { return extensions; }
private:
char const* extensions;
};
}
#endif
| 1,493
|
C++
|
.h
| 45
| 30.022222
| 76
| 0.706944
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,891
|
program_family.h
|
anbox_anbox/src/anbox/graphics/program_family.h
|
/*
* Copyright © 2015 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
*/
#ifndef ANBOX_GRAPHICS_PROGRAM_FAMILY_H_
#define ANBOX_GRAPHICS_PROGRAM_FAMILY_H_
#include <map>
#include <unordered_map>
#include <utility>
#include <GLES2/gl2.h>
namespace anbox::graphics {
/**
* ProgramFamily represents a set of GLSL programs that are closely
* related. Programs which point to the same shader source strings will be
* made to share the same compiled shader objects.
* A secondary intention is that this class may be extended to allow the
* different programs within the family to share common patterns of uniform
* usage too.
*/
class ProgramFamily {
public:
ProgramFamily() = default;
ProgramFamily(ProgramFamily const&) = delete;
ProgramFamily& operator=(ProgramFamily const&) = delete;
~ProgramFamily() noexcept;
GLuint add_program(const GLchar* const static_vshader_src,
const GLchar* const static_fshader_src);
private:
struct Shader {
GLuint id = 0;
void init(GLenum type, const GLchar* src);
};
typedef std::unordered_map<const GLchar*, Shader> ShaderMap;
ShaderMap vshader, fshader;
typedef std::pair<GLuint, GLuint> ShaderPair;
struct Program {
GLuint id = 0;
};
std::map<ShaderPair, Program> program;
};
}
#endif // MIR_RENDERER_GL_PROGRAM_FAMILY_H_
| 1,954
|
C++
|
.h
| 55
| 32.872727
| 75
| 0.749471
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,892
|
single_window_composer_strategy.h
|
anbox_anbox/src/anbox/graphics/single_window_composer_strategy.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_SINGLE_WINDOW_COMPOSER_STRATEGY_H_
#define ANBOX_GRAPHICS_SINGLE_WINDOW_COMPOSER_STRATEGY_H_
#include "anbox/graphics/layer_composer.h"
#include <memory>
namespace anbox::graphics {
class SingleWindowComposerStrategy : public LayerComposer::Strategy {
public:
SingleWindowComposerStrategy(const std::shared_ptr<wm::Manager> &wm);
~SingleWindowComposerStrategy() = default;
WindowRenderableList process_layers(const RenderableList &renderables) override;
private:
std::shared_ptr<wm::Manager> wm_;
};
}
#endif
| 1,221
|
C++
|
.h
| 31
| 37.419355
| 82
| 0.782939
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,894
|
density.h
|
anbox_anbox/src/anbox/graphics/density.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_DENSITY_H_
#define ANBOX_GRAPHICS_DENSITY_H_
namespace anbox::graphics {
/**
* @brief Defines different types of density being used in an Android system.
* See the
* documentation in
* frameworks/base/core/java/android/util/DisplayMetrics.java
* of the Android source tree which defines the different types.
*/
enum class DensityType {
low = 120,
medium = 160,
tv = 213,
high = 240,
xhigh = 360,
xxhigh = 480,
};
DensityType current_density();
int dp_to_pixel(unsigned int dp);
}
#endif
| 1,219
|
C++
|
.h
| 38
| 30.131579
| 77
| 0.745331
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,895
|
primitives.h
|
anbox_anbox/src/anbox/graphics/primitives.h
|
/*
* Copyright © 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
* Kevin DuBois <kevin.dubois@canonical.com>
*/
#ifndef ANBOX_GRAPHICS_PRIMITIVES_H_
#define ANBOX_GRAPHICS_PRIMITIVES_H_
#include <GLES2/gl2.h>
namespace anbox::graphics {
struct Vertex {
GLfloat position[3];
GLfloat texcoord[2];
};
struct Primitive {
enum { max_vertices = 4 };
Primitive() : type(GL_TRIANGLE_FAN), nvertices(4) {
// Default is a quad. Just need to assign vertices[] and tex_id.
}
GLenum type; // GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES etc
GLuint tex_id; // GL texture ID (or 0 to represent the surface itself)
int nvertices;
Vertex vertices[max_vertices];
};
}
#endif
| 1,353
|
C++
|
.h
| 38
| 33.421053
| 75
| 0.737968
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,897
|
multi_window_composer_strategy.h
|
anbox_anbox/src/anbox/graphics/multi_window_composer_strategy.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_MULTI_WINDOW_COMPOSER_STRATEGY_H_
#define ANBOX_GRAPHICS_MULTI_WINDOW_COMPOSER_STRATEGY_H_
#include "anbox/graphics/layer_composer.h"
#include <memory>
namespace anbox::graphics {
class MultiWindowComposerStrategy : public LayerComposer::Strategy {
public:
MultiWindowComposerStrategy(const std::shared_ptr<wm::Manager> &wm);
~MultiWindowComposerStrategy() = default;
WindowRenderableList process_layers(const RenderableList &renderables) override;
private:
std::shared_ptr<wm::Manager> wm_;
};
}
#endif
| 1,216
|
C++
|
.h
| 31
| 37.258065
| 82
| 0.782019
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,898
|
opengles_socket_connection.h
|
anbox_anbox/src/anbox/graphics/opengles_socket_connection.h
|
/*
* Copyright © 2018 The UBports project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Marius Gripsgard <marius@ubports.com>
*/
#ifndef ANBOX_GRAPHICS_OPENGLES_SOCKET_CONNECTION_H_
#define ANBOX_GRAPHICS_OPENGLES_SOCKET_CONNECTION_H_
#include "anbox/network/connections.h"
#include "anbox/network/message_processor.h"
#include "anbox/network/message_receiver.h"
#include "anbox/network/message_sender.h"
#include "anbox/network/socket_connection.h"
#include "anbox/graphics/opengles_message_processor.h"
#include <boost/asio.hpp>
#include <sys/types.h>
namespace anbox {
namespace graphics {
class OpenGlesSocketConnection : public network::SocketConnection {
public:
OpenGlesSocketConnection(
std::shared_ptr<network::MessageReceiver> const& message_receiver,
std::shared_ptr<network::MessageSender> const& message_sender, int id,
std::shared_ptr<network::Connections<network::SocketConnection>> const& connections,
std::shared_ptr<network::MessageProcessor> const& processor);
void read_next_message() override;
private:
void on_read_size(const boost::system::error_code& ec,
std::size_t bytes_read) override;
};
} // namespace anbox
} // namespace graphics
#endif
| 1,791
|
C++
|
.h
| 44
| 37.977273
| 90
| 0.765078
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,899
|
ColorBuffer.h
|
anbox_anbox/src/anbox/graphics/emugl/ColorBuffer.h
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_COLORBUFFER_H
#define _LIBRENDER_COLORBUFFER_H
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
#include <memory>
class TextureDraw;
class TextureResize;
// A class used to model a guest color buffer, and used to implement several
// related things:
//
// - Every gralloc native buffer with HW read or write requirements will
// allocate a host ColorBuffer instance. When gralloc_lock() is called,
// the guest will use ColorBuffer::readPixels() to read the current content
// of the buffer. When gralloc_unlock() is later called, it will call
// ColorBuffer::subUpdate() to send the updated pixels.
//
// - Every guest window EGLSurface is implemented by a host PBuffer
// (see WindowSurface.h) that can have a ColorBuffer instance attached to
// it (through WindowSurface::attachColorBuffer()). When such an attachment
// exists, WindowSurface::flushColorBuffer() will copy the PBuffer's
// pixel data into the ColorBuffer. The latter can then be displayed
// in the client's UI sub-window with ColorBuffer::post().
//
// - Guest EGLImages are implemented as native gralloc buffers too.
// The guest glEGLImageTargetTexture2DOES() implementations will end up
// calling ColorBuffer::bindToTexture() to bind the current context's
// GL_TEXTURE_2D to the buffer. Similarly, the guest versions of
// glEGLImageTargetRenderbufferStorageOES() will end up calling
// ColorBuffer::bindToRenderbuffer().
//
// This forces the implementation to use a host EGLImage to implement each
// ColorBuffer.
//
// As an additional twist.
class ColorBuffer {
public:
// Helper interface class used during ColorBuffer operations. This is
// introduced to remove coupling from the FrameBuffer class implementation.
class Helper {
public:
Helper() {}
virtual ~Helper() {}
virtual bool setupContext() = 0;
virtual void teardownContext() = 0;
virtual TextureDraw* getTextureDraw() const = 0;
};
// Create a new ColorBuffer instance.
// |p_display| is the host EGLDisplay handle.
// |p_width| and |p_height| are the buffer's dimensions in pixels.
// |p_internalFormat| is the internal pixel format to use, valid values
// are: GL_RGB, GL_RGB565, GL_RGBA, GL_RGB5_A1_OES and GL_RGBA4_OES.
// Implementation is free to use something else though.
// |has_eglimage_texture_2d| should be true iff the display supports
// the EGL_KHR_gl_texture_2D_image extension.
// Returns NULL on failure.
static ColorBuffer* create(EGLDisplay p_display, int p_width, int p_height,
GLenum p_internalFormat,
bool has_eglimage_texture_2d, Helper* helper);
// Destructor.
~ColorBuffer();
// Return ColorBuffer width and height in pixels
GLuint getWidth() const { return m_width; }
GLuint getHeight() const { return m_height; }
// Read the ColorBuffer instance's pixel values into host memory.
void readPixels(int x, int y, int width, int height, GLenum p_format,
GLenum p_type, void* pixels);
// Update the ColorBuffer instance's pixel values from host memory.
void subUpdate(int x, int y, int width, int height, GLenum p_format,
GLenum p_type, void* pixels);
// Bind the current context's EGL_TEXTURE_2D texture to this ColorBuffer's
// EGLImage. This is intended to implement glEGLImageTargetTexture2DOES()
// for all GLES versions.
bool bindToTexture();
// Bind the current context's EGL_RENDERBUFFER_OES render buffer to this
// ColorBuffer's EGLImage. This is intended to implement
// glEGLImageTargetRenderbufferStorageOES() for all GLES versions.
bool bindToRenderbuffer();
// Copy the content of the current context's read surface to this
// ColorBuffer. This is used from WindowSurface::flushColorBuffer().
// Return true on success, false on failure (e.g. no current context).
bool blitFromCurrentReadBuffer();
// Read the content of the whole ColorBuffer as 32-bit RGBA pixels.
// |img| must be a buffer large enough (i.e. width * height * 4).
void readback(unsigned char* img);
void bind();
private:
ColorBuffer(); // no default constructor.
explicit ColorBuffer(EGLDisplay display, Helper* helper);
private:
GLuint m_tex;
GLuint m_blitTex;
EGLImageKHR m_eglImage;
EGLImageKHR m_blitEGLImage;
GLuint m_width;
GLuint m_height;
GLuint m_fbo;
GLenum m_internalFormat;
EGLDisplay m_display;
Helper* m_helper;
TextureResize* m_resizer;
};
typedef std::shared_ptr<ColorBuffer> ColorBufferPtr;
#endif
| 5,187
|
C++
|
.h
| 119
| 40.546218
| 78
| 0.740095
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,902
|
ReadBuffer.h
|
anbox_anbox/src/anbox/graphics/emugl/ReadBuffer.h
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _READ_BUFFER_H
#define _READ_BUFFER_H
#include "external/android-emugl/host/include/libOpenglRender/IOStream.h"
class ReadBuffer {
public:
ReadBuffer(size_t bufSize);
~ReadBuffer();
int getData(IOStream *stream); // get fresh data from the stream
unsigned char *buf() { return m_readPtr; } // return the next read location
size_t validData() {
return m_validData;
} // return the amount of valid data in readptr
void consume(size_t amount); // notify that 'amount' data has been consumed;
private:
unsigned char *m_buf;
unsigned char *m_readPtr;
size_t m_size;
size_t m_validData;
};
#endif
| 1,274
|
C++
|
.h
| 35
| 34.514286
| 79
| 0.731392
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,903
|
DisplayManager.h
|
anbox_anbox/src/anbox/graphics/emugl/DisplayManager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_GRAPHICS_EMUGL_DISPLAY_INFO_H_
#define ANBOX_GRAPHICS_EMUGL_DISPLAY_INFO_H_
#include <cstdint>
#include <memory>
namespace anbox::graphics::emugl {
class DisplayInfo {
public:
DisplayInfo() = default;
static std::shared_ptr<DisplayInfo> get();
void set_resolution(const std::uint32_t &vertical, const std::uint32_t horizontal);
std::uint32_t vertical_resolution() const;
std::uint32_t horizontal_resolution() const;
private:
std::uint32_t vertical_resolution_ = 1280;
std::uint32_t horizontal_resolution_ = 720;
};
}
#endif
| 1,235
|
C++
|
.h
| 34
| 34.205882
| 85
| 0.759631
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,904
|
WindowSurface.h
|
anbox_anbox/src/anbox/graphics/emugl/WindowSurface.h
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_WINDOW_SURFACE_H
#define _LIBRENDER_WINDOW_SURFACE_H
#include "anbox/graphics/emugl/ColorBuffer.h"
#include "anbox/graphics/emugl/RenderContext.h"
#include <EGL/egl.h>
#include <GLES/gl.h>
// A class used to model a guest-side window surface. The implementation
// uses a host Pbuffer to act as the EGL rendering surface instead.
class WindowSurface {
public:
// Create a new WindowSurface instance.
// |display| is the host EGLDisplay value.
// |config| is the host EGLConfig value.
// |width| and |height| are the initial size of the Pbuffer.
// Return a new WindowSurface instance on success, or NULL on failure.
static WindowSurface* create(EGLDisplay display, EGLConfig config, int width,
int height);
// Destructor.
~WindowSurface();
// Retrieve the host EGLSurface of the WindowSurface's Pbuffer.
EGLSurface getEGLSurface() const { return mSurface; }
// Attach a ColorBuffer to this WindowSurface.
// Once attached, calling flushColorBuffer() will copy the Pbuffer's
// pixels to the color buffer.
//
// IMPORTANT: This automatically resizes the Pbuffer's to the ColorBuffer's
// dimensions. Potentially losing pixel values in the process.
void setColorBuffer(ColorBufferPtr p_colorBuffer);
// Copy the Pbuffer's pixels to the attached color buffer.
// Returns true on success, or false on error (e.g. if there is no
// attached color buffer).
bool flushColorBuffer();
// Used by bind() below.
enum BindType { BIND_READ,
BIND_DRAW,
BIND_READDRAW };
// TODO(digit): What is this used for exactly? For example, the
// mReadContext is never used by this class. The mDrawContext is only
// used temporarily during flushColorBuffer() operation, and could be
// passed as a parameter to the function instead. Maybe this is only used
// to increment reference counts on the smart pointers.
//
// Bind a context to the WindowSurface (huh? Normally you would bind a
// surface to the context, not the other way around)
//
// |p_ctx| is a RenderContext pointer.
// |p_bindType| is the type of bind. For BIND_READ, this assigns |p_ctx|
// to mReadContext, for BIND_DRAW, it assigns it to mDrawContext, and for
// for BIND_READDRAW, it assigns it to both.
void bind(RenderContextPtr p_ctx, BindType p_bindType);
private:
WindowSurface();
WindowSurface(const WindowSurface& other);
explicit WindowSurface(EGLDisplay display, EGLConfig config);
bool resize(unsigned int p_width, unsigned int p_height);
private:
EGLSurface mSurface;
ColorBufferPtr mAttachedColorBuffer;
RenderContextPtr mReadContext;
RenderContextPtr mDrawContext;
GLuint mWidth;
GLuint mHeight;
EGLConfig mConfig;
EGLDisplay mDisplay;
};
typedef std::shared_ptr<WindowSurface> WindowSurfacePtr;
#endif // _LIBRENDER_WINDOW_SURFACE_H
| 3,498
|
C++
|
.h
| 82
| 39.426829
| 79
| 0.749779
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,905
|
TextureResize.h
|
anbox_anbox/src/anbox/graphics/emugl/TextureResize.h
|
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_TEXTURERESIZE_H
#define _LIBRENDER_TEXTURERESIZE_H
#include <GLES2/gl2.h>
class TextureResize {
public:
TextureResize(GLuint width, GLuint height);
~TextureResize();
// Scales the given texture for the current viewport and returns the scaled
// texture. May return the input if no scaling is required.
GLuint update(GLuint texture);
struct Framebuffer {
GLuint texture = 0;
GLuint framebuffer = 0;
GLuint program = 0;
GLuint aPosition = 0;
GLuint uTexture = 0;
};
private:
void setupFramebuffers(unsigned int factor);
void resize(GLuint texture);
private:
GLuint mWidth;
GLuint mHeight;
unsigned int mFactor;
Framebuffer mFBWidth;
Framebuffer mFBHeight;
GLuint mVertexBuffer;
};
#endif
| 1,367
|
C++
|
.h
| 44
| 28.681818
| 77
| 0.768061
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,907
|
Renderable.h
|
anbox_anbox/src/anbox/graphics/emugl/Renderable.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANBOX_GRAPHICS_EMUGL_RENDERABLE_H_
#define ANBOX_GRAPHICS_EMUGL_RENDERABLE_H_
#include "anbox/graphics/rect.h"
#include <string>
#include <vector>
#include <cstdint>
#include <glm/glm.hpp>
class Renderable {
public:
Renderable(const std::string &name, const std::uint32_t &buffer, float alpha,
const anbox::graphics::Rect &screen_position,
const anbox::graphics::Rect &crop = {},
const glm::mat4 &transformation = glm::mat4(1.0f));
~Renderable();
std::string name() const;
std::uint32_t buffer() const;
anbox::graphics::Rect screen_position() const;
anbox::graphics::Rect crop() const;
glm::mat4 transformation() const;
float alpha() const;
void set_screen_position(const anbox::graphics::Rect &screen_position);
inline bool operator==(const Renderable &rhs) const {
return (name_ == rhs.name() && buffer_ == rhs.buffer() &&
screen_position_ == rhs.screen_position() && crop_ == rhs.crop() &&
transformation_ == rhs.transformation() && alpha_ == rhs.alpha());
}
inline bool operator!=(const Renderable &rhs) const {
return !operator==(rhs);
}
private:
std::string name_;
std::uint32_t buffer_;
anbox::graphics::Rect screen_position_;
anbox::graphics::Rect crop_;
glm::mat4 transformation_;
float alpha_;
};
std::ostream &operator<<(std::ostream &out, const Renderable &r);
typedef std::vector<Renderable> RenderableList;
#endif
| 2,062
|
C++
|
.h
| 55
| 34.218182
| 79
| 0.712995
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,909
|
RenderContext.h
|
anbox_anbox/src/anbox/graphics/emugl/RenderContext.h
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_RENDER_CONTEXT_H
#define _LIBRENDER_RENDER_CONTEXT_H
#include "external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h"
#include <EGL/egl.h>
#include <memory>
// A class used to model a guest EGLContext. This simply wraps a host
// EGLContext, associated with an GLDecoderContextData instance that is
// used to store copies of guest-side arrays.
class RenderContext {
public:
// Create a new RenderContext instance.
// |display| is the host EGLDisplay handle.
// |config| is the host EGLConfig to use.
// |sharedContext| is either EGL_NO_CONTEXT of a host EGLContext handle.
// |isGl2| is true iff the new context will be used with GLESv2, or
// GLESv1 otherwise.
static RenderContext* create(EGLDisplay display, EGLConfig config,
EGLContext sharedContext, bool isGL2 = false);
// Destructor.
~RenderContext();
// Retrieve host EGLContext value.
EGLContext getEGLContext() const { return mContext; }
// Return true iff this is a GLESv2 context.
bool isGL2() const { return mIsGl2; }
// Retrieve GLDecoderContextData instance reference for this
// RenderContext instance.
GLDecoderContextData& decoderContextData() { return mContextData; }
private:
RenderContext();
RenderContext(EGLDisplay display, EGLContext context, bool isGl2);
private:
EGLDisplay mDisplay;
EGLContext mContext;
bool mIsGl2;
GLDecoderContextData mContextData;
};
typedef std::shared_ptr<RenderContext> RenderContextPtr;
#endif // _LIBRENDER_RENDER_CONTEXT_H
| 2,158
|
C++
|
.h
| 53
| 37.981132
| 81
| 0.768532
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,911
|
TimeUtils.h
|
anbox_anbox/src/anbox/graphics/emugl/TimeUtils.h
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _TIME_UTILS_H
#define _TIME_UTILS_H
long long GetCurrentTimeMS();
void TimeSleepMS(int p_mili);
#endif
| 715
|
C++
|
.h
| 20
| 34.6
| 74
| 0.781792
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,912
|
DispatchTables.h
|
anbox_anbox/src/anbox/graphics/emugl/DispatchTables.h
|
/*
* Copyright (C) 2011-2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "OpenGLESDispatch/GLESv2Dispatch.h"
extern GLESv2Dispatch s_gles2;
extern GLESv1Dispatch s_gles1;
| 773
|
C++
|
.h
| 20
| 37.55
| 74
| 0.797603
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,914
|
TextureDraw.h
|
anbox_anbox/src/anbox/graphics/emugl/TextureDraw.h
|
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef TEXTURE_DRAW_H
#define TEXTURE_DRAW_H
#include <EGL/egl.h>
#include <GLES2/gl2.h>
// Helper class used to draw a simple texture to the current framebuffer.
// Usage is pretty simple:
//
// 1) Create a TextureDraw instance, passing the current EGLDisplay to it.
//
// 2) Each time you want to draw a texture, call draw(texture, rotation),
// where |texture| is the name of a GLES 2.x texture object, and
// |rotation| is an angle in degrees describing the clockwise rotation
// in the GL y-upwards coordinate space. This function fills the whole
// framebuffer with texture content.
//
class TextureDraw {
public:
// Create a new instance.
TextureDraw(EGLDisplay display);
// Destructor
~TextureDraw();
// Fill the current framebuffer with the content of |texture|, which must
// be the name of a GLES 2.x texture object.
bool draw(GLuint texture);
private:
GLuint mVertexShader;
GLuint mFragmentShader;
GLuint mProgram;
GLint mPositionSlot;
GLint mInCoordSlot;
GLint mTextureSlot;
GLuint mVertexBuffer;
GLuint mIndexBuffer;
};
#endif // TEXTURE_DRAW_H
| 1,732
|
C++
|
.h
| 48
| 34.270833
| 76
| 0.752534
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,916
|
window_state.h
|
anbox_anbox/src/anbox/wm/window_state.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_WM_WINDOW_STATE_H_
#define ANBOX_WM_WINDOW_STATE_H_
#include "anbox/graphics/rect.h"
#include "anbox/wm/display.h"
#include "anbox/wm/stack.h"
#include "anbox/wm/task.h"
#include <string>
#include <vector>
namespace anbox::wm {
class WindowState {
public:
typedef std::vector<WindowState> List;
WindowState();
WindowState(const Display::Id &display, bool has_surface,
const graphics::Rect &frame, const std::string &package_name,
const Task::Id &task, const Stack::Id &stack);
~WindowState();
Display::Id display() const { return display_; }
bool has_surface() const { return has_surface_; }
graphics::Rect frame() const { return frame_; }
std::string package_name() const { return package_name_; }
Task::Id task() const { return task_; }
Stack::Id stack() const { return stack_; }
private:
Display::Id display_;
bool has_surface_;
graphics::Rect frame_;
std::string package_name_;
Task::Id task_;
Stack::Id stack_;
};
}
#endif
| 1,685
|
C++
|
.h
| 49
| 31.673469
| 76
| 0.721301
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,917
|
task.h
|
anbox_anbox/src/anbox/wm/task.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_WM_TASK_H_
#define ANBOX_WM_TASK_H_
#include <cstdint>
namespace anbox::wm {
class Task {
public:
typedef std::int32_t Id;
static Id Invalid;
Task() = delete;
Task(const Task&) = delete;
};
}
#endif
| 901
|
C++
|
.h
| 29
| 29.068966
| 76
| 0.746251
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,919
|
display.h
|
anbox_anbox/src/anbox/wm/display.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_WM_DISPLAY_H_
#define ANBOX_WM_DISPLAY_H_
#include <cstdint>
namespace anbox::wm {
class Display {
public:
typedef std::int32_t Id;
static Id Invalid;
static Id Default;
Display() = delete;
Display(const Display&) = delete;
};
}
#endif
| 940
|
C++
|
.h
| 30
| 29.3
| 76
| 0.751381
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,921
|
multi_window_manager.h
|
anbox_anbox/src/anbox/wm/multi_window_manager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_WM_MULTI_WINDOW_MANAGER_H_
#define ANBOX_WM_MULTI_WINDOW_MANAGER_H_
#include "anbox/wm/manager.h"
#include <map>
#include <memory>
#include <mutex>
namespace anbox::application {
class Database;
}
namespace anbox::bridge {
class AndroidApiStub;
}
namespace anbox::platform {
class BasePlatform;
}
namespace anbox::wm {
class MultiWindowManager : public Manager {
public:
MultiWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub,
const std::shared_ptr<application::Database> &app_db);
~MultiWindowManager();
void apply_window_state_update(const WindowState::List &updated, const WindowState::List &removed) override;
std::shared_ptr<Window> find_window_for_task(const Task::Id &task) override;
void resize_task(const Task::Id &task, const anbox::graphics::Rect &rect,
const std::int32_t &resize_mode) override;
void set_focused_task(const Task::Id &task) override;
void remove_task(const Task::Id &task) override;
private:
std::mutex mutex_;
std::weak_ptr<platform::BasePlatform> platform_;
std::shared_ptr<bridge::AndroidApiStub> android_api_stub_;
std::shared_ptr<application::Database> app_db_;
std::map<Task::Id, std::shared_ptr<Window>> windows_;
};
}
#endif
| 2,036
|
C++
|
.h
| 53
| 35.169811
| 110
| 0.739351
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,922
|
stack.h
|
anbox_anbox/src/anbox/wm/stack.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_WM_STACK_H_
#define ANBOX_WM_STACK_H_
#include <ostream>
namespace anbox::wm {
class Stack {
public:
enum class Id {
Invalid = -1,
Default = 0,
Fullscreen = 1,
Freeform = 2,
};
Stack() = delete;
Stack(const Stack&) = delete;
};
std::ostream& operator<<(std::ostream &out, Stack::Id const &stack);
std::istream& operator>>(std::istream &in, Stack::Id &stack);
}
#endif
| 1,088
|
C++
|
.h
| 35
| 28.742857
| 76
| 0.723709
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,923
|
environment_file.h
|
anbox_anbox/src/anbox/utils/environment_file.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_UTILS_ENVIRONMENT_FILE_H_
#define ANBOX_UTILS_ENVIRONMENT_FILE_H_
#include <map>
#include <string>
#include <boost/filesystem.hpp>
namespace anbox::utils {
class EnvironmentFile {
public:
EnvironmentFile(const boost::filesystem::path &path);
~EnvironmentFile() = default;
std::string value(const std::string &key, const std::string &default_value = "") const;
private:
std::map<std::string, std::string> data_;
};
}
#endif
| 1,122
|
C++
|
.h
| 32
| 33.125
| 89
| 0.75576
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,924
|
intent.h
|
anbox_anbox/src/anbox/android/intent.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_ANDROID_INTENT_H_
#define ANBOX_ANDROID_INTENT_H_
#include <string>
#include <vector>
namespace anbox::android {
struct Intent {
std::string action;
std::string uri;
std::string type;
int flags = 0;
std::string package;
std::string component;
std::vector<std::string> categories;
bool valid() const;
};
std::ostream &operator<<(std::ostream &out, const Intent &intent);
}
#endif
| 1,088
|
C++
|
.h
| 34
| 29.941176
| 76
| 0.749285
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,925
|
ip_config_builder.h
|
anbox_anbox/src/anbox/android/ip_config_builder.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_ANDROID_IPCONFIGBUILDER_H_
#define ANBOX_ANDROID_IPCONFIGBUILDER_H_
#include "anbox/common/binary_writer.h"
#include <string>
#include <vector>
#include <cstdint>
namespace anbox::android {
class IpConfigBuilder {
public:
enum class Version : std::uint32_t {
Version1 = 1,
Version2 = 2,
};
enum class Assignment {
Static,
DHCP,
};
IpConfigBuilder() = default;
std::size_t write(common::BinaryWriter &writer);
void set_version(const Version &version);
void set_assignment(const Assignment &assignment);
void set_link_address(const std::string &address, std::uint32_t prefix_length);
void set_gateway(const std::string &gateway);
void set_dns_servers(const std::vector<std::string> &dns_servers);
void set_id(std::uint32_t id);
private:
Version version_;
Assignment assignment_;
struct {
std::string address;
std::uint32_t prefix_length;
} link_;
std::string gateway_;
std::vector<std::string> dns_servers_;
std::uint32_t id_;
};
}
#endif
| 1,698
|
C++
|
.h
| 54
| 28.814815
| 81
| 0.73945
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,926
|
splash_screen.h
|
anbox_anbox/src/anbox/ui/splash_screen.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_UI_SPLASH_SCREEN_H_
#define ANBOX_UI_SPLASH_SCREEN_H_
#include <thread>
#include <SDL2/SDL.h>
namespace anbox::ui {
class SplashScreen {
public:
SplashScreen();
~SplashScreen();
private:
void process_events();
std::thread event_thread_;
bool event_thread_running_;
SDL_Window *window_;
};
}
#endif
| 1,006
|
C++
|
.h
| 33
| 28.424242
| 76
| 0.752844
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,928
|
binder_device_allocator.h
|
anbox_anbox/src/anbox/common/binder_device_allocator.h
|
/*
* Copyright (C) 2018 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_BINDER_DEVICE_ALLOCATOR_H_
#define ANBOX_COMMON_BINDER_DEVICE_ALLOCATOR_H_
#include <memory>
namespace anbox::common {
class BinderDevice;
class BinderDeviceAllocator {
public:
static bool is_supported();
static std::unique_ptr<BinderDevice> new_device();
};
}
#endif
| 954
|
C++
|
.h
| 28
| 32.25
| 76
| 0.770314
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,929
|
mount_entry.h
|
anbox_anbox/src/anbox/common/mount_entry.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_MOUNT_ENTRY_H_
#define ANBOX_COMMON_MOUNT_ENTRY_H_
#include <boost/filesystem/path.hpp>
#include <memory>
namespace anbox::common {
class LoopDevice;
class MountEntry {
public:
static std::shared_ptr<MountEntry> create(const boost::filesystem::path &src, const boost::filesystem::path &target,
const std::string &fs_type = "", unsigned long flags = 0, const std::string &data = "");
static std::shared_ptr<MountEntry> create(const std::shared_ptr<LoopDevice> &loop, const boost::filesystem::path &target,
const std::string &fs_type = "", unsigned long flags = 0, const std::string &data = "");
static std::shared_ptr<MountEntry> create(const boost::filesystem::path &target);
~MountEntry();
private:
MountEntry(const boost::filesystem::path &target);
bool active_;
std::shared_ptr<LoopDevice> loop_;
boost::filesystem::path target_;
};
}
#endif
| 1,654
|
C++
|
.h
| 38
| 39.131579
| 132
| 0.707711
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,932
|
fd_sets.h
|
anbox_anbox/src/anbox/common/fd_sets.h
|
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Robert Carr <robert.carr@canonical.com>
*/
#ifndef ANBOX_COMMON_FD_SETS_H_
#define ANBOX_COMMON_FD_SETS_H_
#include <initializer_list>
#include <vector>
#include "anbox/common/fd.h"
namespace anbox {
typedef std::vector<std::vector<Fd>> FdSets;
} // namespace anbox
#endif
| 923
|
C++
|
.h
| 26
| 33.692308
| 74
| 0.758969
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,933
|
message_channel.h
|
anbox_anbox/src/anbox/common/message_channel.h
|
// Copyright 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ANBOX_COMMON_MESSAGE_CHANNEL_H
#define ANBOX_COMMON_MESSAGE_CHANNEL_H
#include <stddef.h>
#include <condition_variable>
#include <mutex>
namespace anbox::common {
// Base non-templated class used to reduce the amount of template
// specialization.
class MessageChannelBase {
public:
// Constructor. |capacity| is the buffer capacity in messages.
MessageChannelBase(size_t capacity);
// Destructor.
~MessageChannelBase();
protected:
// Call this method in the sender thread before writing a new message.
// This returns the position of the available slot in the message array
// where to copy the new fixed-size message. After the copy, call
// afterWrite().
size_t before_write();
// To be called after beforeWrite() and copying a new fixed-size message
// into the array. This signal the receiver thread that there is a new
// incoming message.
void after_write();
// Call this method in the receiver thread before reading a new message.
// This returns the position in the message array where the new message
// can be read. Caller must process the message, then call afterRead().
size_t before_read();
// To be called in the receiver thread after beforeRead() and processing
// the corresponding message.
void after_read();
private:
size_t pos_;
size_t count_;
size_t capacity_;
std::mutex lock_;
std::condition_variable can_read_;
std::condition_variable can_write_;
};
// Helper class used to implement an uni-directional IPC channel between
// two threads. The channel can be used to send fixed-size messages of type
// |T|, with an internal buffer size of |CAPACITY| items. All calls are
// blocking.
//
// Usage is pretty straightforward:
//
// - From the sender thread, call send(msg);
// - From the receiver thread, call receive(&msg);
//
template <typename T, size_t CAPACITY>
class MessageChannel : public MessageChannelBase {
public:
MessageChannel() : MessageChannelBase(CAPACITY) {}
void send(const T& msg) {
size_t pos = before_write();
mItems[pos] = msg;
after_write();
}
void receive(T* msg) {
size_t pos = before_read();
*msg = mItems[pos];
after_read();
}
private:
T mItems[CAPACITY];
};
}
#endif
| 2,841
|
C++
|
.h
| 81
| 32.740741
| 75
| 0.740984
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,936
|
scope_ptr.h
|
anbox_anbox/src/anbox/common/scope_ptr.h
|
// Copyright 2014 The Android Open Source Project
//
// This software is licensed under the terms of the GNU General Public
// License version 2, as published by the Free Software Foundation, and
// may be copied, distributed, and modified under those terms.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#pragma once
#include "anbox/common/type_traits.h"
#include <memory>
#include <type_traits>
#include <utility>
#include <stdlib.h>
namespace anbox::common {
struct FreeDelete {
template <class T>
void operator()(T ptr) const {
free(ptr);
}
};
template <class Func>
struct FuncDelete {
explicit FuncDelete(Func f) : mF(f) {}
FuncDelete(const FuncDelete& other) = default;
FuncDelete(FuncDelete&& other) = default;
FuncDelete& operator=(const FuncDelete& other) = default;
FuncDelete& operator=(FuncDelete&& other) = default;
// To be able to copy/move from all compatible template instantiations.
template <class U>
friend struct FuncDelete;
// Template constructors and move assignment from compatible instantiations.
template <class U>
FuncDelete(const FuncDelete<U>& other) : mF(other.mF) {}
template <class U>
FuncDelete(FuncDelete<U>&& other) : mF(std::move(other.mF)) {}
template <class U>
FuncDelete& operator=(const FuncDelete<U>& other) {
mF = other.mF;
return *this;
}
template <class U>
FuncDelete& operator=(FuncDelete<U>&& other) {
mF = std::move(other.mF);
return *this;
}
// This is the actual deleter call.
template <class T>
void operator()(T t) const {
mF(t);
}
private:
Func mF;
};
template <class T, class Deleter = std::default_delete<T>>
using ScopedPtr = std::unique_ptr<T, Deleter>;
template <class T>
using ScopedCPtr = std::unique_ptr<T, FreeDelete>;
template <class T, class Func>
using ScopedCustomPtr = std::unique_ptr<T, FuncDelete<Func>>;
// A factory function that creates a scoped pointer with |deleter|
// function used as a deleter - it is called at the scope exit.
// Note: enable_if<> limits the scope of allowed arguments to pointers and
// std::nullptr_t (to allow makeCustomScopedPtr(nullptr, ...) calls).
template <class T,
class Func,
class = enable_if_c<std::is_same<T, std::nullptr_t>::value ||
std::is_pointer<T>::value>>
ScopedCustomPtr<
typename std::decay<typename std::remove_pointer<T>::type>::type,
typename std::decay<Func>::type>
makeCustomScopedPtr(T data, Func deleter) {
return ScopedCustomPtr<
typename std::decay<typename std::remove_pointer<T>::type>::type,
typename std::decay<Func>::type>(
data, FuncDelete<typename std::decay<Func>::type>(deleter));
}
}
| 2,897
|
C++
|
.h
| 80
| 33.05
| 78
| 0.719029
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,937
|
binderfs.h
|
anbox_anbox/src/anbox/common/binderfs.h
|
/*
* Copyright (C) 2018 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_BINDERFS_H_
#define ANBOX_COMMON_BINDERFS_H_
#include <linux/types.h>
#include <linux/ioctl.h>
#define BINDERFS_MAX_NAME 255
/**
* struct binderfs_device - retrieve information about a new binder device
* @name: the name to use for the new binderfs binder device
* @major: major number allocated for binderfs binder devices
* @minor: minor number allocated for the new binderfs binder device
*
*/
struct binderfs_device {
char name[BINDERFS_MAX_NAME + 1];
__u32 major;
__u32 minor;
};
/**
* Allocate a new binder device.
*/
#define BINDER_CTL_ADD _IOWR('b', 1, struct binderfs_device)
#endif
| 1,294
|
C++
|
.h
| 38
| 32.131579
| 76
| 0.7512
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,938
|
loop_device.h
|
anbox_anbox/src/anbox/common/loop_device.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_LOOP_DEVICE_H_
#define ANBOX_COMMON_LOOP_DEVICE_H_
#include "anbox/common/fd.h"
#include <boost/filesystem/path.hpp>
namespace anbox::common {
class LoopDevice {
public:
static std::shared_ptr<LoopDevice> create(const boost::filesystem::path &path);
~LoopDevice();
bool attach_file(const boost::filesystem::path &file_path);
boost::filesystem::path path() const { return path_; }
private:
LoopDevice(Fd fd, const boost::filesystem::path &path);
Fd fd_;
boost::filesystem::path path_;
};
}
#endif
| 1,216
|
C++
|
.h
| 34
| 33.588235
| 81
| 0.752771
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,939
|
binder_device.h
|
anbox_anbox/src/anbox/common/binder_device.h
|
/*
* Copyright (C) 2018 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_BINDER_DEVICE_H_
#define ANBOX_COMMON_BINDER_DEVICE_H_
#include "anbox/common/fd.h"
#include <boost/filesystem/path.hpp>
namespace anbox::common {
class BinderDevice {
public:
static std::unique_ptr<BinderDevice> create(const std::string& path);
~BinderDevice();
boost::filesystem::path path() const { return path_; }
private:
BinderDevice(const std::string& path);
const std::string path_;
};
}
#endif
| 1,101
|
C++
|
.h
| 32
| 32.3125
| 76
| 0.756833
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,940
|
dispatcher.h
|
anbox_anbox/src/anbox/common/dispatcher.h
|
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*
*/
#ifndef ANBOX_COMMON_DISPATCHER_H_
#define ANBOX_COMMON_DISPATCHER_H_
#include "anbox/do_not_copy_or_move.h"
#include "anbox/runtime.h"
#include <memory>
namespace anbox::common {
class Dispatcher : public DoNotCopyOrMove {
public:
typedef std::function<void()> Task;
virtual void dispatch(const Task& task) = 0;
protected:
Dispatcher() = default;
};
std::shared_ptr<Dispatcher> create_dispatcher_for_runtime(
const std::shared_ptr<Runtime>&);
}
#endif
| 1,184
|
C++
|
.h
| 35
| 31.828571
| 78
| 0.75678
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,941
|
binary_writer.h
|
anbox_anbox/src/anbox/common/binary_writer.h
|
/*
* Copyright (C) 2016 Thomas Voss <thomas.voss.bochum@gmail.com>
* Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_BINARY_WRITER_H_
#define ANBOX_COMMON_BINARY_WRITER_H_
#include <cstdint>
#include <vector>
#include <string>
namespace anbox::common {
class BinaryWriter {
public:
enum class Order {
Big,
Little,
};
explicit BinaryWriter(std::vector<std::uint8_t>::iterator begin_,
std::vector<std::uint8_t>::iterator end_);
void set_byte_order(Order order);
void write_uint16(std::uint16_t value);
void write_uint32(std::uint32_t value);
void write_string(const char *s, std::size_t size);
void write_string_with_size(const std::string &str);
void write_string_with_size(const char *s, std::size_t size);
std::size_t bytes_written() const;
private:
std::vector<std::uint8_t>::iterator begin_;
std::vector<std::uint8_t>::iterator current_;
std::vector<std::uint8_t>::iterator end_;
Order byte_order_;
};
}
#endif
| 1,627
|
C++
|
.h
| 46
| 32.5
| 76
| 0.719008
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,942
|
loop_device_allocator.h
|
anbox_anbox/src/anbox/common/loop_device_allocator.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_COMMON_LOOP_DEVICE_ALLOCATOR_H_
#define ANBOX_COMMON_LOOP_DEVICE_ALLOCATOR_H_
#include <memory>
namespace anbox::common {
class LoopDevice;
class LoopDeviceAllocator {
public:
static std::shared_ptr<LoopDevice> new_device();
};
}
#endif
| 931
|
C++
|
.h
| 27
| 32.703704
| 76
| 0.769145
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,943
|
version.h
|
anbox_anbox/src/anbox/cmds/version.h
|
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*
*/
#ifndef ANBOX_CMDS_VERSION_H_
#define ANBOX_CMDS_VERSION_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
namespace anbox::cmds {
class Version : public cli::CommandWithFlagsAndAction {
public:
Version();
};
}
#endif
| 974
|
C++
|
.h
| 31
| 29.645161
| 78
| 0.759318
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,944
|
wait_ready.h
|
anbox_anbox/src/anbox/cmds/wait_ready.h
|
/*
* Copyright (C) 2018 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_WAIT_READY_H_
#define ANBOX_CMDS_WAIT_READY_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
namespace anbox::cmds {
class WaitReady : public cli::CommandWithFlagsAndAction {
public:
WaitReady();
private:
bool use_system_dbus_ = false;
};
}
#endif
| 989
|
C++
|
.h
| 31
| 30.064516
| 76
| 0.760756
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,945
|
session_manager.h
|
anbox_anbox/src/anbox/cmds/session_manager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_RUN_H_
#define ANBOX_CMDS_RUN_H_
#include "anbox/cli.h"
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/graphics/gl_renderer_server.h"
#include "anbox/graphics/rect.h"
namespace anbox::bridge {
class AndroidApiStub;
}
namespace anbox::container {
class Client;
}
namespace anbox::cmds {
class SessionManager : public cli::CommandWithFlagsAndAction {
public:
SessionManager();
private:
void launch_appmgr_if_needed(const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub);
std::shared_ptr<container::Client> container_;
std::string desktop_file_hint_;
std::string disabled_sensors_;
bool single_window_ = false;
graphics::Rect window_size_;
bool standalone_ = false;
bool experimental_ = false;
bool use_system_dbus_ = false;
bool use_software_rendering_ = false;
bool no_touch_emulation_ = false;
bool server_side_decoration_ = false;
bool rootless_ = false;
};
}
#endif
| 1,643
|
C++
|
.h
| 51
| 30.078431
| 96
| 0.758054
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,946
|
launch.h
|
anbox_anbox/src/anbox/cmds/launch.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_LAUNCH_H_
#define ANBOX_CMDS_LAUNCH_H_
#include <functional>
#include <iostream>
#include <memory>
#include <systemd/sd-bus.h>
#include "anbox/android/intent.h"
#include "anbox/wm/stack.h"
#include "anbox/cli.h"
namespace anbox::cmds {
class Launch : public cli::CommandWithFlagsAndAction {
public:
Launch();
private:
bool launch_session_manager();
bool launch_session_manager_dbus(sd_bus* bus);
android::Intent intent_;
wm::Stack::Id stack_ = wm::Stack::Id::Default;
bool use_system_dbus_ = false;
};
}
#endif
| 1,224
|
C++
|
.h
| 38
| 30.289474
| 76
| 0.752542
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,947
|
system_info.h
|
anbox_anbox/src/anbox/cmds/system_info.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_SYSTEM_INFO_H_
#define ANBOX_CMDS_SYSTEM_INFO_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
namespace anbox::cmds {
class SystemInfo : public cli::CommandWithFlagsAndAction {
public:
SystemInfo();
};
}
#endif
| 945
|
C++
|
.h
| 29
| 30.827586
| 78
| 0.764254
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,948
|
check_features.h
|
anbox_anbox/src/anbox/cmds/check_features.h
|
/*
* Copyright (C) 2018 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_CHECK_FEATURES_H_
#define ANBOX_CMDS_CHECK_FEATURES_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
namespace anbox::cmds {
class CheckFeatures : public cli::CommandWithFlagsAndAction {
public:
CheckFeatures();
private:
bool sanity_check_for_features();
};
}
#endif
| 1,008
|
C++
|
.h
| 31
| 30.677419
| 76
| 0.766461
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,949
|
install.h
|
anbox_anbox/src/anbox/cmds/install.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_INSTALL_H_
#define ANBOX_CMDS_INSTALL_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
namespace anbox::cmds {
class Install : public cli::CommandWithFlagsAndAction {
public:
Install();
private:
std::string apk_;
};
}
#endif
| 966
|
C++
|
.h
| 31
| 29.322581
| 76
| 0.760215
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,950
|
container_manager.h
|
anbox_anbox/src/anbox/cmds/container_manager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_CMDS_CONTAINER_MANAGER_H_
#define ANBOX_CMDS_CONTAINER_MANAGER_H_
#include <functional>
#include <iostream>
#include <memory>
#include "anbox/cli.h"
#include "anbox/common/loop_device.h"
#include "anbox/common/mount_entry.h"
namespace anbox::cmds {
class ContainerManager : public cli::CommandWithFlagsAndAction {
public:
ContainerManager();
~ContainerManager();
private:
bool setup_mounts();
bool setup_rootfs_overlay();
std::string android_img_path_;
std::string data_path_;
std::shared_ptr<common::LoopDevice> android_img_loop_dev_;
std::vector<std::shared_ptr<common::MountEntry>> mounts_;
bool privileged_ = false;
bool daemon_ = false;
bool enable_rootfs_overlay_ = false;
bool enable_squashfuse_ = false;
std::string container_network_address_;
std::string container_network_gateway_;
std::string container_network_dns_servers_;
};
}
#endif
| 1,575
|
C++
|
.h
| 46
| 32.065217
| 76
| 0.759527
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,951
|
client_info.h
|
anbox_anbox/src/anbox/audio/client_info.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_AUDIO_CLIENT_INFO_H_
#define ANBOX_AUDIO_CLIENT_INFO_H_
#include <cstdint>
namespace anbox::audio {
struct ClientInfo {
enum class Type : std::uint8_t {
Playback = 0,
Recording = 1,
Max = 2,
};
Type type;
};
}
#endif
| 926
|
C++
|
.h
| 30
| 28.666667
| 76
| 0.739082
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,952
|
sink.h
|
anbox_anbox/src/anbox/audio/sink.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_AUDIO_SINK_H_
#define ANBOX_AUDIO_SINK_H_
#include <cstdint>
#include <vector>
namespace anbox::audio {
class Sink {
public:
virtual ~Sink() {}
virtual void write_data(const std::vector<std::uint8_t> &data) = 0;
};
}
#endif
| 921
|
C++
|
.h
| 28
| 31.035714
| 76
| 0.749156
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,953
|
server.h
|
anbox_anbox/src/anbox/audio/server.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_AUDIO_SERVER_H_
#define ANBOX_AUDIO_SERVER_H_
#include "anbox/runtime.h"
#include "anbox/audio/client_info.h"
#include "anbox/network/socket_messenger.h"
#include "anbox/network/socket_connection.h"
#include "anbox/platform/base_platform.h"
#include <atomic>
namespace anbox::network {
class PublishedSocketConnector;
}
namespace anbox::audio {
class Server {
public:
Server(const std::shared_ptr<Runtime>& rt, const std::shared_ptr<platform::BasePlatform> &platform);
~Server();
std::string socket_file() const { return socket_file_; }
private:
void create_connection_for(std::shared_ptr<boost::asio::basic_stream_socket<
boost::asio::local::stream_protocol>> const& socket);
int next_id();
std::shared_ptr<platform::BasePlatform> platform_;
std::string socket_file_;
std::shared_ptr<network::PublishedSocketConnector> connector_;
std::shared_ptr<network::Connections<network::SocketConnection>> const connections_;
std::atomic<int> next_id_;
};
}
#endif
| 1,707
|
C++
|
.h
| 45
| 35.2
| 102
| 0.748941
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,954
|
source.h
|
anbox_anbox/src/anbox/audio/source.h
|
/*
* Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_AUDIO_SOURCE_H_
#define ANBOX_AUDIO_SOURCE_H_
#include <cstdint>
#include <vector>
namespace anbox::audio {
class Source {
public:
virtual ~Source() {}
virtual void read_data(std::vector<std::uint8_t> &data) = 0;
};
}
#endif
| 923
|
C++
|
.h
| 28
| 31.071429
| 76
| 0.750562
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,955
|
at_parser.h
|
anbox_anbox/src/anbox/qemu/at_parser.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_AT_PARSER_H_
#define ANBOX_QEMU_AT_PARSER_H_
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "anbox/do_not_copy_or_move.h"
namespace anbox::qemu {
class AtParser {
public:
typedef std::function<void(const std::string &)> CommandHandler;
AtParser();
void register_command(const std::string &command, CommandHandler handler);
void process_data(std::vector<std::uint8_t> &data);
private:
void processs_command(const std::string &command);
std::map<std::string, CommandHandler> handlers_;
};
}
#endif
| 1,265
|
C++
|
.h
| 37
| 32.162162
| 76
| 0.757178
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,956
|
bootanimation_message_processor.h
|
anbox_anbox/src/anbox/qemu/bootanimation_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_BOOT_ANIMATION_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_BOOT_ANIMATION_MESSAGE_PROCESSOR_H_
#include "anbox/qemu//qemud_message_processor.h"
namespace anbox {
namespace qemu {
class BootAnimationMessageProcessor : public QemudMessageProcessor {
public:
BootAnimationMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger,
const std::string &icon_path);
~BootAnimationMessageProcessor();
protected:
void handle_command(const std::string &command) override;
private:
void retrieve_icon();
std::string icon_path_;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,314
|
C++
|
.h
| 36
| 34.194444
| 76
| 0.771046
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,957
|
camera_message_processor.h
|
anbox_anbox/src/anbox/qemu/camera_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_CAMERA_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_CAMERA_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_messenger.h"
namespace anbox {
namespace qemu {
class CameraMessageProcessor : public network::MessageProcessor {
public:
CameraMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~CameraMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
private:
void process_commands();
void handle_command(const std::string &command);
void list();
std::shared_ptr<network::SocketMessenger> messenger_;
std::vector<std::uint8_t> buffer_;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,419
|
C++
|
.h
| 38
| 35.105263
| 76
| 0.766205
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,959
|
fingerprint_message_processor.h
|
anbox_anbox/src/anbox/qemu/fingerprint_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_FINGERPRINT_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_FINGERPRINT_MESSAGE_PROCESSOR_H_
#include "anbox/qemu/qemud_message_processor.h"
namespace anbox {
namespace qemu {
class FingerprintMessageProcessor : public QemudMessageProcessor {
public:
FingerprintMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~FingerprintMessageProcessor();
protected:
void handle_command(const std::string &command) override;
private:
void listen();
};
} // namespace graphics
} // namespace anbox
#endif
| 1,231
|
C++
|
.h
| 34
| 34.088235
| 76
| 0.776658
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,960
|
sensors_message_processor.h
|
anbox_anbox/src/anbox/qemu/sensors_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_SENSORS_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_SENSORS_MESSAGE_PROCESSOR_H_
#include <thread>
#include "anbox/application/sensors_state.h"
#include "anbox/qemu/qemud_message_processor.h"
namespace anbox::qemu {
class SensorsMessageProcessor : public QemudMessageProcessor {
public:
SensorsMessageProcessor(
std::shared_ptr<network::SocketMessenger> messenger, std::shared_ptr<application::SensorsState> sensorsState);
~SensorsMessageProcessor();
protected:
void handle_command(const std::string& command) override;
private:
void send_message(const std::string& message);
std::shared_ptr<application::SensorsState> sensors_state_;
std::atomic<int> delay_ = 200;
std::atomic<uint32_t> enabledSensors_;
std::atomic<bool> run_thread_ = true;
std::thread thread_;
};
}
#endif
| 1,498
|
C++
|
.h
| 39
| 36.179487
| 116
| 0.770819
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,961
|
telephony_manager.h
|
anbox_anbox/src/anbox/qemu/telephony_manager.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_TELEPHONY_MANAGER_H_
#define ANBOX_QEMU_TELEPHONY_MANAGER_H_
#include <core/dbus/bus.h>
#include <core/dbus/object.h>
#include <core/dbus/service.h>
namespace anbox::qemu {
class TelephonyManager {
public:
TelephonyManager(const core::dbus::Bus::Ptr &bus);
~TelephonyManager();
private:
core::dbus::Bus::Ptr bus_;
core::dbus::Service::Ptr ofono_;
core::dbus::Object::Ptr modem_;
};
}
#endif
| 1,100
|
C++
|
.h
| 33
| 31.393939
| 76
| 0.752587
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,962
|
boot_properties_message_processor.h
|
anbox_anbox/src/anbox/qemu/boot_properties_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_BOOT_PROPERTIES_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_BOOT_PROPERTIES_MESSAGE_PROCESSOR_H_
#include "anbox/qemu//qemud_message_processor.h"
namespace anbox {
namespace qemu {
class BootPropertiesMessageProcessor : public QemudMessageProcessor {
public:
BootPropertiesMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~BootPropertiesMessageProcessor();
protected:
void handle_command(const std::string &command) override;
private:
void list_properties();
};
} // namespace graphics
} // namespace anbox
#endif
| 1,258
|
C++
|
.h
| 34
| 34.882353
| 76
| 0.778325
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,963
|
adb_message_processor.h
|
anbox_anbox/src/anbox/qemu/adb_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_ADBD_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_ADBD_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_connection.h"
#include "anbox/network/socket_messenger.h"
#include "anbox/network/tcp_socket_connector.h"
#include "anbox/network/tcp_socket_messenger.h"
#include "anbox/runtime.h"
#include <boost/asio.hpp>
#include <mutex>
namespace anbox {
namespace qemu {
class AdbMessageProcessor : public network::MessageProcessor {
public:
AdbMessageProcessor(
const std::shared_ptr<Runtime> &rt,
const std::shared_ptr<network::SocketMessenger> &messenger);
~AdbMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
private:
enum State {
waiting_for_guest_accept_command,
waiting_for_host_connection,
waiting_for_guest_start_command,
proxying_data,
closed_by_container,
closed_by_host,
};
void advance_state();
void wait_for_host_connection();
void on_host_connection(std::shared_ptr<boost::asio::basic_stream_socket<
boost::asio::ip::tcp>> const &socket);
void read_next_host_message();
void on_host_read_size(const boost::system::error_code &error,
std::size_t bytes_read);
std::shared_ptr<Runtime> runtime_;
State state_ = waiting_for_guest_accept_command;
std::string expected_command_;
std::shared_ptr<network::SocketMessenger> const messenger_;
std::vector<std::uint8_t> buffer_;
std::shared_ptr<network::TcpSocketConnector> host_connector_;
std::shared_ptr<network::TcpSocketMessenger> host_messenger_;
std::array<std::uint8_t, 8192> host_buffer_;
std::unique_lock<std::mutex> lock_;
static std::mutex active_instance_;
};
} // namespace graphics
} // namespace anbox
#endif
| 2,492
|
C++
|
.h
| 65
| 34.876923
| 76
| 0.737474
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,964
|
qemud_message_processor.h
|
anbox_anbox/src/anbox/qemu/qemud_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_QEMUD_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_QEMUD_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_messenger.h"
namespace anbox {
namespace qemu {
class QemudMessageProcessor : public network::MessageProcessor {
public:
QemudMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~QemudMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
protected:
virtual void handle_command(const std::string &command) = 0;
void send_header(const size_t &size);
void finish_message();
std::shared_ptr<network::SocketMessenger> messenger_;
private:
bool process_commands();
std::vector<std::uint8_t> buffer_;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,490
|
C++
|
.h
| 40
| 34.95
| 76
| 0.764583
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,965
|
gps_message_processor.h
|
anbox_anbox/src/anbox/qemu/gps_message_processor.h
|
/*
* Copyright (C) 2020 Tomasz Grobelny <tomasz@grobelny.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_GPS_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_GPS_MESSAGE_PROCESSOR_H_
#include "anbox/application/gps_info_broker.h"
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_messenger.h"
namespace anbox::qemu {
class GpsMessageProcessor : public network::MessageProcessor {
public:
GpsMessageProcessor(const std::shared_ptr<network::SocketMessenger> &messenger, const std::shared_ptr<anbox::application::GpsInfoBroker> &gpsInfoBroker);
~GpsMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
private:
std::shared_ptr<network::SocketMessenger> messenger_;
std::shared_ptr<anbox::application::GpsInfoBroker> gps_info_broker_;
boost::signals2::connection connection_;
};
}
#endif
| 1,448
|
C++
|
.h
| 34
| 40.588235
| 155
| 0.778566
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,966
|
null_message_processor.h
|
anbox_anbox/src/anbox/qemu/null_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_NULL_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_NULL_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
namespace anbox {
namespace qemu {
class NullMessageProcessor : public network::MessageProcessor {
public:
NullMessageProcessor();
~NullMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,101
|
C++
|
.h
| 30
| 34.8
| 76
| 0.769231
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,967
|
gsm_message_processor.h
|
anbox_anbox/src/anbox/qemu/gsm_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_GSM_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_GSM_MESSAGE_PROCESSOR_H_
#include "anbox/network/message_processor.h"
#include "anbox/network/socket_messenger.h"
namespace anbox {
namespace qemu {
class AtParser;
class GsmMessageProcessor : public network::MessageProcessor {
public:
GsmMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~GsmMessageProcessor();
bool process_data(const std::vector<std::uint8_t> &data) override;
private:
enum class technology {
gsm = 0,
wcdm,
cdma,
evdo,
lte,
unknown,
};
void send_reply(const std::string &message);
void handle_ctec(const std::string &command);
void handle_cmgf(const std::string &command);
void handle_creg(const std::string &command);
void handle_cgreg(const std::string &command);
void handle_cfun(const std::string &command);
std::shared_ptr<network::SocketMessenger> messenger_;
std::vector<std::uint8_t> buffer_;
std::shared_ptr<AtParser> parser_;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,749
|
C++
|
.h
| 51
| 31.647059
| 76
| 0.749556
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,968
|
hwcontrol_message_processor.h
|
anbox_anbox/src/anbox/qemu/hwcontrol_message_processor.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_QEMU_HWCONTROL_MESSAGE_PROCESSOR_H_
#define ANBOX_QEMU_HWCONTROL_MESSAGE_PROCESSOR_H_
#include "anbox/qemu/qemud_message_processor.h"
namespace anbox {
namespace qemu {
class HwControlMessageProcessor : public QemudMessageProcessor {
public:
HwControlMessageProcessor(
const std::shared_ptr<network::SocketMessenger> &messenger);
~HwControlMessageProcessor();
protected:
void handle_command(const std::string &command) override;
};
} // namespace graphics
} // namespace anbox
#endif
| 1,193
|
C++
|
.h
| 32
| 35.21875
| 76
| 0.776817
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,969
|
gtest_utils.h
|
anbox_anbox/src/anbox/testing/gtest_utils.h
|
// Copyright 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "anbox/common/type_traits.h"
#include <gtest/gtest.h>
#include <iterator>
// Miscellenaous helper declarations for unit-tests using the GoogleTest
// framework.
namespace anbox::testing {
// RangesMatch is a useful template used to compare the content of two
// ranges at runtime. Usage is simply:
//
// EXPECT_TRUE(RangesMatch(range1, range2);
//
// Where |range1| and |range2| must have the same item type, and size.
template <typename Range1,
typename Range2,
typename = common::enable_if_c<common::is_range<Range1>::value &&
common::is_range<Range2>::value>>
inline ::testing::AssertionResult RangesMatch(const Range1& expected,
const Range2& actual) {
const auto expectedSize =
std::distance(std::begin(expected), std::end(expected));
const auto actualSize = std::distance(std::begin(actual), std::end(actual));
if (actualSize != expectedSize) {
return ::testing::AssertionFailure()
<< "actual range size " << actualSize << " != expected size "
<< expectedSize;
}
auto itExp = std::begin(expected);
for (const auto& act : actual) {
if (*itExp != act) {
const auto index = std::distance(std::begin(expected), itExp);
return ::testing::AssertionFailure()
<< "range[" << index << "] (" << act << ") != expected["
<< index << "] (" << *itExp << ")";
}
++itExp;
}
return ::testing::AssertionSuccess();
}
}
| 2,146
|
C++
|
.h
| 53
| 35.490566
| 78
| 0.663471
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,971
|
sdl_wrapper.h
|
anbox_anbox/src/anbox/platform/sdl/sdl_wrapper.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_PLATFORM_SDL_WRAPPER_H_
#define ANBOX_PLATFORM_SDL_WRAPPER_H_
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#include <SDL2/SDL.h>
#include <SDL2/SDL_audio.h>
#include <SDL2/SDL_syswm.h>
#include <SDL2/SDL_scancode.h>
#pragma GCC diagnostic pop
#endif
| 974
|
C++
|
.h
| 26
| 35.769231
| 76
| 0.769312
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
17,972
|
keycode_converter.h
|
anbox_anbox/src/anbox/platform/sdl/keycode_converter.h
|
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_
#define ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_
#include "anbox/platform/sdl/sdl_wrapper.h"
#include <cstdint>
#include <array>
namespace anbox::platform::sdl {
class KeycodeConverter {
public:
static std::uint16_t convert(const SDL_Scancode &scan_code);
private:
static const std::array<SDL_Scancode, 249> code_map;
};
}
#endif
| 1,063
|
C++
|
.h
| 30
| 33.533333
| 76
| 0.767283
|
anbox/anbox
| 8,865
| 1,152
| 381
|
GPL-3.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.