Custom Anbox installation files & patches, including patched Android OS image file.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
11 KiB

  1. --- a/src/anbox/application/database.cpp 2020-07-01 10:01:41.501731372 +0300
  2. +++ b/src/anbox/application/database.cpp 2020-07-01 15:26:15.991751825 +0300
  3. @@ -42,6 +42,10 @@ void Database::store_or_update(const Ite
  4. items_[item.package].icon.clear();
  5. }
  6. +std::string Database::set_icon(const Item &item) const {
  7. + return storage_->find_icon(item);
  8. +}
  9. +
  10. void Database::remove(const Item &item) {
  11. auto iter = items_.find(item.package);
  12. if (iter == items_.end())
  13. --- a/src/anbox/application/database.h 2020-07-01 10:01:46.011731377 +0300
  14. +++ b/src/anbox/application/database.h 2020-07-01 12:17:07.385073237 +0300
  15. @@ -48,6 +48,8 @@ class Database {
  16. const Item& find_by_package(const std::string &package) const;
  17. + std::string set_icon(const Item &item) const;
  18. +
  19. private:
  20. std::shared_ptr<LauncherStorage> storage_;
  21. std::map<std::string,Item> items_;
  22. --- a/src/anbox/application/launcher_storage.cpp 2020-07-01 10:13:25.078398779 +0300
  23. +++ b/src/anbox/application/launcher_storage.cpp 2020-07-01 14:49:15.495082807 +0300
  24. @@ -64,6 +64,14 @@ fs::path LauncherStorage::path_for_item_
  25. return path_ / utils::string_format("anbox-%s.png", package_name);
  26. }
  27. +std::string LauncherStorage::find_icon(const Database::Item &item) {
  28. + // TODO error handling
  29. + auto package_name = item.package;
  30. + std::replace(package_name.begin(), package_name.end(), '.', '-');
  31. + const auto item_icon_path = path_for_item_icon(package_name).string();
  32. + return item_icon_path;
  33. +}
  34. +
  35. void LauncherStorage::add_or_update(const Database::Item &item) {
  36. if (!fs::exists(path_)) fs::create_directories(path_);
  37. --- a/src/anbox/application/launcher_storage.h 2020-07-01 10:13:21.398398775 +0300
  38. +++ b/src/anbox/application/launcher_storage.h 2020-07-01 11:18:23.951736195 +0300
  39. @@ -38,11 +38,12 @@ class LauncherStorage {
  40. void add_or_update(const Database::Item &item);
  41. void remove(const Database::Item &item);
  42. + std::string find_icon(const Database::Item &item);
  43. +
  44. private:
  45. std::string clean_package_name(const std::string &package_name);
  46. boost::filesystem::path path_for_item(const std::string &package_name);
  47. boost::filesystem::path path_for_item_icon(const std::string &package_name);
  48. -
  49. boost::filesystem::path path_;
  50. };
  51. } // namespace application
  52. --- a/src/anbox/wm/window.cpp 2020-07-01 09:24:37.405062354 +0300
  53. +++ b/src/anbox/wm/window.cpp 2020-07-01 10:53:21.195067959 +0300
  54. @@ -21,8 +21,8 @@
  55. namespace anbox {
  56. namespace wm {
  57. -Window::Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title)
  58. - : renderer_(renderer), task_(task), frame_(frame), title_(title) {}
  59. +Window::Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title, const std::string &icon)
  60. + : renderer_(renderer), task_(task), frame_(frame), title_(title), icon_(icon) {}
  61. Window::~Window() {
  62. release();
  63. @@ -46,6 +46,8 @@ EGLNativeWindowType Window::native_handl
  64. std::string Window::title() const { return title_; }
  65. +std::string Window::icon() const { return icon_; }
  66. +
  67. bool Window::attach() {
  68. if (!renderer_)
  69. return false;
  70. --- a/src/anbox/wm/window.h 2020-07-01 09:24:40.605062358 +0300
  71. +++ b/src/anbox/wm/window.h 2020-07-01 10:36:49.868400246 +0300
  72. @@ -45,7 +45,7 @@ class Window {
  73. public:
  74. typedef std::vector<Window> List;
  75. - Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title);
  76. + Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title, const std::string &icon);
  77. virtual ~Window();
  78. bool attach();
  79. @@ -58,12 +58,14 @@ class Window {
  80. graphics::Rect frame() const;
  81. Task::Id task() const;
  82. std::string title() const;
  83. + std::string icon() const;
  84. private:
  85. std::shared_ptr<Renderer> renderer_;
  86. Task::Id task_;
  87. graphics::Rect frame_;
  88. std::string title_;
  89. + std::string icon_;
  90. bool attached_ = false;
  91. };
  92. } // namespace wm
  93. --- a/src/anbox/platform/sdl/window.cpp 2020-07-01 10:39:21.251733736 +0300
  94. +++ b/src/anbox/platform/sdl/window.cpp 2020-07-01 18:03:19.775094384 +0300
  95. @@ -20,6 +20,8 @@
  96. #include "anbox/graphics/density.h"
  97. #include "anbox/logger.h"
  98. +#include <SDL2/SDL_image.h>
  99. +
  100. #include <boost/throw_exception.hpp>
  101. #if defined(MIR_SUPPORT)
  102. @@ -46,9 +48,10 @@ Window::Window(const std::shared_ptr<Ren
  103. const std::shared_ptr<Observer> &observer,
  104. const graphics::Rect &frame,
  105. const std::string &title,
  106. + const std::string &icon,
  107. bool resizable,
  108. bool borderless)
  109. - : wm::Window(renderer, task, frame, title),
  110. + : wm::Window(renderer, task, frame, title, icon),
  111. id_(id),
  112. observer_(observer),
  113. native_display_(0),
  114. @@ -70,11 +73,18 @@ Window::Window(const std::shared_ptr<Ren
  115. frame.left(), frame.top(),
  116. frame.width(), frame.height(),
  117. flags);
  118. +
  119. if (!window_) {
  120. const auto message = utils::string_format("Failed to create window: %s", SDL_GetError());
  121. BOOST_THROW_EXCEPTION(std::runtime_error(message));
  122. }
  123. + icon_ = IMG_Load(icon.c_str());
  124. + if (icon_ != NULL) {
  125. + SDL_SetWindowIcon(window_, icon_);
  126. + SDL_FreeSurface(icon_);
  127. + }
  128. +
  129. // If we create a window with border (server-side decoration), We
  130. // should not set hit test handler beacuse we don't need to simulate
  131. // the behavior of the title bar and resize area.
  132. @@ -112,6 +122,7 @@ Window::Window(const std::shared_ptr<Ren
  133. }
  134. SDL_ShowWindow(window_);
  135. +
  136. }
  137. Window::~Window() {
  138. --- a/src/anbox/platform/sdl/window.h 2020-07-01 10:39:21.251733736 +0300
  139. +++ b/src/anbox/platform/sdl/window.h 2020-07-01 17:42:38.021759755 +0300
  140. @@ -53,6 +53,7 @@ class Window : public std::enable_shared
  141. const std::shared_ptr<Observer> &observer,
  142. const graphics::Rect &frame,
  143. const std::string &title,
  144. + const std::string &icon,
  145. bool resizable,
  146. bool borderless);
  147. ~Window();
  148. @@ -74,6 +75,7 @@ class Window : public std::enable_shared
  149. EGLNativeDisplayType native_display_;
  150. EGLNativeWindowType native_window_;
  151. SDL_Window *window_;
  152. + SDL_Surface *icon_;
  153. };
  154. } // namespace sdl
  155. } // namespace platform
  156. --- a/src/anbox/platform/sdl/platform.cpp 2020-07-01 11:58:53.388405411 +0300
  157. +++ b/src/anbox/platform/sdl/platform.cpp 2020-07-01 17:42:07.345093053 +0300
  158. @@ -411,14 +411,14 @@ Window::Id Platform::next_window_id() {
  159. }
  160. std::shared_ptr<wm::Window> Platform::create_window(
  161. - const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
  162. + const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) {
  163. if (!renderer_) {
  164. ERROR("Can't create window without a renderer set");
  165. return nullptr;
  166. }
  167. auto id = next_window_id();
  168. - auto w = std::make_shared<Window>(renderer_, id, task, shared_from_this(), frame, title,
  169. + auto w = std::make_shared<Window>(renderer_, id, task, shared_from_this(), frame, title, icon,
  170. !window_size_immutable_, !config_.server_side_decoration);
  171. focused_sdl_window_id_ = w->window_id();
  172. windows_.insert({id, w});
  173. --- a/src/anbox/platform/sdl/platform.h 2020-07-01 11:40:48.875070925 +0300
  174. +++ b/src/anbox/platform/sdl/platform.h 2020-07-01 17:42:20.438426402 +0300
  175. @@ -50,7 +50,8 @@ class Platform : public std::enable_shar
  176. std::shared_ptr<wm::Window> create_window(
  177. const anbox::wm::Task::Id &task,
  178. const anbox::graphics::Rect &frame,
  179. - const std::string &title) override;
  180. + const std::string &title,
  181. + const std::string &icon) override;
  182. void window_deleted(const Window::Id &id) override;
  183. void window_wants_focus(const Window::Id &id) override;
  184. --- a/src/anbox/platform/null/platform.cpp 2020-07-01 11:20:17.578402976 +0300
  185. +++ b/src/anbox/platform/null/platform.cpp 2020-07-01 11:23:09.188403157 +0300
  186. @@ -24,8 +24,10 @@ class NullWindow : public anbox::wm::Win
  187. public:
  188. NullWindow(const anbox::wm::Task::Id &task,
  189. const anbox::graphics::Rect &frame,
  190. - const std::string &title)
  191. - : anbox::wm::Window(nullptr, task, frame, title) {}
  192. + const std::string &title,
  193. + const std::string &icon
  194. + )
  195. + : anbox::wm::Window(nullptr, task, frame, title, icon) {}
  196. };
  197. }
  198. @@ -34,8 +36,8 @@ namespace platform {
  199. NullPlatform::NullPlatform() {}
  200. std::shared_ptr<wm::Window> NullPlatform::create_window(
  201. - const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
  202. - return std::make_shared<::NullWindow>(task, frame, title);
  203. + const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) {
  204. + return std::make_shared<::NullWindow>(task, frame, title, icon);
  205. }
  206. void NullPlatform::set_clipboard_data(const ClipboardData &data) {
  207. --- a/src/anbox/platform/null/platform.h 2020-07-01 11:24:27.591736574 +0300
  208. +++ b/src/anbox/platform/null/platform.h 2020-07-01 11:24:49.625069928 +0300
  209. @@ -28,7 +28,8 @@ class NullPlatform : public BasePlatform
  210. std::shared_ptr<wm::Window> create_window(
  211. const anbox::wm::Task::Id &task,
  212. const anbox::graphics::Rect &frame,
  213. - const std::string &title) override;
  214. + const std::string &title,
  215. + const std::string &icon) override;
  216. void set_clipboard_data(const ClipboardData &data) override;
  217. ClipboardData get_clipboard_data() override;
  218. std::shared_ptr<audio::Sink> create_audio_sink(const std::shared_ptr<network::LocalSocketMessenger> &messenger) override;
  219. --- a/src/anbox/platform/base_platform.h 2020-07-01 11:35:58.168403951 +0300
  220. +++ b/src/anbox/platform/base_platform.h 2020-07-01 11:36:17.055070636 +0300
  221. @@ -43,7 +43,7 @@ class BasePlatform {
  222. public:
  223. virtual ~BasePlatform() {}
  224. - virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0;
  225. + virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) = 0;
  226. struct ClipboardData {
  227. std::string text;
  228. --- a/src/anbox/wm/single_window_manager.cpp 2020-07-01 11:43:18.281737753 +0300
  229. +++ b/src/anbox/wm/single_window_manager.cpp 2020-07-01 11:43:31.661737769 +0300
  230. @@ -35,7 +35,7 @@ SingleWindowManager::~SingleWindowManage
  231. void SingleWindowManager::setup() {
  232. if (auto p = platform_.lock()) {
  233. - window_ = p->create_window(0, window_size_, "Anbox - Android in a Box");
  234. + window_ = p->create_window(0, window_size_, "Anbox - Android in a Box", "");
  235. if (!window_->attach())
  236. WARNING("Failed to attach window to renderer");
  237. } else {
  238. --- a/src/anbox/wm/multi_window_manager.cpp 2020-07-01 09:57:23.678397769 +0300
  239. +++ b/src/anbox/wm/multi_window_manager.cpp 2020-07-01 16:14:42.061754884 +0300
  240. @@ -64,11 +64,12 @@ void MultiWindowManager::apply_window_st
  241. auto title = window.package_name();
  242. auto app = app_db_->find_by_package(window.package_name());
  243. + auto icon = app_db_->set_icon(app);
  244. if (app.valid())
  245. title = app.name;
  246. if (auto p = platform_.lock()) {
  247. - auto w = p->create_window(window.task(), window.frame(), title);
  248. + auto w = p->create_window(window.task(), window.frame(), title, icon);
  249. if (w) {
  250. w->attach();
  251. windows_.insert({window.task(), w});