static int ubuntum(void *a) { /* Chroot */ chroot("/data/ubuntu"); chdir("/"); /* Set basic env variables */ char *const envp[8] = { "container=aal", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "SHELL=/bin/bash", "HOME=/root", "USER=root", "USERNAME=root", "LOGNAME=root", NULL }; /* Exec shell */ execle("/sbin/init", "/sbin/init", "--verbose", NULL, envp); return 0; }
bzr branch lp:platform-api bzr branch lp:qtubuntu
Package: libplatform-api1-hybris Depends: libhybris Description: Hybris implementation of the Platform API (runtime) This package provides the hybris implementation of the Platform API. The produced library should be used via libhybris, to communicate with the Android userspace, which is where the Ubuntu Application Manager lives.
LOCAL_SRC_FILES := \ ubuntu_application_api_for_hybris.cpp \ ubuntu_application_gps_for_hybris.cpp \ ubuntu_application_sensors_for_hybris.cpp \ ../default/default_ubuntu_application_sensor.cpp \ ../default/default_ubuntu_application_ui.cpp \ ../default/default_ubuntu_ui.cpp \ application_manager.cpp LOCAL_MODULE := libubuntu_application_api LOCAL_SHARED_LIBRARIES := \ libandroidfw \ libbinder \ libutils \ libgui \ libEGL \ libGLESv2 \ libhardware \ libhardware_legacy
extern void *android_dlopen(const char *filename, int flag); extern void *android_dlsym(void *handle, const char *symbol);
- using libhybris procedures for dynamically loading symbols from a shared-lib from android userspace. struct Bridge { static const char* path_to_library() { return "/system/lib/libubuntu_application_api.so"; } Bridge() : lib_handle(android_dlopen(path_to_library(), RTLD_LAZY)) { assert(lib_handle && "Error loading ubuntu_application_api"); } ....... void* resolve_symbol(const char* symbol) const { return android_dlsym(lib_handle, symbol); } void* lib_handle; };
- a simple bridge for loading symbols from libubuntu_application_api.so , which gets along with native android services, and which we have recently mentally βcollectedβ using android / hybris / Android.mk . #define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \ void symbol(arg1 _1, arg2 _2, arg3 _3) { \ static void (*f)(arg1, arg2, arg3) = NULL; \ DLSYM(&f, #symbol); \ f(_1, _2, _3); } ....... IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_init, int, char**); IMPLEMENT_FUNCTION0(StageHint, ubuntu_application_ui_setup_get_stage_hint); IMPLEMENT_FUNCTION0(FormFactorHint, ubuntu_application_ui_setup_get_form_factor_hint); IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_start_a_new_session, SessionCredentials*); IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_set_clipboard_content, void*, size_t); .......
- a bunch of wrappers for the API characters implemented in libubuntu_application_api.so . LOCAL_SRC_FILES:= \ application_manager.cpp \ default_application_manager.cpp \ LOCAL_MODULE:= ubuntuappmanager LOCAL_MODULE_TAGS := optional LOCAL_SHARED_LIBRARIES := \ libbinder \ libinput \ libgui \ libskia \ libandroidfw \ libutils \ libEGL \ libGLESv2 \ libubuntu_application_api
void update_app_lists(); void binderDied(const android::wp<android::IBinder>& who); void register_a_surface(...); void request_fullscreen(...); int get_session_pid(const android::sp<android::IApplicationManagerSession>& session); void focus_running_session_with_id(int id); void unfocus_running_sessions(); int32_t query_snapshot_layer_for_session_with_id(int id); android::IApplicationManagerSession::SurfaceProperties query_surface_properties_for_session_id(int id); void switch_focused_application_locked(size_t index_of_next_focused_app); void switch_focus_to_next_application_locked(); void kill_focused_application_locked(); void start_a_new_session( int32_t session_type, int32_t stage_hint, const android::String8& app_name, const android::String8& desktop_file, const android::sp<android::IApplicationManagerSession>& session, int fd);
~/ubuntu/qtubuntu $ tree . βββ qtubuntu.pro βββ src β βββ modules β β βββ application <------------------ QML plugin β β β βββ application.cc | Ubuntu Application Manager β β β βββ application.h | QtQuick β β β βββ application.pro | β β β βββ application_image.cc | β β β βββ application_image.h | β β β βββ application_list_model.cc | β β β βββ application_list_model.h | β β β βββ application_manager.cc | β β β βββ application_manager.h | β β β βββ application_window.cc | β β β βββ application_window.h | β β β βββ input_filter_area.cc | β β β βββ input_filter_area.h | β β β βββ logging.h | β β β βββ plugin.cc | β β β βββ qmldir | β β βββ ---------------------------------- β β βββ modules.pro β βββ platforms β β βββ base β β βββ platforms.pro β β βββ ubuntu <-------------- QPA β β βββ clipboard.cc β β βββ clipboard.h β β βββ input.cc β β βββ input.h β β βββ integration.cc <-- `createPlatformWindow` β β βββ integration.h β β βββ main.cc β β βββ screen.cc β β βββ screen.h β β βββ ubuntu.json β β βββ ubuntu.pro β β βββ window.cc β β βββ window.h β βββ src.pro βββ tests
#include <ubuntu/application/ui/ubuntu_application_ui.h> ubuntu_application_ui_start_a_new_session(&credentials); ubuntu_application_ui_destroy_surface(surface_); ubuntu_application_ui_create_surface(&surface_, "QUbuntuWindow", geometry.width(), geometry.height(), static_cast<SurfaceRole>(role), flags, eventCallback, this); ubuntu_application_ui_move_surface_to(surface_, geometry.x(), geometry.y()); ubuntu_application_ui_request_fullscreen_for_surface(surface_); ubuntu_application_ui_move_surface_to(surface_, rect.x(), rect.y()); ubuntu_application_ui_resize_surface_to(surface_, rect.width(), rect.height()); ubuntu_application_ui_request_fullscreen_for_surface(surface_); ubuntu_application_ui_show_surface(surface_); ubuntu_application_ui_hide_surface(surface_);
QPlatformWindow* QUbuntuIntegration::createPlatformWindow(QWindow* window) { ....... // Create the window. QPlatformWindow* platformWindow = new QUbuntuWindow(.......); ....... }
void QUbuntuWindow::createWindow() { ....... ubuntu_application_ui_create_surface( &surface_, "QUbuntuWindow", geometry.width(), geometry.height(), static_cast<SurfaceRole>(role), flags, eventCallback, this); ....... ubuntu_application_ui_move_surface_to(surface_, geometry.x(), geometry.y()); ....... }
// ubuntu_application_ui_create_surface ubuntu::application::ui::Surface::Ptr surface = session->create_surface(props, ubuntu::application::ui::input::Listener::Ptr(new CallbackEventListener(cb, ctx))); // ubuntu_application_ui_move_surface_to auto s = static_cast<Holder<ubuntu::application::ui::Surface::Ptr>*>(surface); s->value->move_to(x, y);
namespace android { ....... struct Session : public ubuntu::application::ui::Session, public UbuntuSurface::Observer { ....... Session(.....) { ...... ubuntu::application::ui::Surface::Ptr create_surface( const ubuntu::application::ui::SurfaceProperties& props, const ubuntu::application::ui::input::Listener::Ptr& listener) { ....... // , . UbuntuSurface UbuntuSurface* surface = new UbuntuSurface(client, client_channel, looper, props, listener,this); ....... // 100% , UbuntuSurface return ubuntu::application::ui::Surface::Ptr(surface); .......
struct UbuntuSurface : public ubuntu::application::ui::Surface { ....... UbuntuSurface(const sp<SurfaceComposerClient>& client, .......) : ubuntu::application::ui::Surface(listener) { // - Android API surface_control = client->createSurface( String8(props.title), props.width, props.height, PIXEL_FORMAT_RGBA_8888, props.flags & .......); surface = surface_control->getSurface(); .......
Source: https://habr.com/ru/post/180505/
All Articles