├── .gitignore ├── README.md ├── alienbinder8 ├── alienbinder8.pro └── src │ ├── activityinfo.cpp │ ├── activityinfo.h │ ├── activitymanager.cpp │ ├── activitymanager.h │ ├── alienbinder8.cpp │ ├── alienbinder8.h │ ├── alienservice.cpp │ ├── alienservice.h │ ├── applicationinfo.cpp │ ├── applicationinfo.h │ ├── appopsservice.cpp │ ├── appopsservice.h │ ├── binderinterfaceabstract.cpp │ ├── binderinterfaceabstract.h │ ├── binderlocalobject.cpp │ ├── binderlocalobject.h │ ├── binderlocalservice.cpp │ ├── binderlocalservice.h │ ├── bitset.h │ ├── componentinfo.cpp │ ├── componentinfo.h │ ├── errors.h │ ├── input.cpp │ ├── input.h │ ├── inputmanager.cpp │ ├── inputmanager.h │ ├── intent.cpp │ ├── intent.h │ ├── intentfilter.cpp │ ├── intentfilter.h │ ├── intentsender.cpp │ ├── intentsender.h │ ├── packageiteminfo.cpp │ ├── packageiteminfo.h │ ├── packagemanager.cpp │ ├── packagemanager.h │ ├── parcel.cpp │ ├── parcel.h │ ├── parcelable.cpp │ ├── parcelable.h │ ├── resolveinfo.cpp │ ├── resolveinfo.h │ ├── statusbarmanager.cpp │ ├── statusbarmanager.h │ ├── windowlayout.cpp │ ├── windowlayout.h │ ├── windowmanager.cpp │ └── windowmanager.h ├── alienchroot ├── alienchroot.pro └── src │ ├── alienchroot.cpp │ └── alienchroot.h ├── aliendalvik-control-selector.qml ├── aliendalvik-control.pro ├── common └── src │ ├── alienabstract.cpp │ ├── alienabstract.h │ ├── aliendalvikcontroller.cpp │ ├── aliendalvikcontroller.h │ ├── loggingclasswrapper.cpp │ ├── loggingclasswrapper.h │ ├── systemdcontroller.cpp │ └── systemdcontroller.h ├── daemon ├── daemon.pro ├── dbus │ ├── org.coderus.aliendalvikcontrol.conf │ └── org.coderus.aliendalvikcontrol.service ├── desktop │ ├── android-open-url-selector.desktop │ └── android-open-url.desktop ├── environment │ └── 10-debug.conf ├── settings │ ├── NavbarToggle.qml │ ├── aliendalvikcontrol.json │ └── main.qml ├── src │ ├── dbusservice.cpp │ ├── dbusservice.h │ ├── inotifywatcher.cpp │ ├── inotifywatcher.h │ └── main.cpp └── systemd │ └── aliendalvik-control.service ├── dbus └── org.coderus.aliendalvikcontrol.xml ├── edge ├── edge.pro ├── qml │ └── aliendalvik-control-edge.qml ├── src │ ├── main.cpp │ ├── nativewindowhelper.cpp │ └── nativewindowhelper.h └── systemd │ └── aliendalvik-control-edge.service ├── icons ├── icons.pro └── svgs │ ├── icon-m-aliendalvik-back4.svg │ ├── icon-m-aliendalvik-back8.svg │ ├── icon-m-aliendalvikcontrol.svg │ └── icon-m-share-aliendalvik.svg ├── proxy ├── dbus │ └── org.coderus.aliendalvikcontrol.service ├── proxy.pro └── src │ ├── adaptor.cpp │ ├── adaptor.h │ ├── handler.cpp │ ├── handler.h │ ├── main.cpp │ ├── service.cpp │ └── service.h ├── rpm └── aliendalvik-control.spec ├── selector ├── dbus │ └── org.coderus.aliendalvikselector.service ├── qml │ └── aliendalvik-control-selector.qml ├── selector.pro └── src │ └── main.cpp ├── share ├── dbus │ └── org.coderus.aliendalvikshare.service ├── qml │ ├── aliendalvik-control-share-cover.qml │ └── aliendalvik-control-share.qml ├── share.pro └── src │ └── main.cpp └── shareui ├── qml └── AliendalvikShare.qml ├── shareui.pro └── src ├── mediatransfer.cpp ├── mediatransfer.h ├── plugininfo.cpp ├── plugininfo.h ├── transferiface.cpp └── transferiface.h /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.moc 20 | moc_*.cpp 21 | qrc_*.cpp 22 | ui_*.h 23 | Makefile* 24 | *-build-* 25 | 26 | # QtCreator 27 | 28 | *.autosave 29 | 30 | #QtCtreator Qml 31 | *.qmlproject.user 32 | *.qmlproject.user.* 33 | 34 | *.apk 35 | 36 | *.png 37 | 38 | \.build*/ 39 | 40 | *.avi 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aliendalvik-control 2 | DBus daemon for controlling aliendalvik and sending commands 3 | -------------------------------------------------------------------------------- /alienbinder8/alienbinder8.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | QT = core dbus network 4 | CONFIG += plugin 5 | CONFIG += c++11 6 | CONFIG += link_pkgconfig 7 | PKGCONFIG += libgbinder 8 | 9 | HEADERS += \ 10 | ../common/src/alienabstract.h \ 11 | ../common/src/aliendalvikcontroller.h \ 12 | ../common/src/loggingclasswrapper.h \ 13 | ../common/src/systemdcontroller.h \ 14 | src/alienbinder8.h \ 15 | src/binderinterfaceabstract.h \ 16 | src/activitymanager.h \ 17 | src/packagemanager.h \ 18 | src/intent.h \ 19 | src/resolveinfo.h \ 20 | src/activityinfo.h \ 21 | src/componentinfo.h \ 22 | src/packageiteminfo.h \ 23 | src/applicationinfo.h \ 24 | src/statusbarmanager.h \ 25 | src/windowlayout.h \ 26 | src/intentfilter.h \ 27 | src/parcelable.h \ 28 | src/parcel.h \ 29 | src/appopsservice.h \ 30 | src/intentsender.h \ 31 | src/alienservice.h \ 32 | src/binderlocalobject.h \ 33 | src/binderlocalservice.h \ 34 | src/windowmanager.h \ 35 | src/inputmanager.h \ 36 | src/bitset.h \ 37 | src/input.h \ 38 | src/errors.h 39 | 40 | SOURCES += \ 41 | ../common/src/alienabstract.cpp \ 42 | ../common/src/aliendalvikcontroller.cpp \ 43 | ../common/src/loggingclasswrapper.cpp \ 44 | ../common/src/systemdcontroller.cpp \ 45 | src/alienbinder8.cpp \ 46 | src/binderinterfaceabstract.cpp \ 47 | src/activitymanager.cpp \ 48 | src/packagemanager.cpp \ 49 | src/intent.cpp \ 50 | src/resolveinfo.cpp \ 51 | src/activityinfo.cpp \ 52 | src/componentinfo.cpp \ 53 | src/packageiteminfo.cpp \ 54 | src/applicationinfo.cpp \ 55 | src/statusbarmanager.cpp \ 56 | src/windowlayout.cpp \ 57 | src/intentfilter.cpp \ 58 | src/parcelable.cpp \ 59 | src/parcel.cpp \ 60 | src/appopsservice.cpp \ 61 | src/intentsender.cpp \ 62 | src/alienservice.cpp \ 63 | src/binderlocalobject.cpp \ 64 | src/binderlocalservice.cpp \ 65 | src/windowmanager.cpp \ 66 | src/inputmanager.cpp \ 67 | src/input.cpp 68 | 69 | 70 | DEFINES += QT_DEPRECATED_WARNINGS 71 | DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII 72 | 73 | EXTRA_CFLAGS=-W -Wall -Wextra -Wpedantic -Werror 74 | QMAKE_CXXFLAGS += $$EXTRA_CFLAGS 75 | QMAKE_CFLAGS += $$EXTRA_CFLAGS 76 | 77 | TARGET = aliendalvikcontrolplugin-binder8 78 | target.path = /usr/lib 79 | 80 | INSTALLS = target 81 | -------------------------------------------------------------------------------- /alienbinder8/src/activityinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "activityinfo.h" 2 | #include "parcel.h" 3 | #include "windowlayout.h" 4 | 5 | ActivityInfo::ActivityInfo(Parcel *parcel, const char *loggingCategoryName) 6 | : ComponentInfo(parcel, loggingCategoryName) 7 | { 8 | theme = parcel->readInt(); 9 | qCDebug(logging) << Q_FUNC_INFO << "theme:" << theme; 10 | launchMode = parcel->readInt(); 11 | qCDebug(logging) << Q_FUNC_INFO << "launchMode:" << launchMode; 12 | documentLaunchMode = parcel->readInt(); 13 | qCDebug(logging) << Q_FUNC_INFO << "documentLaunchMode:" << documentLaunchMode; 14 | permission = parcel->readString(); 15 | qCDebug(logging) << Q_FUNC_INFO << "permission:" << permission; 16 | taskAffinity = parcel->readString(); 17 | qCDebug(logging) << Q_FUNC_INFO << "taskAffinity:" << taskAffinity; 18 | targetActivity = parcel->readString(); 19 | qCDebug(logging) << Q_FUNC_INFO << "targetActivity:" << targetActivity; 20 | flags = parcel->readInt(); 21 | qCDebug(logging) << Q_FUNC_INFO << "flags:" << flags; 22 | screenOrientation = parcel->readInt(); 23 | qCDebug(logging) << Q_FUNC_INFO << "screenOrientation:" << screenOrientation; 24 | configChanges = parcel->readInt(); 25 | qCDebug(logging) << Q_FUNC_INFO << "configChanges:" << configChanges; 26 | softInputMode = parcel->readInt(); 27 | qCDebug(logging) << Q_FUNC_INFO << "softInputMode:" << softInputMode; 28 | uiOptions = parcel->readInt(); 29 | qCDebug(logging) << Q_FUNC_INFO << "uiOptions:" << uiOptions; 30 | parentActivityName = parcel->readString(); 31 | qCDebug(logging) << Q_FUNC_INFO << "parentActivityName:" << parentActivityName; 32 | persistableMode = parcel->readInt(); 33 | qCDebug(logging) << Q_FUNC_INFO << "persistableMode:" << persistableMode; 34 | maxRecents = parcel->readInt(); 35 | qCDebug(logging) << Q_FUNC_INFO << "maxRecents:" << maxRecents; 36 | lockTaskLaunchMode = parcel->readInt(); 37 | qCDebug(logging) << Q_FUNC_INFO << "lockTaskLaunchMode:" << lockTaskLaunchMode; 38 | const int haveWindowLayout = parcel->readInt(); 39 | if (haveWindowLayout == 1) { 40 | qCDebug(logging) << Q_FUNC_INFO << "Have window layout!" << haveWindowLayout; 41 | windowLayout = new WindowLayout(parcel); 42 | } 43 | resizeMode = parcel->readInt(); 44 | qCDebug(logging) << Q_FUNC_INFO << "resizeMode:" << resizeMode; 45 | requestedVrComponent = parcel->readString(); 46 | qCDebug(logging) << Q_FUNC_INFO << "requestedVrComponent:" << requestedVrComponent; 47 | rotationAnimation = parcel->readInt(); 48 | qCDebug(logging) << Q_FUNC_INFO << "rotationAnimation:" << rotationAnimation; 49 | colorMode = parcel->readInt(); 50 | qCDebug(logging) << Q_FUNC_INFO << "colorMode:" << colorMode; 51 | maxAspectRatio = parcel->readFloat(); 52 | qCDebug(logging) << Q_FUNC_INFO << "maxAspectRatio:" << maxAspectRatio; 53 | } 54 | 55 | ActivityInfo::~ActivityInfo() 56 | { 57 | if (windowLayout) { 58 | delete windowLayout; 59 | windowLayout = nullptr; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /alienbinder8/src/activityinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIVITYINFO_H 2 | #define ACTIVITYINFO_H 3 | 4 | #include "componentinfo.h" 5 | 6 | 7 | class Parcel; 8 | class WindowLayout; 9 | class ActivityInfo : public ComponentInfo 10 | { 11 | public: 12 | ActivityInfo(Parcel *parcel, const char *loggingCategoryName = LOGGING(ActivityInfo)".parcel"); 13 | virtual ~ActivityInfo(); 14 | 15 | int theme = -1; 16 | int launchMode = -1; 17 | int documentLaunchMode = -1; 18 | QString permission; 19 | QString taskAffinity; 20 | QString targetActivity; 21 | int flags = -1; 22 | int screenOrientation = -1; 23 | int configChanges = -1; 24 | int softInputMode = -1; 25 | int uiOptions = -1; 26 | QString parentActivityName; 27 | int persistableMode = -1; 28 | int maxRecents = -1; 29 | int lockTaskLaunchMode = -1; 30 | WindowLayout *windowLayout = nullptr; 31 | int resizeMode = -1; 32 | QString requestedVrComponent; 33 | int rotationAnimation = -1; 34 | int colorMode = -1; 35 | float maxAspectRatio = -1; 36 | }; 37 | 38 | #endif // ACTIVITYINFO_H 39 | -------------------------------------------------------------------------------- /alienbinder8/src/activitymanager.cpp: -------------------------------------------------------------------------------- 1 | #include "activitymanager.h" 2 | #include "intent.h" 3 | #include "parcel.h" 4 | 5 | #include 6 | #include 7 | 8 | #define AM_SERVICE_NAME "activity" 9 | #define AM_INTERFACE_NAME "android.app.IActivityManager" 10 | 11 | static ActivityManager *s_instance = nullptr; 12 | 13 | ActivityManager::ActivityManager(QObject *parent, const char *loggingCategoryName) 14 | : BinderInterfaceAbstract(AM_SERVICE_NAME, 15 | AM_INTERFACE_NAME, 16 | parent, 17 | loggingCategoryName) 18 | { 19 | } 20 | 21 | ActivityManager::~ActivityManager() 22 | { 23 | if (s_instance == this) { 24 | s_instance = nullptr; 25 | } 26 | } 27 | 28 | ActivityManager *ActivityManager::GetInstance() 29 | { 30 | if (!s_instance) { 31 | s_instance = new ActivityManager(qApp); 32 | } 33 | return s_instance; 34 | } 35 | 36 | void ActivityManager::startActivity(Intent intent) 37 | { 38 | ActivityManager *manager = ActivityManager::GetInstance(); 39 | qCDebug(manager->logging) << Q_FUNC_INFO << intent.action; 40 | 41 | QSharedPointer parcel = manager->createTransaction(); 42 | if (!parcel) { 43 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 44 | return; 45 | } 46 | 47 | parcel->writeStrongBinder(static_cast(NULL)); // IBinder b; ApplicationThreadNative.asInterface(b); 48 | parcel->writeString(QString()); // callingPackage 49 | parcel->writeInt(1); // const value 50 | intent.writeToParcel(parcel.data()); 51 | parcel->writeString(QString()); // resolvedType 52 | parcel->writeStrongBinder(static_cast(NULL)); // resultTo 53 | parcel->writeString(QString()); // resultWho 54 | parcel->writeInt(0); // requestCode 55 | parcel->writeInt(0); // startFlags 56 | parcel->writeInt(0); // profilerInfo disable 57 | parcel->writeInt(0); // options disable 58 | int status = 0; 59 | manager->sendTransaction(TRANSACTION_startActivity, parcel, &status); 60 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 61 | } 62 | 63 | void ActivityManager::forceStopPackage(const QString &package) 64 | { 65 | ActivityManager *manager = ActivityManager::GetInstance(); 66 | qCDebug(manager->logging) << Q_FUNC_INFO << package; 67 | 68 | QSharedPointer parcel = manager->createTransaction(); 69 | if (!parcel) { 70 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 71 | return; 72 | } 73 | 74 | parcel->writeString(package); 75 | parcel->writeInt(USER_OWNER); 76 | int status = 0; 77 | manager->sendTransaction(TRANSACTION_forceStopPackage, parcel, &status); 78 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 79 | } 80 | -------------------------------------------------------------------------------- /alienbinder8/src/activitymanager.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIVITYMANAGER_H 2 | #define ACTIVITYMANAGER_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | 6 | #include 7 | 8 | enum { 9 | TRANSACTION_startActivity = 3, 10 | TRANSACTION_registerReceiver = 6, 11 | TRANSACTION_forceStopPackage = 72, 12 | }; 13 | 14 | class Intent; 15 | class ActivityManager : public BinderInterfaceAbstract 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit ActivityManager(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(ActivityManager)".manager"); 20 | virtual ~ActivityManager(); 21 | 22 | static ActivityManager *GetInstance(); 23 | 24 | static void startActivity(Intent intent); 25 | static void forceStopPackage(const QString &package); 26 | }; 27 | 28 | #endif // ACTIVITYMANAGER_H 29 | -------------------------------------------------------------------------------- /alienbinder8/src/alienbinder8.h: -------------------------------------------------------------------------------- 1 | #ifndef ALIENCHROOT_H 2 | #define ALIENCHROOT_H 3 | 4 | #include "../common/src/alienabstract.h" 5 | 6 | #include 7 | 8 | class AlienBinder8 : public AlienAbstract 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit AlienBinder8(QObject *parent = nullptr); 13 | 14 | public slots: 15 | QString dataPath() const override; 16 | 17 | void sendKeyevent(int code, quint64 uptime) override; 18 | void sendInput(const QString &) override; 19 | void sendTap(int posx, int posy, quint64 uptime) override; 20 | void sendSwipe(int startx, int starty, int endx, int endy, int duration) override; 21 | void uriActivity(const QString &uri) override; 22 | void uriActivitySelector(const QString &uri) override; 23 | void hideNavBar(int height, int) override; 24 | void showNavBar(int) override; 25 | void hideStatusBar() override; 26 | void showStatusBar() override; 27 | void openDownloads() override; 28 | void openSettings() override; 29 | void openContacts() override; 30 | void openCamera() override; 31 | void openGallery() override; 32 | void openAppSettings(const QString &packageName) override; 33 | void launchApp(const QString &packageName) override; 34 | void componentActivity(const QString &package, const QString &className, const QString &data) override; 35 | void forceStop(const QString &packageName) override; 36 | void shareFile(const QString &filename, const QString &mimetype) override; 37 | void shareText(const QString &text) override; 38 | void doShare(const QString &mimetype, const QString &filename, const QString &data, const QString &packageName, const QString &className, const QString &launcherClass) override; 39 | QVariantList getImeList() override; 40 | void triggerImeMethod(const QString &ime, bool enable) override; 41 | void setImeMethod(const QString &ime) override; 42 | QString getSettings(const QString &nspace, const QString &key) override; 43 | void putSettings(const QString &nspace, const QString &key, const QString &value) override; 44 | QString getprop(const QString &key) override; 45 | void setprop(const QString &key, const QString &value) override; 46 | 47 | void requestDeviceInfo() override; 48 | void requestUptime() override; 49 | 50 | QString checkShareFile(const QString &shareFilePath) override; 51 | 52 | void installApk(const QString &fileName) override; 53 | 54 | private: 55 | void requestUptimePayload(const QVariantMap &payload); 56 | 57 | private slots: 58 | void serviceStopped() override; 59 | void serviceStarted() override; 60 | }; 61 | 62 | #endif // ALIENCHROOT_H 63 | -------------------------------------------------------------------------------- /alienbinder8/src/alienservice.cpp: -------------------------------------------------------------------------------- 1 | #include "alienservice.h" 2 | #include "parcel.h" 3 | 4 | #include 5 | 6 | #define PM_SERVICE_NAME "alien" 7 | #define PM_INTERFACE_NAME "alien.applications.IAlienService" 8 | 9 | static AlienService *s_instance = nullptr; 10 | 11 | AlienService::AlienService(QObject *parent, const char *loggingCategoryName) 12 | : BinderInterfaceAbstract(PM_SERVICE_NAME, 13 | PM_INTERFACE_NAME, 14 | parent, 15 | loggingCategoryName) 16 | { 17 | 18 | } 19 | 20 | AlienService::~AlienService() 21 | { 22 | s_instance = nullptr; 23 | } 24 | 25 | AlienService *AlienService::GetInstance() 26 | { 27 | if (!s_instance) { 28 | s_instance = new AlienService(qApp); 29 | } 30 | return s_instance; 31 | } 32 | 33 | QString AlienService::getPrettyName(int uid) 34 | { 35 | QString prettyName; 36 | 37 | AlienService *service = AlienService::GetInstance(); 38 | qCDebug(service->logging) << Q_FUNC_INFO << uid; 39 | 40 | QSharedPointer parcel = service->createTransaction(); 41 | if (!parcel) { 42 | qCCritical(service->logging) << Q_FUNC_INFO << "Null Parcel!"; 43 | return prettyName; 44 | } 45 | 46 | parcel->writeInt(uid); 47 | int status = 0; 48 | QSharedPointer out = service->sendTransaction(TRANSACTION_getPrettyName, parcel, &status); 49 | qCDebug(service->logging) << Q_FUNC_INFO << "Status:" << status; 50 | const int exception = out->readInt(); 51 | if (exception != 0) { 52 | qCCritical(service->logging) << Q_FUNC_INFO << "Exception:" << exception; 53 | return prettyName; 54 | } 55 | prettyName = out->readString(); 56 | qCDebug(service->logging) << Q_FUNC_INFO << "Result:" << prettyName; 57 | 58 | return prettyName; 59 | } 60 | 61 | void AlienService::startApp(const QString &packageName) 62 | { 63 | AlienService *service = AlienService::GetInstance(); 64 | qCDebug(service->logging) << Q_FUNC_INFO << packageName; 65 | 66 | QSharedPointer parcel = service->createTransaction(); 67 | if (!parcel) { 68 | qCCritical(service->logging) << Q_FUNC_INFO << "Null Parcel!"; 69 | return; 70 | } 71 | 72 | parcel->writeString(packageName); 73 | int status = 0; 74 | service->sendTransaction(TRANSACTION_startApp, parcel, &status); 75 | qCDebug(service->logging) << Q_FUNC_INFO << "Status:" << status; 76 | } 77 | -------------------------------------------------------------------------------- /alienbinder8/src/alienservice.h: -------------------------------------------------------------------------------- 1 | #ifndef ALIENSERVICE_H 2 | #define ALIENSERVICE_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | enum { 10 | TRANSACTION_startApp = 1, 11 | TRANSACTION_getPrettyName = 7, 12 | }; 13 | 14 | class AlienService : public BinderInterfaceAbstract 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit AlienService(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(AlienService)".manager"); 19 | virtual ~AlienService(); 20 | 21 | static AlienService *GetInstance(); 22 | 23 | static QString getPrettyName(int uid); 24 | static void startApp(const QString &packageName); 25 | }; 26 | 27 | #endif // ALIENSERVICE_H 28 | -------------------------------------------------------------------------------- /alienbinder8/src/applicationinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "applicationinfo.h" 2 | #include "parcel.h" 3 | 4 | ApplicationInfo::ApplicationInfo(Parcel *parcel, const char *loggingCategoryName) 5 | : PackageItemInfo(parcel, loggingCategoryName) 6 | { 7 | taskAffinity = parcel->readString(); 8 | qCDebug(logging) << Q_FUNC_INFO << "taskAffinity" << taskAffinity; 9 | permission = parcel->readString(); 10 | qCDebug(logging) << Q_FUNC_INFO << "permission" << permission; 11 | processName = parcel->readString(); 12 | qCDebug(logging) << Q_FUNC_INFO << "processName" << processName; 13 | className = parcel->readString(); 14 | qCDebug(logging) << Q_FUNC_INFO << "className" << className; 15 | theme = parcel->readInt(); 16 | qCDebug(logging) << Q_FUNC_INFO << "theme" << theme; 17 | flags = parcel->readInt(); 18 | qCDebug(logging) << Q_FUNC_INFO << "flags" << flags; 19 | privateFlags = parcel->readInt(); 20 | qCDebug(logging) << Q_FUNC_INFO << "privateFlags" << privateFlags; 21 | requiresSmallestWidthDp = parcel->readInt(); 22 | qCDebug(logging) << Q_FUNC_INFO << "requiresSmallestWidthDp" << requiresSmallestWidthDp; 23 | compatibleWidthLimitDp = parcel->readInt(); 24 | qCDebug(logging) << Q_FUNC_INFO << "compatibleWidthLimitDp" << compatibleWidthLimitDp; 25 | largestWidthLimitDp = parcel->readInt(); 26 | qCDebug(logging) << Q_FUNC_INFO << "largestWidthLimitDp" << largestWidthLimitDp; 27 | 28 | const int haveUuidInfo = parcel->readInt(); 29 | if (haveUuidInfo != 0) { 30 | qCDebug(logging) << Q_FUNC_INFO << "Have UUID INFO!" << haveUuidInfo 31 | << parcel->readLong() << parcel->readLong(); 32 | 33 | // storageUuid = new UUID(parcel->readLong(), parcel->readLong()); 34 | // volumeUuid = StorageManager.convert(storageUuid); 35 | } 36 | scanSourceDir = parcel->readString(); 37 | qCDebug(logging) << Q_FUNC_INFO << "scanSourceDir" << scanSourceDir; 38 | scanPublicSourceDir = parcel->readString(); 39 | qCDebug(logging) << Q_FUNC_INFO << "scanPublicSourceDir" << scanPublicSourceDir; 40 | sourceDir = parcel->readString(); 41 | qCDebug(logging) << Q_FUNC_INFO << "sourceDir" << sourceDir; 42 | publicSourceDir = parcel->readString(); 43 | qCDebug(logging) << Q_FUNC_INFO << "publicSourceDir" << publicSourceDir; 44 | splitNames = parcel->readStringList(); 45 | qCDebug(logging) << Q_FUNC_INFO << "splitNames" << splitNames; 46 | splitSourceDirs = parcel->readStringList(); 47 | qCDebug(logging) << Q_FUNC_INFO << "splitSourceDirs" << splitSourceDirs; 48 | splitPublicSourceDirs = parcel->readStringList(); 49 | qCDebug(logging) << Q_FUNC_INFO << "splitPublicSourceDirs" << splitPublicSourceDirs; 50 | splitDependencies = parcel->readSparseArray(); 51 | qCDebug(logging) << Q_FUNC_INFO << "splitDependencies" << splitDependencies; 52 | nativeLibraryDir = parcel->readString(); 53 | qCDebug(logging) << Q_FUNC_INFO << "nativeLibraryDir" << nativeLibraryDir; 54 | secondaryNativeLibraryDir = parcel->readString(); 55 | qCDebug(logging) << Q_FUNC_INFO << "secondaryNativeLibraryDir" << secondaryNativeLibraryDir; 56 | nativeLibraryRootDir = parcel->readString(); 57 | qCDebug(logging) << Q_FUNC_INFO << "nativeLibraryRootDir" << nativeLibraryRootDir; 58 | const int i_nativeLibraryRootRequiresIsa = parcel->readInt(); 59 | qCDebug(logging) << Q_FUNC_INFO << "i_nativeLibraryRootRequiresIsa" << i_nativeLibraryRootRequiresIsa; 60 | if (i_nativeLibraryRootRequiresIsa != 0) { 61 | nativeLibraryRootRequiresIsa = enabled; 62 | 63 | primaryCpuAbi = parcel->readString(); 64 | qCDebug(logging) << Q_FUNC_INFO << "primaryCpuAbi" << primaryCpuAbi; 65 | secondaryCpuAbi = parcel->readString(); 66 | qCDebug(logging) << Q_FUNC_INFO << "secondaryCpuAbi" << secondaryCpuAbi; 67 | resourceDirs = parcel->readStringList(); 68 | qCDebug(logging) << Q_FUNC_INFO << "resourceDirs" << resourceDirs; 69 | seInfo = parcel->readString(); 70 | qCDebug(logging) << Q_FUNC_INFO << "seInfo" << seInfo; 71 | seInfoUser = parcel->readString(); 72 | qCDebug(logging) << Q_FUNC_INFO << "seInfoUser" << seInfoUser; 73 | sharedLibraryFiles = parcel->readStringList(); 74 | qCDebug(logging) << Q_FUNC_INFO << "sharedLibraryFiles" << sharedLibraryFiles; 75 | dataDir = parcel->readString(); 76 | qCDebug(logging) << Q_FUNC_INFO << "dataDir" << dataDir; 77 | deviceProtectedDataDir = parcel->readString(); 78 | qCDebug(logging) << Q_FUNC_INFO << "deviceProtectedDataDir" << deviceProtectedDataDir; 79 | credentialProtectedDataDir = parcel->readString(); 80 | qCDebug(logging) << Q_FUNC_INFO << "credentialProtectedDataDir" << credentialProtectedDataDir; 81 | uid = parcel->readInt(); 82 | qCDebug(logging) << Q_FUNC_INFO << "uid" << uid; 83 | minSdkVersion = parcel->readInt(); 84 | qCDebug(logging) << Q_FUNC_INFO << "minSdkVersion" << minSdkVersion; 85 | targetSdkVersion = parcel->readInt(); 86 | qCDebug(logging) << Q_FUNC_INFO << "targetSdkVersion" << targetSdkVersion; 87 | versionCode = parcel->readInt(); 88 | qCDebug(logging) << Q_FUNC_INFO << "versionCode" << versionCode; 89 | const int finita = parcel->readInt(); 90 | qCDebug(logging) << Q_FUNC_INFO << "finita" << finita; 91 | if (finita == 0) { 92 | return; 93 | } 94 | } 95 | 96 | // enabled = parcel->readBoolean(); 97 | enabled = true; 98 | qCDebug(logging) << Q_FUNC_INFO << "enabled" << enabled; 99 | enabledSetting = parcel->readInt(); 100 | qCDebug(logging) << Q_FUNC_INFO << "enabledSetting" << enabledSetting; 101 | installLocation = parcel->readInt(); 102 | qCDebug(logging) << Q_FUNC_INFO << "installLocation" << installLocation; 103 | manageSpaceActivityName = parcel->readString(); 104 | qCDebug(logging) << Q_FUNC_INFO << "manageSpaceActivityName" << manageSpaceActivityName; 105 | backupAgentName = parcel->readString(); 106 | qCDebug(logging) << Q_FUNC_INFO << "backupAgentName" << backupAgentName; 107 | descriptionRes = parcel->readInt(); 108 | qCDebug(logging) << Q_FUNC_INFO << "descriptionRes" << descriptionRes; 109 | uiOptions = parcel->readInt(); 110 | qCDebug(logging) << Q_FUNC_INFO << "uiOptions" << uiOptions; 111 | fullBackupContent = parcel->readInt(); 112 | qCDebug(logging) << Q_FUNC_INFO << "fullBackupContent" << fullBackupContent; 113 | networkSecurityConfigRes = parcel->readInt(); 114 | qCDebug(logging) << Q_FUNC_INFO << "networkSecurityConfigRes" << networkSecurityConfigRes; 115 | category = parcel->readInt(); 116 | qCDebug(logging) << Q_FUNC_INFO << "category" << category; 117 | targetSandboxVersion = parcel->readInt(); 118 | qCDebug(logging) << Q_FUNC_INFO << "targetSandboxVersion" << targetSandboxVersion; 119 | 120 | classLoaderName = parcel->readString(); 121 | qCDebug(logging) << Q_FUNC_INFO << "classLoaderName" << classLoaderName; 122 | 123 | splitClassLoaderNames = parcel->readStringList(); 124 | qCDebug(logging) << Q_FUNC_INFO << "splitClassLoaderNames" << splitClassLoaderNames; 125 | } 126 | -------------------------------------------------------------------------------- /alienbinder8/src/applicationinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef APPLICATIONINFO_H 2 | #define APPLICATIONINFO_H 3 | 4 | #include "packageiteminfo.h" 5 | 6 | #include 7 | #include 8 | 9 | class Parcel; 10 | class ApplicationInfo : public PackageItemInfo 11 | { 12 | public: 13 | ApplicationInfo(Parcel *parcel, const char *loggingCategoryName = LOGGING(ApplicationInfo)".parcel"); 14 | 15 | QString taskAffinity; 16 | QString permission; 17 | QString processName; 18 | QString className; 19 | int theme = -1; 20 | int flags = -1; 21 | int privateFlags = -1; 22 | int requiresSmallestWidthDp = -1; 23 | int compatibleWidthLimitDp = -1; 24 | int largestWidthLimitDp = -1; 25 | 26 | // if (source.readInt() != 0) { 27 | // storageUuid = new UUID(source.readLong(), source.readLong()); 28 | // volumeUuid = StorageManager.convert(storageUuid); 29 | // } 30 | 31 | QString scanSourceDir; 32 | QString scanPublicSourceDir; 33 | QString sourceDir; 34 | QString publicSourceDir; 35 | QStringList splitNames; 36 | QStringList splitSourceDirs; 37 | QStringList splitPublicSourceDirs; 38 | QHash splitDependencies; 39 | QString nativeLibraryDir; 40 | QString secondaryNativeLibraryDir; 41 | QString nativeLibraryRootDir; 42 | bool nativeLibraryRootRequiresIsa; 43 | QString primaryCpuAbi; 44 | QString secondaryCpuAbi; 45 | QStringList resourceDirs; 46 | QString seInfo; 47 | QString seInfoUser; 48 | QStringList sharedLibraryFiles; 49 | QString dataDir; 50 | QString deviceProtectedDataDir; 51 | QString credentialProtectedDataDir; 52 | int uid = -1; 53 | int minSdkVersion = -1; 54 | int targetSdkVersion = -1; 55 | int versionCode = -1; 56 | bool enabled = false; 57 | int enabledSetting = -1; 58 | int installLocation = -1; 59 | QString manageSpaceActivityName; 60 | QString backupAgentName; 61 | int descriptionRes = -1; 62 | int uiOptions = -1; 63 | int fullBackupContent = -1; 64 | int networkSecurityConfigRes = -1; 65 | int category = -1; 66 | int targetSandboxVersion = -1; 67 | QString classLoaderName; 68 | QStringList splitClassLoaderNames; 69 | }; 70 | 71 | #endif // APPLICATIONINFO_H 72 | -------------------------------------------------------------------------------- /alienbinder8/src/appopsservice.cpp: -------------------------------------------------------------------------------- 1 | #include "appopsservice.h" 2 | #include "parcel.h" 3 | 4 | #include 5 | 6 | #define AO_SERVICE_NAME "appops" 7 | #define AO_INTERFACE_NAME "com.android.internal.app.IAppOpsService" 8 | 9 | static AppOpsService *s_instance = nullptr; 10 | 11 | AppOpsService::AppOpsService(QObject *parent, const char *loggingCategoryName) 12 | : BinderInterfaceAbstract(AO_SERVICE_NAME, 13 | AO_INTERFACE_NAME, 14 | parent, 15 | loggingCategoryName) 16 | { 17 | } 18 | 19 | AppOpsService::~AppOpsService() 20 | { 21 | s_instance = nullptr; 22 | } 23 | 24 | AppOpsService *AppOpsService::GetInstance() 25 | { 26 | if (!s_instance) { 27 | s_instance = new AppOpsService(qApp); 28 | } 29 | return s_instance; 30 | } 31 | 32 | GBinderRemoteObject *AppOpsService::getToken(GBinderLocalObject *clientToken) 33 | { 34 | GBinderRemoteObject *result = nullptr; 35 | 36 | AppOpsService *service = AppOpsService::GetInstance(); 37 | qCDebug(service->logging) << Q_FUNC_INFO << clientToken; 38 | 39 | QSharedPointer parcel = service->createTransaction(); 40 | if (!parcel) { 41 | qCCritical(service->logging) << Q_FUNC_INFO << "Null Parcel!"; 42 | return result; 43 | } 44 | 45 | parcel->writeStrongBinder(clientToken); 46 | 47 | int status = 0; 48 | QSharedPointer in = service->sendTransaction(TRANSACTION_getToken, parcel, &status); 49 | qCDebug(service->logging) << Q_FUNC_INFO << "Status:" << status; 50 | const int exception = in->readInt(); 51 | qCDebug(service->logging) << Q_FUNC_INFO << "Exception:" << exception; 52 | if (exception != 0) { 53 | return result; 54 | } 55 | result = in->readStrongBinder(); 56 | 57 | return result; 58 | } 59 | -------------------------------------------------------------------------------- /alienbinder8/src/appopsservice.h: -------------------------------------------------------------------------------- 1 | #ifndef APPOPSSERVICE_H 2 | #define APPOPSSERVICE_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | 6 | enum { 7 | TRANSACTION_getToken = 7, 8 | }; 9 | 10 | class AppOpsService : public BinderInterfaceAbstract 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit AppOpsService(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(AppOpsService)".manager"); 15 | virtual ~AppOpsService(); 16 | 17 | static AppOpsService *GetInstance(); 18 | 19 | static GBinderRemoteObject *getToken(GBinderLocalObject *clientToken = nullptr); 20 | }; 21 | 22 | #endif // APPOPSSERVICE_H 23 | -------------------------------------------------------------------------------- /alienbinder8/src/binderinterfaceabstract.cpp: -------------------------------------------------------------------------------- 1 | #include "binderinterfaceabstract.h" 2 | #include "intent.h" 3 | #include "parcel.h" 4 | #include "parcelable.h" 5 | 6 | #include 7 | #include 8 | 9 | void BinderInterfaceAbstract::registrationHandler(GBinderServiceManager *sm, const char *name, void *user_data) 10 | { 11 | BinderInterfaceAbstract* instance = static_cast(user_data); 12 | qCDebug(instance->logging) << Q_FUNC_INFO << "Service registered" << sm << name << user_data; 13 | instance->registerManager(); 14 | } 15 | 16 | void BinderInterfaceAbstract::deathHandler(GBinderRemoteObject *obj, void *user_data) 17 | { 18 | BinderInterfaceAbstract* instance = static_cast(user_data); 19 | qCWarning(instance->logging) << Q_FUNC_INFO << "Binder died" << obj << user_data; 20 | instance->binderDisconnect(); 21 | } 22 | 23 | BinderInterfaceAbstract::BinderInterfaceAbstract(const char *serviceName, 24 | const char *interfaceName, 25 | QObject *parent, 26 | const char *loggingCategoryName) 27 | : AliendalvikController(parent) 28 | , LoggingClassWrapper(loggingCategoryName) 29 | , m_serviceName(serviceName) 30 | , m_interfaceName(interfaceName) 31 | { 32 | } 33 | 34 | BinderInterfaceAbstract::~BinderInterfaceAbstract() 35 | { 36 | binderDisconnect(); 37 | } 38 | 39 | bool BinderInterfaceAbstract::isBinderReady() const 40 | { 41 | return m_client; 42 | } 43 | 44 | bool BinderInterfaceAbstract::wait(quint64 timeout) 45 | { 46 | if (isBinderReady()) { 47 | return true; 48 | } 49 | QTimer timer; 50 | QEventLoop loop; 51 | connect(this, &BinderInterfaceAbstract::binderConnected, &loop, &QEventLoop::quit); 52 | connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); 53 | timer.start(timeout); 54 | loop.exec(); 55 | 56 | return isBinderReady(); 57 | } 58 | 59 | QSharedPointer BinderInterfaceAbstract::createTransaction() 60 | { 61 | QSharedPointer dataParcel; 62 | qCDebug(logging) << Q_FUNC_INFO; 63 | 64 | if (!wait()) { 65 | qCCritical(logging) << Q_FUNC_INFO << "No client!"; 66 | return dataParcel; 67 | } 68 | 69 | GBinderLocalRequest* req = gbinder_client_new_request(m_client); 70 | dataParcel.reset(new Parcel(req)); 71 | return dataParcel; 72 | } 73 | 74 | QSharedPointer BinderInterfaceAbstract::sendTransaction(int code, QSharedPointer parcel, int *status) 75 | { 76 | qCDebug(logging) << Q_FUNC_INFO << code; 77 | QSharedPointer outParcel; 78 | 79 | if (!m_client) { 80 | qCCritical(logging) << Q_FUNC_INFO << "No client!"; 81 | return outParcel; 82 | } 83 | 84 | GBinderRemoteReply *reply = gbinder_client_transact_sync_reply 85 | (m_client, code, parcel->request(), status); 86 | 87 | outParcel.reset(new Parcel(reply)); 88 | return outParcel; 89 | } 90 | 91 | GBinderServiceManager *BinderInterfaceAbstract::manager() 92 | { 93 | return m_serviceManager; 94 | } 95 | 96 | GBinderLocalReply *BinderInterfaceAbstract::onTransact(GBinderLocalObject *obj, GBinderRemoteRequest *req, guint code, guint flags, int *status, void *user_data) 97 | { 98 | BinderInterfaceAbstract* instance = static_cast(user_data); 99 | const char *iface = gbinder_remote_request_interface(req); 100 | qCWarning(instance->logging) << Q_FUNC_INFO; 101 | qCWarning(instance->logging) << "Interface:" << iface; 102 | qCWarning(instance->logging) << "GBinderLocalObject:" << obj; 103 | qCWarning(instance->logging) << "GBinderRemoteRequest:" << req; 104 | qCWarning(instance->logging) << "Code:" << code; 105 | qCWarning(instance->logging) << "Flags:" << flags; 106 | GBinderLocalReply *reply = NULL; 107 | *status = GBINDER_STATUS_OK; 108 | return reply; 109 | } 110 | 111 | void BinderInterfaceAbstract::serviceStopped() 112 | { 113 | qCDebug(logging) << Q_FUNC_INFO; 114 | binderDisconnect(); 115 | } 116 | 117 | void BinderInterfaceAbstract::serviceStarted() 118 | { 119 | qCDebug(logging) << Q_FUNC_INFO; 120 | binderConnect(); 121 | } 122 | 123 | void BinderInterfaceAbstract::binderConnect() 124 | { 125 | qCDebug(logging) << Q_FUNC_INFO << "Binder connect" << m_serviceName << m_interfaceName; 126 | 127 | if (!m_serviceManager) { 128 | qCDebug(logging) << Q_FUNC_INFO << "Creating service manager for" << binderDevice(); 129 | m_serviceManager = gbinder_servicemanager_new(binderDevice()); 130 | } 131 | 132 | if (!m_serviceManager) { 133 | qCCritical(logging) << Q_FUNC_INFO << "Can't create service manager!"; 134 | return; 135 | } 136 | 137 | 138 | qCDebug(logging) << Q_FUNC_INFO << "Add registration handler"; 139 | m_registrationHandler = gbinder_servicemanager_add_registration_handler(m_serviceManager, 140 | m_serviceName, 141 | &BinderInterfaceAbstract::registrationHandler, 142 | this); 143 | } 144 | 145 | void BinderInterfaceAbstract::binderDisconnect() 146 | { 147 | qCWarning(logging) << Q_FUNC_INFO << "Binder disconnect" << m_serviceName << m_interfaceName; 148 | 149 | if (m_client) { 150 | qCWarning(logging) << Q_FUNC_INFO << "Removing client"; 151 | gbinder_client_unref(m_client); 152 | m_client = nullptr; 153 | } 154 | 155 | if (m_deathHandler && m_remote) { 156 | qCWarning(logging) << Q_FUNC_INFO << "Removing death handler"; 157 | gbinder_remote_object_remove_handler(m_remote, m_deathHandler); 158 | m_deathHandler = 0; 159 | } 160 | 161 | if (m_remote) { 162 | qCWarning(logging) << Q_FUNC_INFO << "Removing remote"; 163 | gbinder_remote_object_unref(m_remote); 164 | m_remote = nullptr; 165 | } 166 | 167 | if (m_registrationHandler && m_serviceManager) { 168 | qCWarning(logging) << Q_FUNC_INFO << "Removing registration handler"; 169 | gbinder_servicemanager_remove_handler(m_serviceManager, m_registrationHandler); 170 | m_registrationHandler = 0; 171 | } 172 | 173 | if (m_serviceManager) { 174 | qCWarning(logging) << Q_FUNC_INFO << "Removing service manager"; 175 | gbinder_servicemanager_unref(m_serviceManager); 176 | m_serviceManager = nullptr; 177 | } 178 | 179 | emit binderDisconnected(); 180 | } 181 | 182 | void BinderInterfaceAbstract::registerManager() 183 | { 184 | qCDebug(logging) << Q_FUNC_INFO << "Register manager" << m_serviceName; 185 | 186 | int status; 187 | m_remote = gbinder_remote_object_ref( 188 | gbinder_servicemanager_get_service_sync(m_serviceManager, 189 | m_serviceName, 190 | &status)); 191 | 192 | qCDebug(logging) << Q_FUNC_INFO << "Service status:" << status; 193 | 194 | if (!m_remote) { 195 | qCCritical(logging) << Q_FUNC_INFO << "No remote!"; 196 | binderDisconnect(); 197 | return; 198 | } 199 | 200 | m_deathHandler = gbinder_remote_object_add_death_handler(m_remote, 201 | &BinderInterfaceAbstract::deathHandler, 202 | this); 203 | 204 | qCDebug(logging) << Q_FUNC_INFO << "Register client" << m_interfaceName; 205 | 206 | m_client = gbinder_client_new(m_remote, m_interfaceName); 207 | 208 | if (!m_client) { 209 | qCCritical(logging) << Q_FUNC_INFO << "No client!"; 210 | binderDisconnect(); 211 | return; 212 | } 213 | 214 | qCDebug(logging) << Q_FUNC_INFO << "Removing registration handler"; 215 | 216 | gbinder_servicemanager_remove_handler(m_serviceManager, m_registrationHandler); 217 | m_registrationHandler = 0; 218 | 219 | emit binderConnected(); 220 | } 221 | -------------------------------------------------------------------------------- /alienbinder8/src/binderinterfaceabstract.h: -------------------------------------------------------------------------------- 1 | #ifndef BINDERINTERFACEABSTRACT_H 2 | #define BINDERINTERFACEABSTRACT_H 3 | 4 | #include "../common/src/aliendalvikcontroller.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | class Parcel; 13 | class BinderInterfaceAbstract : public AliendalvikController, public LoggingClassWrapper 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit BinderInterfaceAbstract(const char *serviceName, 18 | const char *interfaceName, 19 | QObject *parent = nullptr, 20 | const char *loggingCategoryName = LOGGING(BinderInterfaceAbstract)".interface"); 21 | virtual ~BinderInterfaceAbstract(); 22 | 23 | bool isBinderReady() const; 24 | bool wait(quint64 timeout = 10000); 25 | 26 | QSharedPointer createTransaction(); 27 | QSharedPointer sendTransaction(int code, QSharedPointer parcel, int *status); 28 | 29 | GBinderServiceManager *manager(); 30 | 31 | static GBinderLocalReply* onTransact( 32 | GBinderLocalObject *obj, 33 | GBinderRemoteRequest *req, 34 | guint code, 35 | guint flags, 36 | int *status, 37 | void *user_data); 38 | 39 | private slots: 40 | void serviceStopped(); 41 | void serviceStarted(); 42 | 43 | signals: 44 | void binderConnected(); 45 | void binderDisconnected(); 46 | 47 | private: 48 | void binderConnect(); 49 | void binderDisconnect(); 50 | 51 | static void registrationHandler(GBinderServiceManager* sm, const char* name, void* user_data); 52 | void registerManager(); 53 | 54 | static void deathHandler(GBinderRemoteObject *obj, void *user_data); 55 | 56 | const char *m_serviceName; 57 | const char *m_interfaceName; 58 | 59 | GBinderRemoteObject *m_remote = nullptr; 60 | GBinderLocalObject *m_local = nullptr; 61 | GBinderServiceManager *m_serviceManager = nullptr; 62 | GBinderClient *m_client = nullptr; 63 | 64 | int m_registrationHandler = 0; 65 | int m_deathHandler = 0; 66 | int m_localHandler = 0; 67 | }; 68 | 69 | #endif // BINDERINTERFACEABSTRACT_H 70 | -------------------------------------------------------------------------------- /alienbinder8/src/binderlocalobject.cpp: -------------------------------------------------------------------------------- 1 | #include "binderlocalobject.h" 2 | #include "binderinterfaceabstract.h" 3 | 4 | BinderLocalObject::BinderLocalObject(const char *name, QObject *parent, const char *loggingCategoryName) 5 | : AliendalvikController(parent) 6 | , LoggingClassWrapper(loggingCategoryName) 7 | , m_serviceName(name) 8 | { 9 | } 10 | 11 | BinderLocalObject::~BinderLocalObject() 12 | { 13 | binderDisconnect(); 14 | } 15 | 16 | GBinderLocalObject *BinderLocalObject::localObject() const 17 | { 18 | return m_localHandler; 19 | } 20 | 21 | GBinderLocalReply *BinderLocalObject::onTransact(GBinderLocalObject *, GBinderRemoteRequest *req, guint code, guint, int *status, void *user_data) 22 | { 23 | BinderLocalObject *binderLocalObject = static_cast(user_data); 24 | const char *iface = gbinder_remote_request_interface(req); 25 | qCDebug(binderLocalObject->logging) << Q_FUNC_INFO << code << iface; 26 | 27 | *status = GBINDER_STATUS_OK; 28 | 29 | GBinderLocalReply *reply = nullptr; 30 | return reply; 31 | } 32 | 33 | void BinderLocalObject::serviceStopped() 34 | { 35 | qCDebug(logging) << Q_FUNC_INFO; 36 | binderDisconnect(); 37 | } 38 | 39 | void BinderLocalObject::serviceStarted() 40 | { 41 | qCDebug(logging) << Q_FUNC_INFO; 42 | binderConnect(); 43 | } 44 | 45 | void BinderLocalObject::binderConnect() 46 | { 47 | qCDebug(logging) << Q_FUNC_INFO << "Creating service manager for" << binderDevice(); 48 | m_serviceManager = gbinder_servicemanager_new(binderDevice()); 49 | 50 | if (!m_serviceManager) { 51 | qCCritical(logging) << Q_FUNC_INFO << "Can't create service manager!"; 52 | return; 53 | } 54 | 55 | m_localHandler = gbinder_servicemanager_new_local_object( 56 | m_serviceManager, 57 | m_serviceName, 58 | &BinderLocalObject::onTransact, 59 | this); 60 | 61 | qCDebug(logging) << Q_FUNC_INFO << "Creating handler for" << m_serviceName << m_localHandler; 62 | } 63 | 64 | void BinderLocalObject::binderDisconnect() 65 | { 66 | if (m_localHandler) { 67 | qCDebug(logging) << Q_FUNC_INFO << "Dropping handler" << m_localHandler; 68 | gbinder_local_object_drop(m_localHandler); 69 | m_localHandler = nullptr; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /alienbinder8/src/binderlocalobject.h: -------------------------------------------------------------------------------- 1 | #ifndef BINDERLOCALOBJECT_H 2 | #define BINDERLOCALOBJECT_H 3 | 4 | #include "../common/src/aliendalvikcontroller.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | #include 10 | 11 | class BinderLocalObject : public AliendalvikController , public LoggingClassWrapper 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit BinderLocalObject(const char *name, 16 | QObject *parent = nullptr, 17 | const char *loggingCategoryName = LOGGING(BinderLocalObject)".interface"); 18 | virtual ~BinderLocalObject(); 19 | 20 | GBinderLocalObject *localObject() const; 21 | 22 | static GBinderLocalReply* onTransact( 23 | GBinderLocalObject *, 24 | GBinderRemoteRequest *req, 25 | guint code, 26 | guint, 27 | int *status, 28 | void *user_data); 29 | 30 | private slots: 31 | void serviceStopped(); 32 | void serviceStarted(); 33 | 34 | private: 35 | void binderConnect(); 36 | void binderDisconnect(); 37 | 38 | const char *m_serviceName; 39 | 40 | GBinderServiceManager *m_serviceManager = nullptr; 41 | GBinderLocalObject *m_localHandler = nullptr; 42 | 43 | }; 44 | 45 | #endif // BINDERLOCALOBJECT_H 46 | -------------------------------------------------------------------------------- /alienbinder8/src/binderlocalservice.cpp: -------------------------------------------------------------------------------- 1 | #include "binderlocalservice.h" 2 | 3 | #include 4 | 5 | BinderLocalService::BinderLocalService(const char *serviceName, 6 | const char *interfaceName, 7 | QObject *parent, 8 | const char *loggingCategoryName) 9 | : AliendalvikController(parent) 10 | , LoggingClassWrapper(loggingCategoryName) 11 | , m_serviceName(serviceName) 12 | , m_interfaceName(interfaceName) 13 | { 14 | } 15 | 16 | BinderLocalService::~BinderLocalService() 17 | { 18 | binderDisconnect(); 19 | } 20 | 21 | void BinderLocalService::serviceStopped() 22 | { 23 | qCDebug(logging) << Q_FUNC_INFO; 24 | binderDisconnect(); 25 | } 26 | 27 | void BinderLocalService::serviceStarted() 28 | { 29 | qCDebug(logging) << Q_FUNC_INFO; 30 | binderConnect(); 31 | } 32 | 33 | void BinderLocalService::binderConnect() 34 | { 35 | qCDebug(logging) << Q_FUNC_INFO << "Binder connect" << m_serviceName << m_interfaceName; 36 | 37 | if (!m_serviceManager) { 38 | qCWarning(logging) << Q_FUNC_INFO << "Creating service manager for" << binderDevice(); 39 | m_serviceManager = gbinder_servicemanager_new(binderDevice()); 40 | } 41 | 42 | if (!m_serviceManager) { 43 | qCCritical(logging) << Q_FUNC_INFO << "Can't create service manager!"; 44 | return; 45 | } 46 | 47 | if (!m_localObject) { 48 | qCWarning(logging) << Q_FUNC_INFO << "Creating local object"; 49 | m_localObject = gbinder_servicemanager_new_local_object( 50 | m_serviceManager, 51 | m_interfaceName, 52 | &BinderLocalService::handler, 53 | this); 54 | } 55 | 56 | if (!m_binderServiceName) { 57 | qCWarning(logging) << Q_FUNC_INFO << "Creating service name"; 58 | m_binderServiceName = gbinder_servicename_new(m_serviceManager, m_localObject, m_serviceName); 59 | } 60 | 61 | emit binderConnected(); 62 | } 63 | 64 | void BinderLocalService::binderDisconnect() 65 | { 66 | qCWarning(logging) << Q_FUNC_INFO << "Binder disconnect" << m_serviceName << m_interfaceName; 67 | 68 | if (m_binderServiceName) { 69 | qCWarning(logging) << Q_FUNC_INFO << "Removing service name"; 70 | gbinder_servicename_unref(m_binderServiceName); 71 | m_binderServiceName = nullptr; 72 | } 73 | 74 | if (m_localObject) { 75 | qCWarning(logging) << Q_FUNC_INFO << "Removing local obbject"; 76 | gbinder_local_object_drop(m_localObject); 77 | m_localObject = nullptr; 78 | } 79 | 80 | if (m_serviceManager) { 81 | qCWarning(logging) << Q_FUNC_INFO << "Removing service manager"; 82 | gbinder_servicemanager_unref(m_serviceManager); 83 | m_serviceManager = nullptr; 84 | } 85 | 86 | emit binderDisconnected(); 87 | } 88 | 89 | GBinderLocalReply *BinderLocalService::handler(GBinderLocalObject *obj, 90 | GBinderRemoteRequest *req, 91 | guint code, 92 | guint flags, 93 | int *status, 94 | void *user_data) 95 | { 96 | BinderLocalService *instance = static_cast(user_data); 97 | return instance->onTransact(obj, req, code, flags, status); 98 | } 99 | -------------------------------------------------------------------------------- /alienbinder8/src/binderlocalservice.h: -------------------------------------------------------------------------------- 1 | #ifndef BINDERLOCALSERVICE_H 2 | #define BINDERLOCALSERVICE_H 3 | 4 | #include "../common/src/aliendalvikcontroller.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | #include 10 | 11 | class BinderLocalService: public AliendalvikController, public LoggingClassWrapper 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit BinderLocalService(const char *serviceName, 16 | const char *interfaceName, 17 | QObject *parent = nullptr, 18 | const char *loggingCategoryName = LOGGING(BinderLocalService)".interface"); 19 | virtual ~BinderLocalService(); 20 | 21 | signals: 22 | void binderConnected(); 23 | void binderDisconnected(); 24 | 25 | private slots: 26 | void serviceStopped(); 27 | void serviceStarted(); 28 | 29 | protected: 30 | virtual GBinderLocalReply *onTransact( 31 | GBinderLocalObject *obj, 32 | GBinderRemoteRequest *req, 33 | guint code, 34 | guint flags, 35 | int *status) = 0; 36 | 37 | private: 38 | void binderConnect(); 39 | void binderDisconnect(); 40 | 41 | static GBinderLocalReply *handler( 42 | GBinderLocalObject *obj, 43 | GBinderRemoteRequest *req, 44 | guint code, 45 | guint flags, 46 | int *status, 47 | void *user_data); 48 | 49 | const char *m_serviceName; 50 | const char *m_interfaceName; 51 | 52 | GBinderServiceManager *m_serviceManager = nullptr; 53 | GBinderServiceName *m_binderServiceName = nullptr; 54 | GBinderLocalObject *m_localObject = nullptr; 55 | GBinderRemoteObject *m_remoteObject = nullptr; 56 | 57 | }; 58 | 59 | #endif // BINDERLOCALSERVICE_H 60 | -------------------------------------------------------------------------------- /alienbinder8/src/bitset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef BITSET_H 18 | #define BITSET_H 19 | 20 | #include 21 | 22 | // A simple set of 64 bits that can be individually marked or cleared. 23 | struct BitSet64 { 24 | uint64_t value; 25 | inline BitSet64() : value(0ULL) { } 26 | explicit inline BitSet64(uint64_t value) : value(value) { } 27 | // Gets the value associated with a particular bit index. 28 | static inline uint64_t valueForBit(uint32_t n) { return 0x8000000000000000ULL >> n; } 29 | // Clears the bit set. 30 | inline void clear() { clear(value); } 31 | static inline void clear(uint64_t& value) { value = 0ULL; } 32 | // Returns the number of marked bits in the set. 33 | inline uint32_t count() const { return count(value); } 34 | static inline uint32_t count(uint64_t value) { return __builtin_popcountll(value); } 35 | // Returns true if the bit set does not contain any marked bits. 36 | inline bool isEmpty() const { return isEmpty(value); } 37 | static inline bool isEmpty(uint64_t value) { return ! value; } 38 | // Returns true if the bit set does not contain any unmarked bits. 39 | inline bool isFull() const { return isFull(value); } 40 | static inline bool isFull(uint64_t value) { return value == 0xffffffffffffffffULL; } 41 | // Returns true if the specified bit is marked. 42 | inline bool hasBit(uint32_t n) const { return hasBit(value, n); } 43 | static inline bool hasBit(uint64_t value, uint32_t n) { return value & valueForBit(n); } 44 | // Marks the specified bit. 45 | inline void markBit(uint32_t n) { markBit(value, n); } 46 | static inline void markBit(uint64_t& value, uint32_t n) { value |= valueForBit(n); } 47 | // Clears the specified bit. 48 | inline void clearBit(uint32_t n) { clearBit(value, n); } 49 | static inline void clearBit(uint64_t& value, uint32_t n) { value &= ~ valueForBit(n); } 50 | // Finds the first marked bit in the set. 51 | // Result is undefined if all bits are unmarked. 52 | inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } 53 | static inline uint32_t firstMarkedBit(uint64_t value) { return __builtin_clzll(value); } 54 | // Finds the first unmarked bit in the set. 55 | // Result is undefined if all bits are marked. 56 | inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } 57 | static inline uint32_t firstUnmarkedBit(uint64_t value) { return __builtin_clzll(~ value); } 58 | // Finds the last marked bit in the set. 59 | // Result is undefined if all bits are unmarked. 60 | inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } 61 | static inline uint32_t lastMarkedBit(uint64_t value) { return 63 - __builtin_ctzll(value); } 62 | // Finds the first marked bit in the set and clears it. Returns the bit index. 63 | // Result is undefined if all bits are unmarked. 64 | inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } 65 | static inline uint32_t clearFirstMarkedBit(uint64_t& value) { 66 | uint64_t n = firstMarkedBit(value); 67 | clearBit(value, n); 68 | return n; 69 | } 70 | // Finds the first unmarked bit in the set and marks it. Returns the bit index. 71 | // Result is undefined if all bits are marked. 72 | inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } 73 | static inline uint32_t markFirstUnmarkedBit(uint64_t& value) { 74 | uint64_t n = firstUnmarkedBit(value); 75 | markBit(value, n); 76 | return n; 77 | } 78 | // Finds the last marked bit in the set and clears it. Returns the bit index. 79 | // Result is undefined if all bits are unmarked. 80 | inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } 81 | static inline uint32_t clearLastMarkedBit(uint64_t& value) { 82 | uint64_t n = lastMarkedBit(value); 83 | clearBit(value, n); 84 | return n; 85 | } 86 | // Gets the index of the specified bit in the set, which is the number of 87 | // marked bits that appear before the specified bit. 88 | inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } 89 | static inline uint32_t getIndexOfBit(uint64_t value, uint32_t n) { 90 | return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); 91 | } 92 | inline bool operator== (const BitSet64& other) const { return value == other.value; } 93 | inline bool operator!= (const BitSet64& other) const { return value != other.value; } 94 | inline BitSet64 operator& (const BitSet64& other) const { 95 | return BitSet64(value & other.value); 96 | } 97 | inline BitSet64& operator&= (const BitSet64& other) { 98 | value &= other.value; 99 | return *this; 100 | } 101 | inline BitSet64 operator| (const BitSet64& other) const { 102 | return BitSet64(value | other.value); 103 | } 104 | inline BitSet64& operator|= (const BitSet64& other) { 105 | value |= other.value; 106 | return *this; 107 | } 108 | }; 109 | 110 | #endif // BITSET_H 111 | -------------------------------------------------------------------------------- /alienbinder8/src/componentinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "applicationinfo.h" 2 | #include "componentinfo.h" 3 | #include "parcel.h" 4 | 5 | ComponentInfo::ComponentInfo(Parcel *parcel, const char *loggingCategoryName) 6 | : PackageItemInfo(parcel, loggingCategoryName) 7 | { 8 | hasApplicationInfo = parcel->readBoolean(); 9 | qCDebug(logging) << Q_FUNC_INFO << "hasApplicationInfo:" << hasApplicationInfo; 10 | if (hasApplicationInfo) { 11 | // applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source); 12 | applicationInfo = new ApplicationInfo(parcel); 13 | } 14 | processName = parcel->readString(); 15 | qCDebug(logging) << Q_FUNC_INFO << "processName:" << processName; 16 | splitName = parcel->readString(); 17 | qCDebug(logging) << Q_FUNC_INFO << "splitName:" << splitName; 18 | descriptionRes = parcel->readInt(); 19 | qCDebug(logging) << Q_FUNC_INFO << "descriptionRes:" << descriptionRes; 20 | enabled = parcel->readBoolean(); 21 | qCDebug(logging) << Q_FUNC_INFO << "enabled:" << enabled; 22 | exported = parcel->readBoolean(); 23 | qCDebug(logging) << Q_FUNC_INFO << "exported:" << exported; 24 | directBootAware = parcel->readBoolean(); 25 | qCDebug(logging) << Q_FUNC_INFO << "directBootAware:" << directBootAware; 26 | encryptionAware = directBootAware; 27 | 28 | } 29 | 30 | ComponentInfo::~ComponentInfo() 31 | { 32 | if (applicationInfo) { 33 | delete applicationInfo; 34 | applicationInfo = nullptr; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /alienbinder8/src/componentinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPONENTINFO_H 2 | #define COMPONENTINFO_H 3 | 4 | #include "packageiteminfo.h" 5 | 6 | class Parcel; 7 | class ApplicationInfo; 8 | class ComponentInfo : public PackageItemInfo 9 | { 10 | public: 11 | ComponentInfo(Parcel *parcel, const char *loggingCategoryName = LOGGING(ComponentInfo)".parcel"); 12 | virtual ~ComponentInfo(); 13 | 14 | bool hasApplicationInfo = false; 15 | 16 | ApplicationInfo *applicationInfo = nullptr; 17 | 18 | QString processName; 19 | QString splitName; 20 | int descriptionRes = -1; 21 | bool enabled = false; 22 | bool exported = false; 23 | bool encryptionAware = false; 24 | bool directBootAware = false; 25 | }; 26 | 27 | #endif // COMPONENTINFO_H 28 | -------------------------------------------------------------------------------- /alienbinder8/src/errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | #include 18 | #include 19 | #include 20 | namespace android { 21 | /** 22 | * The type used to return success/failure from frameworks APIs. 23 | * See the anonymous enum below for valid values. 24 | */ 25 | typedef int32_t status_t; 26 | /* 27 | * Error codes. 28 | * All error codes are negative values. 29 | */ 30 | // Win32 #defines NO_ERROR as well. It has the same value, so there's no 31 | // real conflict, though it's a bit awkward. 32 | #ifdef _WIN32 33 | # undef NO_ERROR 34 | #endif 35 | enum { 36 | OK = 0, // Preferred constant for checking success. 37 | NO_ERROR = OK, // Deprecated synonym for `OK`. Prefer `OK` because it doesn't conflict with Windows. 38 | UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value 39 | NO_MEMORY = -ENOMEM, 40 | INVALID_OPERATION = -ENOSYS, 41 | BAD_VALUE = -EINVAL, 42 | BAD_TYPE = (UNKNOWN_ERROR + 1), 43 | NAME_NOT_FOUND = -ENOENT, 44 | PERMISSION_DENIED = -EPERM, 45 | NO_INIT = -ENODEV, 46 | ALREADY_EXISTS = -EEXIST, 47 | DEAD_OBJECT = -EPIPE, 48 | FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), 49 | #if !defined(_WIN32) 50 | BAD_INDEX = -EOVERFLOW, 51 | NOT_ENOUGH_DATA = -ENODATA, 52 | WOULD_BLOCK = -EWOULDBLOCK, 53 | TIMED_OUT = -ETIMEDOUT, 54 | UNKNOWN_TRANSACTION = -EBADMSG, 55 | #else 56 | BAD_INDEX = -E2BIG, 57 | NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), 58 | WOULD_BLOCK = (UNKNOWN_ERROR + 4), 59 | TIMED_OUT = (UNKNOWN_ERROR + 5), 60 | UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), 61 | #endif 62 | FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), 63 | UNEXPECTED_NULL = (UNKNOWN_ERROR + 8), 64 | }; 65 | // Restore define; enumeration is in "android" namespace, so the value defined 66 | // there won't work for Win32 code in a different namespace. 67 | #ifdef _WIN32 68 | # define NO_ERROR 0L 69 | #endif 70 | } // namespace android 71 | -------------------------------------------------------------------------------- /alienbinder8/src/input.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "input.h" 18 | 19 | #include "parcel.h" 20 | #include 21 | 22 | namespace android { 23 | 24 | float PointerCoords::getAxisValue(int32_t axis) const { 25 | if (axis < 0 || axis > 63 || !BitSet64::hasBit(bits, axis)){ 26 | return 0; 27 | } 28 | return values[BitSet64::getIndexOfBit(bits, axis)]; 29 | } 30 | 31 | status_t PointerCoords::setAxisValue(int32_t axis, float value) { 32 | if (axis < 0 || axis > 63) { 33 | return NAME_NOT_FOUND; 34 | } 35 | uint32_t index = BitSet64::getIndexOfBit(bits, axis); 36 | if (!BitSet64::hasBit(bits, axis)) { 37 | if (value == 0) { 38 | return OK; // axes with value 0 do not need to be stored 39 | } 40 | uint32_t count = BitSet64::count(bits); 41 | if (count >= MAX_AXES) { 42 | tooManyAxes(axis); 43 | return NO_MEMORY; 44 | } 45 | BitSet64::markBit(bits, axis); 46 | for (uint32_t i = count; i > index; i--) { 47 | values[i] = values[i - 1]; 48 | } 49 | } 50 | values[index] = value; 51 | return OK; 52 | } 53 | static inline void scaleAxisValue(PointerCoords& c, int axis, float scaleFactor) { 54 | float value = c.getAxisValue(axis); 55 | if (value != 0) { 56 | c.setAxisValue(axis, value * scaleFactor); 57 | } 58 | } 59 | void PointerCoords::scale(float scaleFactor) { 60 | // No need to scale pressure or size since they are normalized. 61 | // No need to scale orientation since it is meaningless to do so. 62 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_X, scaleFactor); 63 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_Y, scaleFactor); 64 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MAJOR, scaleFactor); 65 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOUCH_MINOR, scaleFactor); 66 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MAJOR, scaleFactor); 67 | scaleAxisValue(*this, AMOTION_EVENT_AXIS_TOOL_MINOR, scaleFactor); 68 | } 69 | void PointerCoords::applyOffset(float xOffset, float yOffset) { 70 | setAxisValue(AMOTION_EVENT_AXIS_X, getX() + xOffset); 71 | setAxisValue(AMOTION_EVENT_AXIS_Y, getY() + yOffset); 72 | } 73 | 74 | status_t PointerCoords::readFromParcel(Parcel* parcel) { 75 | bits = parcel->readInt64(); 76 | uint32_t count = BitSet64::count(bits); 77 | if (count > MAX_AXES) { 78 | return BAD_VALUE; 79 | } 80 | for (uint32_t i = 0; i < count; i++) { 81 | values[i] = parcel->readFloat(); 82 | } 83 | return OK; 84 | } 85 | status_t PointerCoords::writeToParcel(Parcel* parcel) const { 86 | parcel->writeInt64(bits); 87 | uint32_t count = BitSet64::count(bits); 88 | for (uint32_t i = 0; i < count; i++) { 89 | parcel->writeFloat(values[i]); 90 | } 91 | return OK; 92 | } 93 | 94 | void PointerCoords::tooManyAxes(int axis) { 95 | qWarning() << "Could not set value for axis %d because the PointerCoords structure is full and cannot contain more than %d axis values." << axis << int(MAX_AXES); 96 | } 97 | bool PointerCoords::operator==(const PointerCoords& other) const { 98 | if (bits != other.bits) { 99 | return false; 100 | } 101 | uint32_t count = BitSet64::count(bits); 102 | for (uint32_t i = 0; i < count; i++) { 103 | if (values[i] != other.values[i]) { 104 | return false; 105 | } 106 | } 107 | return true; 108 | } 109 | void PointerCoords::copyFrom(const PointerCoords& other) { 110 | bits = other.bits; 111 | uint32_t count = BitSet64::count(bits); 112 | for (uint32_t i = 0; i < count; i++) { 113 | values[i] = other.values[i]; 114 | } 115 | } 116 | 117 | } // namespace android 118 | -------------------------------------------------------------------------------- /alienbinder8/src/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef INPUT_H 18 | #define INPUT_H 19 | 20 | #include "bitset.h" 21 | #include "errors.h" 22 | 23 | class Parcel; 24 | 25 | namespace android { 26 | 27 | enum { 28 | AMOTION_EVENT_AXIS_X = 0, 29 | AMOTION_EVENT_AXIS_Y = 1, 30 | AMOTION_EVENT_AXIS_PRESSURE = 2, 31 | AMOTION_EVENT_AXIS_SIZE = 3, 32 | AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, 33 | AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, 34 | AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, 35 | AMOTION_EVENT_AXIS_TOOL_MINOR = 7, 36 | AMOTION_EVENT_AXIS_ORIENTATION = 8, 37 | AMOTION_EVENT_AXIS_VSCROLL = 9, 38 | AMOTION_EVENT_AXIS_HSCROLL = 10, 39 | }; 40 | 41 | /* 42 | * Pointer coordinate data. 43 | */ 44 | struct PointerCoords { 45 | enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 128 46 | // Bitfield of axes that are present in this structure. 47 | uint64_t bits __attribute__((aligned(8))); 48 | // Values of axes that are stored in this structure packed in order by axis id 49 | // for each axis that is present in the structure according to 'bits'. 50 | float values[MAX_AXES]; 51 | inline void clear() { 52 | BitSet64::clear(bits); 53 | } 54 | bool isEmpty() const { 55 | return BitSet64::isEmpty(bits); 56 | } 57 | float getAxisValue(int32_t axis) const; 58 | status_t setAxisValue(int32_t axis, float value); 59 | void scale(float scale); 60 | void applyOffset(float xOffset, float yOffset); 61 | inline float getX() const { 62 | return getAxisValue(AMOTION_EVENT_AXIS_X); 63 | } 64 | inline float getY() const { 65 | return getAxisValue(AMOTION_EVENT_AXIS_Y); 66 | } 67 | status_t readFromParcel(Parcel* parcel); 68 | status_t writeToParcel(Parcel* parcel) const; 69 | bool operator==(const PointerCoords& other) const; 70 | inline bool operator!=(const PointerCoords& other) const { 71 | return !(*this == other); 72 | } 73 | void copyFrom(const PointerCoords& other); 74 | private: 75 | void tooManyAxes(int axis); 76 | }; 77 | 78 | } // namespace android 79 | 80 | #endif // INPUT_H 81 | -------------------------------------------------------------------------------- /alienbinder8/src/inputmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "inputmanager.h" 2 | #include "parcel.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "input.h" 9 | 10 | #define IM_SERVICE_NAME "input" 11 | #define IM_INTERFACE_NAME "android.hardware.input.IInputManager" 12 | 13 | static InputManager *s_instance = nullptr; 14 | 15 | InputManager::InputManager(QObject *parent, const char *loggingCategoryName) 16 | : BinderInterfaceAbstract(IM_SERVICE_NAME, 17 | IM_INTERFACE_NAME, 18 | parent, 19 | loggingCategoryName) 20 | { 21 | 22 | } 23 | 24 | InputManager::~InputManager() 25 | { 26 | if (s_instance == this) { 27 | s_instance = nullptr; 28 | } 29 | } 30 | 31 | InputManager *InputManager::GetInstance() 32 | { 33 | if (!s_instance) { 34 | s_instance = new InputManager(qApp); 35 | } 36 | return s_instance; 37 | } 38 | 39 | void InputManager::sendTap(int posx, int posy, quint64 uptime) 40 | { 41 | InputManager::injectTapEvent(0, posx, posy, 1.0f, uptime + 10); 42 | InputManager::injectTapEvent(1, posx, posy, 0.0f, uptime + 20); 43 | } 44 | 45 | void InputManager::injectTapEvent(int action, float posx, float posy, float pressure, quint64 uptime) 46 | { 47 | InputManager *manager = InputManager::GetInstance(); 48 | qCDebug(manager->logging) << Q_FUNC_INFO << action << posx << posy << pressure << uptime; 49 | 50 | QSharedPointer parcel = manager->createTransaction(); 51 | parcel->writeInt(1); // have event 52 | parcel->writeInt(1); // PARCEL_TOKEN_MOTION_EVENT 53 | 54 | parcel->writeInt(1); // pointerCount 55 | parcel->writeInt(1); // sampleCount 56 | parcel->writeInt(1); // mDeviceId 57 | parcel->writeInt(0x1002); // mSource 58 | parcel->writeInt(action); // mAction 59 | parcel->writeInt(0); // mActionButton 60 | parcel->writeInt(0); // mFlags 61 | parcel->writeInt(0); // mEdgeFlags 62 | parcel->writeInt(0); // mMetaState 63 | parcel->writeInt(0); // mButtonState 64 | parcel->writeFloat(0.0f); // mXOffset 65 | parcel->writeFloat(0.0f); // mYOffset 66 | parcel->writeFloat(1.0f); // mXPrecision 67 | parcel->writeFloat(1.0f); // mYPrecision 68 | parcel->writeInt64(uptime * 1000000); // mDownTime 69 | parcel->writeInt(0); // properties.id 70 | parcel->writeInt(0); // properties.toolType 71 | parcel->writeInt64(uptime * 1000000); // mSampleEventTimes 72 | 73 | android::PointerCoords pointerCoords; 74 | pointerCoords.clear(); 75 | 76 | pointerCoords.setAxisValue(android::AMOTION_EVENT_AXIS_X, posx); 77 | pointerCoords.setAxisValue(android::AMOTION_EVENT_AXIS_Y, posy); 78 | pointerCoords.setAxisValue(android::AMOTION_EVENT_AXIS_PRESSURE, pressure); 79 | pointerCoords.setAxisValue(android::AMOTION_EVENT_AXIS_SIZE, 1.0f); 80 | 81 | pointerCoords.writeToParcel(parcel.data()); 82 | 83 | // enum { MAX_AXES = 30 }; // 30 so that sizeof(PointerCoords) == 128 84 | // // Bitfield of axes that are present in this structure. 85 | // uint64_t bits __attribute__((aligned(8))); 86 | // // Values of axes that are stored in this structure packed in order by axis id 87 | // // for each axis that is present in the structure according to 'bits'. 88 | // float values[MAX_AXES]; 89 | 90 | // const float size = 1.0f; 91 | // float inputValues[] = {posx, posy, pressure, size}; 92 | 93 | // BitSet64::clear(bits); 94 | 95 | // for (int axis = 0; axis < 4; axis++) { 96 | // float value = inputValues[axis]; 97 | // uint32_t index = BitSet64::getIndexOfBit(bits, axis); 98 | // if (!BitSet64::hasBit(bits, axis)) { 99 | // if (value == 0) { 100 | // continue; // axes with value 0 do not need to be stored 101 | // } 102 | // uint32_t count = BitSet64::count(bits); 103 | // if (count >= MAX_AXES) { 104 | // continue; 105 | // } 106 | // BitSet64::markBit(bits, axis); 107 | // for (uint32_t i = count; i > index; i--) { 108 | // values[i] = values[i - 1]; 109 | // } 110 | // } 111 | // values[index] = value; 112 | // } 113 | // parcel->writeInt64(bits); // values bits 114 | 115 | // uint32_t count = BitSet64::count(bits); 116 | // for (uint32_t i = 0; i < count; i++) { 117 | // parcel->writeFloat(values[i]); 118 | // } 119 | 120 | parcel->writeInt(2); // mode 121 | 122 | int status = 0; 123 | QSharedPointer out = manager->sendTransaction(TRANSACTION_injectInputEvent, parcel, &status); 124 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 125 | if (status < 0) { 126 | return; 127 | } 128 | const int exception = out->readInt(); 129 | if (exception != 0) { 130 | qCCritical(manager->logging) << Q_FUNC_INFO << "Exception:" << exception; 131 | return; 132 | } 133 | const int result = out->readInt(); 134 | qCDebug(manager->logging) << Q_FUNC_INFO << "Result:" << result; 135 | } 136 | 137 | void InputManager::keyevent(int keycode, quint64 uptime) 138 | { 139 | InputManager *manager = InputManager::GetInstance(); 140 | qCDebug(manager->logging) << Q_FUNC_INFO << keycode << uptime; 141 | 142 | QSharedPointer parcel = manager->createTransaction(); 143 | parcel->writeInt(1); // have event 144 | parcel->writeInt(2); // PARCEL_TOKEN_KEY_EVENT 145 | 146 | parcel->writeInt(1); // mDeviceId 147 | parcel->writeInt(0x1002); // mSource 148 | parcel->writeInt(ACTION_DOWN); // mAction 149 | parcel->writeInt(keycode); // mKeyCode 150 | parcel->writeInt(0); // mRepeatCount 151 | parcel->writeInt(0); // mMetaState 152 | parcel->writeInt(0); // mScanCode 153 | parcel->writeInt(0); // mFlags 154 | parcel->writeInt64(uptime * 1000000); // mDownTime 155 | parcel->writeInt64(uptime * 1000000); // mEventTime 156 | 157 | int status = 0; 158 | QSharedPointer out = manager->sendTransaction(TRANSACTION_injectInputEvent, parcel, &status); 159 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 160 | if (status < 0) { 161 | return; 162 | } 163 | const int exception = out->readInt(); 164 | if (exception != 0) { 165 | qCCritical(manager->logging) << Q_FUNC_INFO << "Exception:" << exception; 166 | return; 167 | } 168 | const int result = out->readInt(); 169 | qCDebug(manager->logging) << Q_FUNC_INFO << "Result:" << result; 170 | } 171 | -------------------------------------------------------------------------------- /alienbinder8/src/inputmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef INPUTMANAGER_H 2 | #define INPUTMANAGER_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | 6 | #include 7 | 8 | enum { 9 | TRANSACTION_getInputDevice = 1, 10 | TRANSACTION_getInputDeviceIds = 2, 11 | TRANSACTION_injectInputEvent = 8, 12 | }; 13 | 14 | enum { 15 | ACTION_DOWN = 0, 16 | ACTION_UP, 17 | ACTION_MULTIPLE 18 | }; 19 | 20 | class Intent; 21 | class InputManager : public BinderInterfaceAbstract 22 | { 23 | Q_OBJECT 24 | public: 25 | explicit InputManager(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(InputManager)".manager"); 26 | virtual ~InputManager(); 27 | 28 | static InputManager *GetInstance(); 29 | 30 | // hacks 31 | static void sendTap(int posx, int posy, quint64 uptime); 32 | static void injectTapEvent(int action, float posx, float posy, float pressure, quint64 uptime); 33 | static void keyevent(int keycode, quint64 uptime); 34 | }; 35 | 36 | #endif // INPUTMANAGER_H 37 | -------------------------------------------------------------------------------- /alienbinder8/src/intent.cpp: -------------------------------------------------------------------------------- 1 | #include "intent.h" 2 | #include "parcel.h" 3 | 4 | Intent::Intent(const char *loggingCategoryName) 5 | : Parcelable(QStringLiteral("android.content.Intent")) 6 | , LoggingClassWrapper(loggingCategoryName) 7 | { 8 | 9 | } 10 | 11 | Intent::Intent(const Parcel *parcel, const char *loggingCategoryName) 12 | : Parcelable(QStringLiteral("android.content.Intent")) 13 | , LoggingClassWrapper(loggingCategoryName) 14 | { 15 | if (!parcel) { 16 | qCCritical(logging) << Q_FUNC_INFO << "Null Parcel!"; 17 | return; 18 | } 19 | 20 | action = parcel->readString(); 21 | qCDebug(logging) << Q_FUNC_INFO << "Action:" << action; 22 | 23 | // Uri createFromParcel(Parcel in) 24 | const int uriType = parcel->readInt(); 25 | qCDebug(logging) << Q_FUNC_INFO << "Uri type:" << uriType; 26 | 27 | if (uriType == 1) { 28 | data = parcel->readString(); 29 | qCDebug(logging) << Q_FUNC_INFO << "Data:" << data; 30 | } 31 | 32 | type = parcel->readString(); 33 | qCDebug(logging) << Q_FUNC_INFO << "Type:" << type; 34 | flags = parcel->readInt(); 35 | qCDebug(logging) << Q_FUNC_INFO << "Flags:" << flags; 36 | package = parcel->readString(); 37 | qCDebug(logging) << Q_FUNC_INFO << "Package:" << package; 38 | classPackage = parcel->readString(); 39 | qCDebug(logging) << Q_FUNC_INFO << "Class package:" << classPackage; 40 | if (!classPackage.isNull()) { 41 | className = parcel->readString(); 42 | qCDebug(logging) << Q_FUNC_INFO << "Class name:" << className; 43 | } 44 | const int mSourceBounds = parcel->readInt(); 45 | qCDebug(logging) << Q_FUNC_INFO << "mSourceBounds:" << mSourceBounds; 46 | const int categoriesLength = parcel->readInt(); 47 | qCDebug(logging) << Q_FUNC_INFO << "categoriesLength:" << categoriesLength; 48 | const int mSelector = parcel->readInt(); 49 | qCDebug(logging) << Q_FUNC_INFO << "mSelector:" << mSelector; 50 | const int mClipData = parcel->readInt(); 51 | qCDebug(logging) << Q_FUNC_INFO << "mClipData:" << mClipData; 52 | const int contentUserHint = parcel->readInt(); 53 | qCDebug(logging) << Q_FUNC_INFO << "contentUserHint:" << contentUserHint; 54 | parcel->readBundle(); 55 | } 56 | 57 | Intent::Intent(const Intent &other) 58 | : Parcelable(other.creator) 59 | , LoggingClassWrapper(other.logging.categoryName()) 60 | { 61 | action = other.action; 62 | data = other.data; 63 | type = other.type; 64 | 65 | flags = other.flags; 66 | 67 | package = other.package; 68 | classPackage = other.classPackage; 69 | className = other.className; 70 | 71 | contentUserHint = other.contentUserHint; 72 | 73 | extras = other.extras; 74 | } 75 | 76 | Intent::~Intent() 77 | { 78 | 79 | } 80 | 81 | void Intent::writeToParcel(Parcel *parcel) const 82 | { 83 | if (!parcel) { 84 | qCCritical(logging) << Q_FUNC_INFO << "Null Parcel!"; 85 | return; 86 | } 87 | 88 | parcel->writeString(action); 89 | 90 | // Uri.writeToParcel 91 | if (data.isNull()) { 92 | parcel->writeInt(0); // NULL_TYPE_ID 93 | } else { 94 | parcel->writeInt(1); // TYPE_ID UriString = 1 95 | parcel->writeString(data); 96 | } 97 | 98 | parcel->writeString(type); 99 | 100 | parcel->writeInt(flags); 101 | 102 | parcel->writeString(package); 103 | 104 | // ComponentName.writeToParcel 105 | if (classPackage.isEmpty() && className.isEmpty()) { 106 | parcel->writeString(QString()); 107 | } else { 108 | parcel->writeString(classPackage); 109 | if (className.startsWith(QChar(u'.'))) { 110 | parcel->writeString(classPackage + className); 111 | } else { 112 | parcel->writeString(className); 113 | } 114 | } 115 | 116 | parcel->writeInt(0); // mSourceBounds disable 117 | parcel->writeInt(0); // mCategories disable 118 | parcel->writeInt(0); // mSelector disable 119 | parcel->writeInt(0); // mClipData disable 120 | 121 | parcel->writeInt(contentUserHint); 122 | 123 | if (extras.isEmpty()) { 124 | parcel->writeInt(-1); 125 | } else { 126 | parcel->writeBundle(extras); 127 | } 128 | } 129 | 130 | QDebug operator<<(QDebug dbg, const Intent &intent) 131 | { 132 | dbg << "Action:" << intent.action; 133 | return dbg.maybeSpace(); 134 | } 135 | -------------------------------------------------------------------------------- /alienbinder8/src/intent.h: -------------------------------------------------------------------------------- 1 | #ifndef INTENT_H 2 | #define INTENT_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | #include "parcelable.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | enum { 12 | USER_NULL = -10000, 13 | USER_CURRENT_OR_SELF = -3, 14 | USER_CURRENT = -2, 15 | USER_ALL = -1, 16 | USER_OWNER = 0 17 | }; 18 | 19 | class Parcel; 20 | class Intent : public Parcelable, public LoggingClassWrapper 21 | { 22 | public: 23 | Intent(const char *loggingCategoryName = LOGGING(Intent)".parcel"); 24 | Intent(const Parcel *parcel, const char *loggingCategoryName = LOGGING(Intent)".parcel"); 25 | Intent(const Intent &other); 26 | ~Intent(); 27 | 28 | void writeToParcel(Parcel *parcel) const override; 29 | 30 | QString action; 31 | QString data; 32 | QString type; 33 | 34 | int flags = 0; 35 | 36 | QString package; 37 | QString classPackage; 38 | QString className; 39 | 40 | int contentUserHint = USER_CURRENT; 41 | 42 | QVariantHash extras; 43 | }; 44 | 45 | Q_DECLARE_METATYPE(Intent) 46 | 47 | QDebug operator<<(QDebug dbg, const Intent &intent); 48 | 49 | #endif // INTENT_H 50 | -------------------------------------------------------------------------------- /alienbinder8/src/intentfilter.cpp: -------------------------------------------------------------------------------- 1 | #include "intentfilter.h" 2 | #include "parcel.h" 3 | 4 | IntentFilter::IntentFilter(Parcel *parcel, const char *loggingCategoryName) 5 | : LoggingClassWrapper(loggingCategoryName) 6 | { 7 | const int length = parcel->readInt(); 8 | qCDebug(logging) << Q_FUNC_INFO << "mActions length:" << length; 9 | // mActions = parcel->readStringList(); 10 | // qCDebug(logging) << Q_FUNC_INFO << "mActions:" << mActions; 11 | // if (parcel->readInt() != 0) { 12 | // mCategories = parcel->readStringList(); 13 | // qCDebug(logging) << Q_FUNC_INFO << "mCategories:" << mActions; 14 | // } 15 | // if (parcel->readInt() != 0) { 16 | // mDataSchemes = parcel->readStringList(); 17 | // qCDebug(logging) << Q_FUNC_INFO << "mDataSchemes:" << mActions; 18 | // } 19 | // if (parcel->readInt() != 0) { 20 | // mDataTypes = parcel->readStringList(); 21 | // qCDebug(logging) << Q_FUNC_INFO << "mDataTypes:" << mActions; 22 | // } 23 | // const int N = parcel->readInt(); 24 | // qCDebug(logging) << Q_FUNC_INFO << "have mDataSchemeSpecificParts!"; 25 | // if (N > 0) { 26 | // mDataSchemeSpecificParts = new ArrayList(N); 27 | // for (int i=0; ireadInt(); 32 | // if (N > 0) { 33 | // mDataAuthorities = new ArrayList(N); 34 | // for (int i=0; ireadInt(); 39 | // if (N > 0) { 40 | // mDataPaths = new ArrayList(N); 41 | // for (int i=0; ireadInt(); 46 | // mHasPartialTypes = parcel->readInt() > 0; 47 | // setAutoVerify(parcel->readInt() > 0); 48 | // setVisibilityToInstantApp(parcel->readInt()); 49 | } 50 | -------------------------------------------------------------------------------- /alienbinder8/src/intentfilter.h: -------------------------------------------------------------------------------- 1 | #ifndef INTENTFILTER_H 2 | #define INTENTFILTER_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | 6 | #include 7 | 8 | 9 | class Parcel; 10 | class IntentFilter : public LoggingClassWrapper 11 | { 12 | public: 13 | IntentFilter(Parcel *parcel, const char *loggingCategoryName = LOGGING(IntentFilter)".parcel"); 14 | 15 | QStringList mActions; 16 | QStringList mCategories; 17 | QStringList mDataSchemes; 18 | QStringList mDataTypes; 19 | 20 | // int N = parcel->readInt(); 21 | // if (N > 0) { 22 | // mDataSchemeSpecificParts = new ArrayList(N); 23 | // for (int i=0; ireadInt(); 28 | // if (N > 0) { 29 | // mDataAuthorities = new ArrayList(N); 30 | // for (int i=0; ireadInt(); 35 | // if (N > 0) { 36 | // mDataPaths = new ArrayList(N); 37 | // for (int i=0; ireadInt(); 42 | // mHasPartialTypes = parcel->readInt() > 0; 43 | // setAutoVerify(parcel->readInt() > 0); 44 | // setVisibilityToInstantApp(parcel->readInt()); 45 | }; 46 | 47 | #endif // INTENTFILTER_H 48 | -------------------------------------------------------------------------------- /alienbinder8/src/intentsender.cpp: -------------------------------------------------------------------------------- 1 | #include "intentsender.h" 2 | #include "parcel.h" 3 | 4 | IntentSender::IntentSender(GBinderRemoteObject *target, const char *loggingCategoryName) 5 | : Parcelable(QStringLiteral("android.content.IntentSender")) 6 | , LoggingClassWrapper(loggingCategoryName) 7 | , m_target(target) 8 | { 9 | 10 | } 11 | 12 | IntentSender::IntentSender(const Parcel *parcel, const char *loggingCategoryName) 13 | : Parcelable(QStringLiteral("android.content.IntentSender")) 14 | , LoggingClassWrapper(loggingCategoryName) 15 | { 16 | m_target = parcel->readStrongBinder(); 17 | } 18 | 19 | IntentSender::IntentSender(const IntentSender &other) 20 | : Parcelable(other.creator) 21 | , LoggingClassWrapper(other.logging.categoryName()) 22 | { 23 | m_target = other.target(); 24 | } 25 | 26 | IntentSender::~IntentSender() 27 | { 28 | 29 | } 30 | 31 | GBinderRemoteObject *IntentSender::target() const 32 | { 33 | return m_target; 34 | } 35 | 36 | void IntentSender::writeToParcel(Parcel *parcel) const 37 | { 38 | parcel->writeStrongBinder(m_target); 39 | } 40 | 41 | QDebug operator<<(QDebug dbg, const IntentSender &intentSender) 42 | { 43 | dbg << "IntentSender:" << intentSender.target(); 44 | return dbg.maybeSpace(); 45 | } 46 | -------------------------------------------------------------------------------- /alienbinder8/src/intentsender.h: -------------------------------------------------------------------------------- 1 | #ifndef INTENTSENDER_H 2 | #define INTENTSENDER_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | #include "parcelable.h" 6 | 7 | #include 8 | 9 | class Parcel; 10 | class IntentSender : public Parcelable, public LoggingClassWrapper 11 | { 12 | public: 13 | IntentSender(GBinderRemoteObject *target = nullptr, const char *loggingCategoryName = LOGGING(Intent)".parcel"); 14 | IntentSender(const Parcel *parcel, const char *loggingCategoryName = LOGGING(Intent)".parcel"); 15 | IntentSender(const IntentSender &other); 16 | virtual ~IntentSender(); 17 | 18 | GBinderRemoteObject *target() const; 19 | void writeToParcel(Parcel *parcel) const override; 20 | 21 | private: 22 | GBinderRemoteObject *m_target = nullptr; 23 | }; 24 | 25 | Q_DECLARE_METATYPE(IntentSender) 26 | 27 | QDebug operator<<(QDebug dbg, const IntentSender &intentSender); 28 | 29 | #endif // INTENTSENDER_H 30 | -------------------------------------------------------------------------------- /alienbinder8/src/packageiteminfo.cpp: -------------------------------------------------------------------------------- 1 | #include "packageiteminfo.h" 2 | #include "parcel.h" 3 | 4 | PackageItemInfo::PackageItemInfo(Parcel *parcel, const char *loggingCategoryName) 5 | : LoggingClassWrapper(loggingCategoryName) 6 | { 7 | name = parcel->readString(); 8 | qCDebug(logging) << Q_FUNC_INFO << "Name:" << name; 9 | packageName = parcel->readString(); 10 | qCDebug(logging) << Q_FUNC_INFO << "Package:" << packageName; 11 | 12 | labelRes = parcel->readInt(); 13 | 14 | // TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source) 15 | const int kind = parcel->readInt(); 16 | qCDebug(logging) << Q_FUNC_INFO << "kind:" << kind; 17 | const QString string = parcel->readString(); 18 | qCDebug(logging) << Q_FUNC_INFO << "string:" << string; 19 | 20 | icon = parcel->readInt(); 21 | qCDebug(logging) << Q_FUNC_INFO << "icon:" << icon; 22 | logo = parcel->readInt(); 23 | qCDebug(logging) << Q_FUNC_INFO << "logo:" << logo; 24 | 25 | parcel->readBundle(); // metaData 26 | 27 | banner = parcel->readInt(); 28 | qCDebug(logging) << Q_FUNC_INFO << "banner:" << banner; 29 | showUserIcon = parcel->readInt(); 30 | qCDebug(logging) << Q_FUNC_INFO << "showUserIcon:" << showUserIcon; 31 | } 32 | -------------------------------------------------------------------------------- /alienbinder8/src/packageiteminfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PACKAGEITEMINFO_H 2 | #define PACKAGEITEMINFO_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | 6 | #include 7 | 8 | class Parcel; 9 | class PackageItemInfo : public LoggingClassWrapper 10 | { 11 | public: 12 | PackageItemInfo(Parcel *parcel, const char *loggingCategoryName = LOGGING(PackageItemInfo)".parcel"); 13 | 14 | QString name; 15 | QString packageName; 16 | 17 | int labelRes = -1; 18 | 19 | int icon = -1; 20 | int logo = -1; 21 | int banner = -1; 22 | int showUserIcon = -1; 23 | }; 24 | 25 | #endif // PACKAGEITEMINFO_H 26 | -------------------------------------------------------------------------------- /alienbinder8/src/packagemanager.cpp: -------------------------------------------------------------------------------- 1 | #include "packagemanager.h" 2 | #include "intent.h" 3 | #include "resolveinfo.h" 4 | #include "parcel.h" 5 | 6 | #include 7 | 8 | #define PM_SERVICE_NAME "package" 9 | #define PM_INTERFACE_NAME "android.content.pm.IPackageManager" 10 | 11 | static PackageManager *s_instance = nullptr; 12 | 13 | PackageManager::PackageManager(QObject *parent, const char *loggingCategoryName) 14 | : BinderInterfaceAbstract(PM_SERVICE_NAME, 15 | PM_INTERFACE_NAME, 16 | parent, 17 | loggingCategoryName) 18 | { 19 | 20 | } 21 | 22 | PackageManager::~PackageManager() 23 | { 24 | s_instance = nullptr; 25 | } 26 | 27 | PackageManager *PackageManager::GetInstance() 28 | { 29 | if (!s_instance) { 30 | s_instance = new PackageManager(qApp); 31 | } 32 | return s_instance; 33 | } 34 | 35 | QList > PackageManager::queryIntentActivities(Intent intent) 36 | { 37 | PackageManager *manager = PackageManager::GetInstance(); 38 | qCDebug(manager->logging) << Q_FUNC_INFO << intent.action; 39 | 40 | QList > resolveInfoList; 41 | 42 | QSharedPointer parcel = manager->createTransaction(); 43 | if (!parcel) { 44 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 45 | return resolveInfoList; 46 | } 47 | 48 | parcel->writeInt(1); // const value 49 | intent.writeToParcel(parcel.data()); 50 | parcel->writeString(intent.type); // resolvedType 51 | parcel->writeInt(0); // flags 52 | parcel->writeInt(USER_OWNER); // userId 53 | int status = 0; 54 | QSharedPointer out = manager->sendTransaction(TRANSACTION_queryIntentActivities, parcel, &status); 55 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 56 | const int exception = out->readInt(); 57 | if (exception != 0) { 58 | qCCritical(manager->logging) << Q_FUNC_INFO << "Exception:" << exception; 59 | return resolveInfoList; 60 | } 61 | const int result = out->readInt(); 62 | qCDebug(manager->logging) << Q_FUNC_INFO << "Result:" << result; 63 | if (result != 0) { 64 | const int count = out->readInt(); 65 | qCDebug(manager->logging) << Q_FUNC_INFO << "Count:" << count; 66 | qCDebug(manager->logging) << Q_FUNC_INFO << "Creator:" << out->readString(); 67 | for (int i = 0; i < count; i++) { 68 | const int present = out->readInt(); 69 | qCDebug(manager->logging) << Q_FUNC_INFO << "Present:" << present; 70 | if (present != 0) { 71 | QSharedPointer resolveInfo(new ResolveInfo(out.data())); 72 | resolveInfoList.append(resolveInfo); 73 | } else { 74 | break; 75 | } 76 | } 77 | } 78 | return resolveInfoList; 79 | } 80 | 81 | int PackageManager::getPackageUid(const QString &packageName) 82 | { 83 | PackageManager *manager = PackageManager::GetInstance(); 84 | qCDebug(manager->logging) << Q_FUNC_INFO << packageName; 85 | 86 | int uid = -1; 87 | 88 | QSharedPointer parcel = manager->createTransaction(); 89 | if (!parcel) { 90 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 91 | return uid; 92 | } 93 | 94 | parcel->writeString(packageName); 95 | parcel->writeInt(0); // flags 96 | parcel->writeInt(USER_OWNER); // userId 97 | int status = 0; 98 | QSharedPointer out = manager->sendTransaction(TRANSACTION_getPackageUid, parcel, &status); 99 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 100 | const int exception = out->readInt(); 101 | if (exception != 0) { 102 | qCCritical(manager->logging) << Q_FUNC_INFO << "Exception:" << exception; 103 | return uid; 104 | } 105 | uid = out->readInt(); 106 | qCDebug(manager->logging) << Q_FUNC_INFO << "Result:" << uid; 107 | 108 | return uid; 109 | } 110 | -------------------------------------------------------------------------------- /alienbinder8/src/packagemanager.h: -------------------------------------------------------------------------------- 1 | #ifndef PACKAGEMANAGER_H 2 | #define PACKAGEMANAGER_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | enum { 10 | TRANSACTION_getPackageUid = 5, 11 | TRANSACTION_queryIntentActivities = 45, 12 | }; 13 | 14 | class Intent; 15 | class ResolveInfo; 16 | class PackageManager : public BinderInterfaceAbstract 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit PackageManager(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(PackageManager)".manager"); 21 | virtual ~PackageManager(); 22 | 23 | static PackageManager *GetInstance(); 24 | 25 | static int getPackageUid(const QString &packageName); 26 | static QList > queryIntentActivities(Intent intent); 27 | }; 28 | 29 | #endif // PACKAGEMANAGER_H 30 | -------------------------------------------------------------------------------- /alienbinder8/src/parcel.h: -------------------------------------------------------------------------------- 1 | #ifndef PARCEL_H 2 | #define PARCEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../common/src/loggingclasswrapper.h" 9 | 10 | enum { 11 | StringUri_TYPE_ID = 1 12 | }; 13 | 14 | // Keep in sync with frameworks/base/core/java/android/os/Parcel.java. 15 | enum { 16 | VAL_NULL = -1, 17 | VAL_STRING = 0, 18 | VAL_INTEGER = 1, 19 | VAL_MAP = 2, 20 | VAL_BUNDLE = 3, 21 | VAL_PARCELABLE = 4, 22 | VAL_SHORT = 5, 23 | VAL_LONG = 6, 24 | VAL_DOUBLE = 8, 25 | VAL_BOOLEAN = 9, 26 | VAL_BYTEARRAY = 13, 27 | VAL_STRINGARRAY = 14, 28 | VAL_IBINDER = 15, 29 | VAL_PARCELABLEARRAY = 16, 30 | VAL_INTARRAY = 18, 31 | VAL_LONGARRAY = 19, 32 | VAL_BYTE = 20, 33 | VAL_SERIALIZABLE = 21, 34 | VAL_BOOLEANARRAY = 23, 35 | VAL_PERSISTABLEBUNDLE = 25, 36 | VAL_DOUBLEARRAY = 28, 37 | }; 38 | 39 | enum { 40 | // Keep them in sync with BUNDLE_MAGIC* in frameworks/base/core/java/android/os/BaseBundle.java. 41 | BUNDLE_MAGIC = 0x4C444E42, 42 | BUNDLE_MAGIC_NATIVE = 0x4C444E44, 43 | }; 44 | 45 | class Intent; 46 | class Parcelable; 47 | class Parcel : public LoggingClassWrapper 48 | { 49 | public: 50 | Parcel(GBinderLocalRequest *request); 51 | Parcel(GBinderRemoteReply *reply); 52 | Parcel(GBinderRemoteRequest *remote); 53 | ~Parcel(); 54 | 55 | void writeStrongBinder(GBinderLocalObject *value); 56 | void writeStrongBinder(GBinderRemoteObject *value); 57 | void writeString(const QString &value); 58 | void writeInt(int value); 59 | void writeFloat(float value); 60 | void writeDouble(double value); 61 | void writeInt64(quint64 value); 62 | void writeBundle(const QVariantHash &value); 63 | void writeValue(const QVariant &value); 64 | void writeParcelable(const Parcelable &parcelable); 65 | 66 | int readInt() const; 67 | quint64 readInt64() const; 68 | QString readString() const; 69 | QVariantHash readBundle() const; 70 | qlonglong readLong() const; 71 | bool readBoolean() const; 72 | double readDouble() const; 73 | QStringList readStringList() const; 74 | QList readIntList() const; 75 | QHash readSparseArray() const; 76 | QVariant readValue() const; 77 | float readFloat() const; 78 | GBinderRemoteObject *readStrongBinder() const; 79 | QVariant readParcelable() const; 80 | QVariantList readParcelableArray() const; 81 | 82 | GBinderLocalRequest *request(); 83 | 84 | private: 85 | GBinderLocalRequest *m_request = nullptr; 86 | GBinderRemoteReply *m_reply = nullptr; 87 | GBinderRemoteRequest *m_remote = nullptr; 88 | GBinderWriter *m_writer = nullptr; 89 | GBinderReader *m_reader = nullptr; 90 | }; 91 | 92 | #endif // PARCEL_H 93 | -------------------------------------------------------------------------------- /alienbinder8/src/parcelable.cpp: -------------------------------------------------------------------------------- 1 | #include "parcelable.h" 2 | 3 | Parcelable::Parcelable(const QString &parcelableCreator) 4 | : creator(parcelableCreator) 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /alienbinder8/src/parcelable.h: -------------------------------------------------------------------------------- 1 | #ifndef PARCELABLE_H 2 | #define PARCELABLE_H 3 | 4 | #include 5 | 6 | class Parcel; 7 | class Parcelable 8 | { 9 | public: 10 | Parcelable(const QString &creator); 11 | 12 | QString creator; 13 | 14 | virtual void writeToParcel(Parcel *parcel) const = 0; 15 | }; 16 | 17 | #endif // PARCELABLE_H 18 | -------------------------------------------------------------------------------- /alienbinder8/src/resolveinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "resolveinfo.h" 2 | #include "activityinfo.h" 3 | #include "intentfilter.h" 4 | #include "parcel.h" 5 | 6 | ResolveInfo::ResolveInfo(Parcel *parcel, const char *loggingCategoryName) 7 | : LoggingClassWrapper(loggingCategoryName) 8 | { 9 | typeComponentInfo = parcel->readInt(); 10 | qCDebug(logging) << Q_FUNC_INFO << "Info source:" << typeComponentInfo; 11 | switch (typeComponentInfo) { 12 | case ComponentInfoActivityInfo: 13 | activityInfo = new ActivityInfo(parcel); 14 | qCDebug(logging) << Q_FUNC_INFO << "activityInfo:" << activityInfo; 15 | break; 16 | case ComponentInfoServiceInfo: 17 | break; 18 | case ComponentInfoProviderInfo: 19 | break; 20 | default: 21 | qCritical() << Q_FUNC_INFO << "Missing ComponentInfo!"; 22 | return; 23 | } 24 | 25 | const int haveIntentFilter = parcel->readInt(); 26 | if (haveIntentFilter != 0) { 27 | qCDebug(logging) << Q_FUNC_INFO << "have intent filter!" << haveIntentFilter; 28 | intentFilter = new IntentFilter(parcel); 29 | } 30 | priority = parcel->readInt(); 31 | qCDebug(logging) << Q_FUNC_INFO << "priority:" << priority; 32 | preferredOrder = parcel->readInt(); 33 | qCDebug(logging) << Q_FUNC_INFO << "preferredOrder:" << preferredOrder; 34 | match = parcel->readInt(); 35 | qCDebug(logging) << Q_FUNC_INFO << "match:" << match; 36 | specificIndex = parcel->readInt(); 37 | qCDebug(logging) << Q_FUNC_INFO << "specificIndex:" << specificIndex; 38 | labelRes = parcel->readInt(); 39 | qCDebug(logging) << Q_FUNC_INFO << "labelRes:" << labelRes; 40 | 41 | // TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source) 42 | const int kind = parcel->readInt(); 43 | qCDebug(logging) << Q_FUNC_INFO << "kind:" << kind; 44 | const QString string = parcel->readString(); 45 | qCDebug(logging) << Q_FUNC_INFO << "string:" << string; 46 | 47 | icon = parcel->readInt(); 48 | qCDebug(logging) << Q_FUNC_INFO << "icon:" << icon; 49 | resolvePackageName = parcel->readString(); 50 | qCDebug(logging) << Q_FUNC_INFO << "resolvePackageName:" << resolvePackageName; 51 | targetUserId = parcel->readInt(); 52 | qCDebug(logging) << Q_FUNC_INFO << "targetUserId:" << targetUserId; 53 | system = parcel->readBoolean(); 54 | qCDebug(logging) << Q_FUNC_INFO << "system:" << system; 55 | noResourceId = parcel->readBoolean(); 56 | qCDebug(logging) << Q_FUNC_INFO << "noResourceId:" << noResourceId; 57 | iconResourceId = parcel->readInt(); 58 | qCDebug(logging) << Q_FUNC_INFO << "iconResourceId:" << iconResourceId; 59 | handleAllWebDataURI = parcel->readBoolean(); 60 | qCDebug(logging) << Q_FUNC_INFO << "handleAllWebDataURI:" << handleAllWebDataURI; 61 | instantAppAvailable = parcel->readBoolean(); 62 | qCDebug(logging) << Q_FUNC_INFO << "instantAppAvailable:" << instantAppAvailable; 63 | isInstantAppAvailable = instantAppAvailable; 64 | qCDebug(logging) << Q_FUNC_INFO << "isInstantAppAvailable:" << isInstantAppAvailable; 65 | } 66 | 67 | ResolveInfo::~ResolveInfo() 68 | { 69 | if (activityInfo) { 70 | delete activityInfo; 71 | activityInfo = nullptr; 72 | } 73 | 74 | if (intentFilter) { 75 | delete intentFilter; 76 | intentFilter = nullptr; 77 | } 78 | } 79 | 80 | ComponentInfo *ResolveInfo::getComponentInfo() 81 | { 82 | if (activityInfo) { 83 | return activityInfo; 84 | } 85 | qCritical() << Q_FUNC_INFO << "Missing ComponentInfo for" << resolvePackageName; 86 | return nullptr; 87 | } 88 | -------------------------------------------------------------------------------- /alienbinder8/src/resolveinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef RESOLVEINFO_H 2 | #define RESOLVEINFO_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | 6 | enum { 7 | ComponentInfoActivityInfo = 1, 8 | ComponentInfoServiceInfo, 9 | ComponentInfoProviderInfo, 10 | }; 11 | 12 | class ComponentInfo; 13 | class ActivityInfo; 14 | class IntentFilter; 15 | class Parcel; 16 | class ResolveInfo : public LoggingClassWrapper 17 | { 18 | public: 19 | ResolveInfo(Parcel *parcel, const char *loggingCategoryName = LOGGING(ResolveInfo)".parcel"); 20 | virtual ~ResolveInfo(); 21 | 22 | int typeComponentInfo = 0; 23 | 24 | ComponentInfo *getComponentInfo(); 25 | ActivityInfo *activityInfo = nullptr; 26 | IntentFilter *intentFilter = nullptr; 27 | 28 | int priority = -1; 29 | int preferredOrder = -1; 30 | int match = -1; 31 | int specificIndex = -1; 32 | int labelRes = -1; 33 | 34 | // nonLocalizedLabel 35 | // = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); 36 | 37 | int icon = -1; 38 | QString resolvePackageName; 39 | int targetUserId = -1; 40 | bool system = false; 41 | bool noResourceId = false; 42 | int iconResourceId = -1; 43 | bool handleAllWebDataURI = false; 44 | bool instantAppAvailable = false; 45 | bool isInstantAppAvailable = false; 46 | }; 47 | 48 | #endif // RESOLVEINFO_H 49 | -------------------------------------------------------------------------------- /alienbinder8/src/statusbarmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "statusbarmanager.h" 2 | 3 | #include 4 | 5 | #define SBM_SERVICE_NAME "statusbar" 6 | #define SBM_INTERFACE_NAME "com.android.internal.statusbar.IStatusBarService" 7 | 8 | static StatusBarManager *s_instance = nullptr; 9 | 10 | StatusBarManager::StatusBarManager(QObject *parent, const char *loggingCategoryName) 11 | : BinderInterfaceAbstract(SBM_SERVICE_NAME, 12 | SBM_INTERFACE_NAME, 13 | parent, 14 | loggingCategoryName) 15 | { 16 | 17 | } 18 | 19 | StatusBarManager::~StatusBarManager() 20 | { 21 | s_instance = nullptr; 22 | } 23 | 24 | StatusBarManager *StatusBarManager::GetInstance() 25 | { 26 | if (!s_instance) { 27 | s_instance = new StatusBarManager(qApp); 28 | } 29 | return s_instance; 30 | } 31 | 32 | void StatusBarManager::expand() 33 | { 34 | StatusBarManager *manager = StatusBarManager::GetInstance(); 35 | 36 | QSharedPointer parcel = manager->createTransaction(); 37 | if (!parcel) { 38 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 39 | return; 40 | } 41 | 42 | int status = 0; 43 | manager->sendTransaction(TRANSACTION_expand, parcel, &status); 44 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 45 | } 46 | 47 | void StatusBarManager::collapse() 48 | { 49 | StatusBarManager *manager = StatusBarManager::GetInstance(); 50 | 51 | QSharedPointer parcel = manager->createTransaction(); 52 | if (!parcel) { 53 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 54 | return; 55 | } 56 | 57 | int status = 0; 58 | manager->sendTransaction(TRANSACTION_collapse, parcel, &status); 59 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 60 | } 61 | -------------------------------------------------------------------------------- /alienbinder8/src/statusbarmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef STATUSBARMANAGER_H 2 | #define STATUSBARMANAGER_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | #include "../common/src/loggingclasswrapper.h" 6 | 7 | #include 8 | 9 | enum { 10 | TRANSACTION_expand = 1, 11 | TRANSACTION_collapse = 2, 12 | }; 13 | 14 | 15 | class StatusBarManager : public BinderInterfaceAbstract 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit StatusBarManager(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(PackageManager)".manager"); 20 | virtual ~StatusBarManager(); 21 | 22 | static StatusBarManager *GetInstance(); 23 | 24 | static void expand(); 25 | static void collapse(); 26 | }; 27 | 28 | #endif // STATUSBARMANAGER_H 29 | -------------------------------------------------------------------------------- /alienbinder8/src/windowlayout.cpp: -------------------------------------------------------------------------------- 1 | #include "parcel.h" 2 | #include "windowlayout.h" 3 | 4 | WindowLayout::WindowLayout(Parcel *parcel ,const char *loggingCategoryName) 5 | : LoggingClassWrapper(loggingCategoryName) 6 | { 7 | width = parcel->readInt(); 8 | qCDebug(logging) << Q_FUNC_INFO << "width:" << width; 9 | widthFraction = parcel->readFloat(); 10 | qCDebug(logging) << Q_FUNC_INFO << "widthFraction:" << widthFraction; 11 | height = parcel->readInt(); 12 | qCDebug(logging) << Q_FUNC_INFO << "height:" << height; 13 | heightFraction = parcel->readFloat(); 14 | qCDebug(logging) << Q_FUNC_INFO << "heightFraction:" << heightFraction; 15 | gravity = parcel->readInt(); 16 | qCDebug(logging) << Q_FUNC_INFO << "gravity:" << gravity; 17 | minWidth = parcel->readInt(); 18 | qCDebug(logging) << Q_FUNC_INFO << "minWidth:" << minWidth; 19 | minHeight = parcel->readInt(); 20 | qCDebug(logging) << Q_FUNC_INFO << "minHeight:" << minHeight; 21 | } 22 | -------------------------------------------------------------------------------- /alienbinder8/src/windowlayout.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOWLAYOUT_H 2 | #define WINDOWLAYOUT_H 3 | 4 | #include "../common/src/loggingclasswrapper.h" 5 | 6 | class Parcel; 7 | class WindowLayout : public LoggingClassWrapper 8 | { 9 | public: 10 | WindowLayout(Parcel *parcel, const char *loggingCategoryName = LOGGING(WindowLayout)".parcel"); 11 | 12 | int width = -1; 13 | float widthFraction = -1; 14 | int height = -1; 15 | float heightFraction = -1; 16 | int gravity = -1; 17 | int minWidth = -1; 18 | int minHeight = -1; 19 | }; 20 | 21 | #endif // WINDOWLAYOUT_H 22 | -------------------------------------------------------------------------------- /alienbinder8/src/windowmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "parcel.h" 2 | #include "windowmanager.h" 3 | 4 | #include 5 | #include 6 | 7 | #define WM_SERVICE_NAME "window" 8 | #define WM_INTERFACE_NAME "android.view.IWindowManager" 9 | 10 | static WindowManager *s_instance = nullptr; 11 | 12 | WindowManager::WindowManager(QObject *parent, const char *loggingCategoryName) 13 | : BinderInterfaceAbstract(WM_SERVICE_NAME, 14 | WM_INTERFACE_NAME, 15 | parent, 16 | loggingCategoryName) 17 | { 18 | 19 | } 20 | 21 | WindowManager::~WindowManager() 22 | { 23 | if (s_instance == this) { 24 | s_instance = nullptr; 25 | } 26 | } 27 | 28 | WindowManager *WindowManager::GetInstance() 29 | { 30 | if (!s_instance) { 31 | s_instance = new WindowManager(qApp); 32 | } 33 | return s_instance; 34 | } 35 | 36 | void WindowManager::setOverscan(int displayId, int left, int top, int right, int bottom) 37 | { 38 | WindowManager *manager = WindowManager::GetInstance(); 39 | qCDebug(manager->logging) << Q_FUNC_INFO << displayId << left << top << right << bottom; 40 | 41 | QSharedPointer parcel = manager->createTransaction(); 42 | if (!parcel) { 43 | qCCritical(manager->logging) << Q_FUNC_INFO << "Null Parcel!"; 44 | return; 45 | } 46 | 47 | parcel->writeInt(displayId); 48 | parcel->writeInt(left); 49 | parcel->writeInt(top); 50 | parcel->writeInt(right); 51 | parcel->writeInt(bottom); 52 | int status = 0; 53 | manager->sendTransaction(TRANSACTION_setOverscan, parcel, &status); 54 | qCDebug(manager->logging) << Q_FUNC_INFO << "Status:" << status; 55 | } 56 | -------------------------------------------------------------------------------- /alienbinder8/src/windowmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOWMANAGER_H 2 | #define WINDOWMANAGER_H 3 | 4 | #include "binderinterfaceabstract.h" 5 | 6 | enum { 7 | TRANSACTION_setOverscan = 15, 8 | }; 9 | 10 | class WindowManager : public BinderInterfaceAbstract 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit WindowManager(QObject *parent = nullptr, const char *loggingCategoryName = LOGGING(WindowManager)".manager"); 15 | virtual ~WindowManager(); 16 | 17 | static WindowManager *GetInstance(); 18 | 19 | static void setOverscan(int displayId, int left, int top, int right, int bottom); 20 | }; 21 | 22 | #endif // WINDOWMANAGER_H 23 | -------------------------------------------------------------------------------- /alienchroot/alienchroot.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | QT = core dbus network 4 | CONFIG += plugin 5 | 6 | HEADERS += \ 7 | ../common/src/alienabstract.h \ 8 | ../common/src/aliendalvikcontroller.h \ 9 | ../common/src/loggingclasswrapper.h \ 10 | ../common/src/systemdcontroller.h \ 11 | src/alienchroot.h 12 | 13 | SOURCES += \ 14 | ../common/src/alienabstract.cpp \ 15 | ../common/src/aliendalvikcontroller.cpp \ 16 | ../common/src/loggingclasswrapper.cpp \ 17 | ../common/src/systemdcontroller.cpp \ 18 | src/alienchroot.cpp 19 | 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII 22 | 23 | EXTRA_CFLAGS=-W -Wall -Wextra -Wpedantic -Werror 24 | QMAKE_CXXFLAGS += $$EXTRA_CFLAGS 25 | QMAKE_CFLAGS += $$EXTRA_CFLAGS 26 | 27 | TARGET = aliendalvikcontrolplugin-chroot 28 | target.path = /usr/lib 29 | 30 | INSTALLS = target 31 | -------------------------------------------------------------------------------- /alienchroot/src/alienchroot.h: -------------------------------------------------------------------------------- 1 | #ifndef ALIENCHROOT_H 2 | #define ALIENCHROOT_H 3 | 4 | #include "../common/src/alienabstract.h" 5 | 6 | #include 7 | 8 | class AlienChroot : public AlienAbstract 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit AlienChroot(QObject *parent = nullptr); 13 | 14 | public slots: 15 | QString dataPath() const override; 16 | 17 | void sendKeyevent(int code, quint64) override; 18 | void sendInput(const QString &text) override; 19 | void sendTap(int posx, int posy, quint64 uptime) override; 20 | void sendSwipe(int startx, int starty, int endx, int endy, int duration) override; 21 | void uriActivity(const QString &uri) override; 22 | void uriActivitySelector(const QString &uri) override; 23 | void hideNavBar(int height, int api) override; 24 | void showNavBar(int api) override; 25 | void hideStatusBar() override; 26 | void showStatusBar() override; 27 | void openDownloads() override; 28 | void openSettings() override; 29 | void openContacts() override; 30 | void openCamera() override; 31 | void openGallery() override; 32 | void openAppSettings(const QString &) override; 33 | void launchApp(const QString &packageName) override; 34 | void componentActivity(const QString &package, const QString &className, const QString &data) override; 35 | void forceStop(const QString &packageName) override; 36 | void shareFile(const QString &filename, const QString &mimetype) override; 37 | void shareText(const QString &text) override; 38 | void doShare(const QString &mimetype, const QString &filename, const QString &data, const QString &packageName, const QString &className, const QString &launcherClass) override; 39 | QVariantList getImeList() override; 40 | void triggerImeMethod(const QString &ime, bool enable) override; 41 | void setImeMethod(const QString &ime) override; 42 | QString getSettings(const QString &nspace, const QString &key) override; 43 | void putSettings(const QString &nspace, const QString &key, const QString &value) override; 44 | QString getprop(const QString &key) override; 45 | void setprop(const QString &key, const QString &value) override; 46 | 47 | void requestDeviceInfo() override; 48 | void requestUptime() override; 49 | 50 | QString checkShareFile(const QString &shareFilePath); 51 | 52 | void installApk(const QString &fileName) override; 53 | 54 | private: 55 | void runCommand(const QString &program, const QStringList ¶ms); 56 | QString runCommandOutput(const QString &program, const QStringList ¶ms); 57 | 58 | QProcessEnvironment m_alienEnvironment; 59 | 60 | private slots: 61 | void serviceStopped() override; 62 | void serviceStarted() override; 63 | 64 | }; 65 | 66 | #endif // ALIENCHROOT_H 67 | -------------------------------------------------------------------------------- /aliendalvik-control-selector.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | import Sailfish.Silica.private 1.0 4 | import Nemo.DBus 2.0 5 | import Nemo.Configuration 1.0 6 | 7 | MouseArea 8 | { 9 | id: root 10 | 11 | width: Screen.width 12 | height: Screen.height 13 | 14 | property string url 15 | 16 | onClicked: { 17 | Qt.quit() 18 | } 19 | 20 | ConfigurationGroup { 21 | id: config 22 | path: "/org/coderus/aliendalvikcontrol/selector" 23 | property int windowPosX: -1 24 | property int windowPosY: -1 25 | } 26 | 27 | Wallpaper { 28 | id: bg 29 | x: config.windowPosX >= 0 ? config.windowPosX : (root.width - bg.width) / 2 30 | y: config.windowPosY >= 0 ? config.windowPosY : (root.height - bg.height) / 2 31 | width: parent.width - Theme.horizontalPageMargin * 2 32 | height: Math.min(Theme.itemSizeMedium * 5, contentView.contentHeight) 33 | clip: true 34 | blending: true 35 | 36 | Rectangle { 37 | anchors.fill: parent 38 | border.width: 1 39 | border.color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) 40 | color: "transparent" 41 | } 42 | 43 | SilicaListView { 44 | id: contentView 45 | anchors.fill: parent 46 | header: Component { 47 | MouseArea { 48 | width: parent.width 49 | height: Theme.itemSizeMedium 50 | 51 | drag.minimumX: 0 52 | drag.maximumX: root.width - bg.width 53 | drag.minimumY: 0 54 | drag.maximumY: root.height - Theme.itemSizeMedium * 5 55 | 56 | onPressAndHold: { 57 | drag.target = bg 58 | } 59 | 60 | onReleased: { 61 | drag.target = undefined 62 | config.windowPosX = bg.x 63 | config.windowPosY = bg.y 64 | console.log("### saving posx:", config.windowPosX, "posy:", config.windowPosY) 65 | } 66 | 67 | onCanceled: { 68 | drag.target = undefined 69 | } 70 | 71 | Column { 72 | width: parent.width 73 | anchors.centerIn: parent 74 | 75 | Label { 76 | anchors.horizontalCenter: parent.horizontalCenter 77 | text: "Open url with" 78 | } 79 | 80 | Label { 81 | anchors.left: parent.left 82 | anchors.right: parent.right 83 | anchors.margins: Theme.horizontalPageMargin 84 | truncationMode: TruncationMode.Fade 85 | text: root.url 86 | font.pixelSize: Theme.fontSizeSmall 87 | color: Theme.secondaryColor 88 | } 89 | } 90 | } 91 | } 92 | delegate: Component { 93 | BackgroundItem { 94 | id: content 95 | width: ListView.view.width 96 | 97 | Image { 98 | id: icon 99 | anchors.left: parent.left 100 | anchors.leftMargin: Theme.horizontalPageMargin 101 | anchors.verticalCenter: parent.verticalCenter 102 | sourceSize.width: Theme.itemSizeSmall - Theme.paddingMedium 103 | sourceSize.height: Theme.itemSizeSmall - Theme.paddingMedium 104 | source: "data:image/png;base64," + modelData.icon 105 | } 106 | 107 | Label { 108 | anchors.left: icon.right 109 | anchors.leftMargin: Theme.paddingMedium 110 | anchors.right: parent.right 111 | anchors.rightMargin: Theme.horizontalPageMargin 112 | anchors.verticalCenter: parent.verticalCenter 113 | text: modelData.prettyName 114 | color: content.highlighted ? Theme.highlightColor : Theme.primaryColor 115 | } 116 | 117 | onClicked: { 118 | console.log("###", modelData.packageName) 119 | control.call("uriLaunchActivity", [modelData.packageName, modelData.className, modelData.launcherClass, modelData.data]) 120 | 121 | Qt.quit() 122 | } 123 | } 124 | } 125 | VerticalScrollDecorator {} 126 | } 127 | } 128 | 129 | DBusAdaptor { 130 | id: adaptor 131 | bus: DBus.SessionBus 132 | service: "org.coderus.aliendalvikselector" 133 | path: "/" 134 | iface: "org.coderus.aliendalvikselector" 135 | 136 | xml: ' \n' + 137 | ' \n' + 138 | ' ' + 139 | ' ' + 140 | ' \n' + 141 | ' \n' 142 | 143 | function openUrl(url, candidates) { 144 | root.url = url 145 | contentView.model = candidates 146 | } 147 | } 148 | 149 | DBusInterface { 150 | id: control 151 | bus: DBus.SystemBus 152 | service: "org.coderus.aliendalvikcontrol" 153 | path: "/" 154 | iface: "org.coderus.aliendalvikcontrol" 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /aliendalvik-control.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | proxy \ 4 | alienchroot \ 5 | alienbinder8 \ 6 | daemon \ 7 | selector \ 8 | share \ 9 | shareui \ 10 | icons \ 11 | # edge \ 12 | # SUBDIRS end 13 | 14 | daemon.depends = \ 15 | alienchroot \ 16 | alienbinder8 17 | 18 | OTHER_FILES += \ 19 | rpm/aliendalvik-control.spec 20 | -------------------------------------------------------------------------------- /common/src/alienabstract.cpp: -------------------------------------------------------------------------------- 1 | #include "alienabstract.h" 2 | 3 | AlienAbstract::AlienAbstract(QObject *parent) 4 | : AliendalvikController(parent) 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /common/src/alienabstract.h: -------------------------------------------------------------------------------- 1 | #ifndef ALIENABSTRACT_H 2 | #define ALIENABSTRACT_H 3 | 4 | #include "aliendalvikcontroller.h" 5 | 6 | #include 7 | #include 8 | 9 | class AlienAbstract : public AliendalvikController 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit AlienAbstract(QObject *parent = nullptr); 14 | 15 | public slots: 16 | virtual QString dataPath() const = 0; 17 | 18 | virtual void sendKeyevent(int code, quint64 uptime) = 0; 19 | virtual void sendInput(const QString &text) = 0; 20 | virtual void sendTap(int posx, int posy, quint64 uptime) = 0; 21 | virtual void sendSwipe(int startx, int starty, int endx, int endy, int duration) = 0; 22 | virtual void uriActivity(const QString &uri) = 0; 23 | virtual void uriActivitySelector(const QString &uri) = 0; 24 | virtual void hideNavBar(int height, int api = 0) = 0; 25 | virtual void showNavBar(int api = 0) = 0; 26 | virtual void hideStatusBar() = 0; 27 | virtual void showStatusBar() = 0; 28 | virtual void openDownloads() = 0; 29 | virtual void openSettings() = 0; 30 | virtual void openContacts() = 0; 31 | virtual void openCamera() = 0; 32 | virtual void openGallery() = 0; 33 | virtual void openAppSettings(const QString &package) = 0; 34 | virtual void launchApp(const QString &packageName) = 0; 35 | virtual void componentActivity(const QString &package, const QString &className, const QString &data = QString()) = 0; 36 | virtual void forceStop(const QString &packageName) = 0; 37 | virtual void shareFile(const QString &filename, const QString &mimetype) = 0; 38 | virtual void shareText(const QString &text) = 0; 39 | virtual void doShare(const QString &mimetype, 40 | const QString &filename, 41 | const QString &data, 42 | const QString &packageName, 43 | const QString &className, 44 | const QString &launcherClass) = 0; 45 | virtual QVariantList getImeList() = 0; 46 | virtual void triggerImeMethod(const QString &ime, bool enable) = 0; 47 | virtual void setImeMethod(const QString &ime) = 0; 48 | virtual QString getSettings(const QString &nspace, const QString &key) = 0; 49 | virtual void putSettings(const QString &nspace, const QString &key, const QString &value) = 0; 50 | virtual QString getprop(const QString &key) = 0; 51 | virtual void setprop(const QString &key, const QString &value) = 0; 52 | 53 | virtual void requestDeviceInfo() = 0; 54 | virtual void requestUptime() = 0; 55 | 56 | virtual QString checkShareFile(const QString &shareFilePath) = 0; 57 | 58 | virtual void installApk(const QString &fileName) = 0; 59 | }; 60 | 61 | #endif // ALIENABSTRACT_H 62 | -------------------------------------------------------------------------------- /common/src/aliendalvikcontroller.cpp: -------------------------------------------------------------------------------- 1 | #include "aliendalvikcontroller.h" 2 | #include "systemdcontroller.h" 3 | 4 | #include 5 | 6 | #define s_newBinderDevice "/dev/puddlejumper" 7 | 8 | AliendalvikController::AliendalvikController(QObject *parent) 9 | : QObject(parent) 10 | , m_controller(SystemdController::GetInstance(QStringLiteral("aliendalvik.service"))) 11 | { 12 | connect(m_controller, &SystemdController::serviceStarted, this, &AliendalvikController::serviceStarted); 13 | connect(m_controller, &SystemdController::serviceStopped, this, &AliendalvikController::serviceStopped); 14 | if (isServiceActive()) { 15 | QTimer::singleShot(0, this, &AliendalvikController::serviceStarted); 16 | } 17 | } 18 | 19 | const char *AliendalvikController::binderDevice() const 20 | { 21 | return s_newBinderDevice; 22 | } 23 | 24 | bool AliendalvikController::isServiceActive() const 25 | { 26 | if (!m_controller) { 27 | return false; 28 | } 29 | 30 | return m_controller->isActive(); 31 | } 32 | 33 | SystemdController *AliendalvikController::controller() const 34 | { 35 | return m_controller; 36 | } 37 | -------------------------------------------------------------------------------- /common/src/aliendalvikcontroller.h: -------------------------------------------------------------------------------- 1 | #ifndef ALIENDALVIKCONTROLLER_H 2 | #define ALIENDALVIKCONTROLLER_H 3 | 4 | #include 5 | 6 | class SystemdController; 7 | class AliendalvikController : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit AliendalvikController(QObject *parent = nullptr); 12 | 13 | const char *binderDevice() const; 14 | 15 | bool isServiceActive() const; 16 | SystemdController *controller() const; 17 | 18 | private: 19 | SystemdController *m_controller = nullptr; 20 | 21 | private slots: 22 | virtual void serviceStopped() = 0; 23 | virtual void serviceStarted() = 0; 24 | }; 25 | 26 | #endif // ALIENDALVIKCONTROLLER_H 27 | -------------------------------------------------------------------------------- /common/src/loggingclasswrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "loggingclasswrapper.h" 2 | 3 | LoggingClassWrapper::LoggingClassWrapper(const char *category, QtMsgType type) 4 | : logging(category, type) 5 | { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /common/src/loggingclasswrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGINGCLASSWRAPPER_H 2 | #define LOGGINGCLASSWRAPPER_H 3 | 4 | #include 5 | 6 | #define LOGGING(x) "logging"#x 7 | 8 | class LoggingClassWrapper 9 | { 10 | public: 11 | LoggingClassWrapper(const char *category, QtMsgType type = QtWarningMsg); 12 | 13 | QLoggingCategory logging; 14 | }; 15 | 16 | #endif // LOGGINGCLASSWRAPPER_H 17 | -------------------------------------------------------------------------------- /common/src/systemdcontroller.cpp: -------------------------------------------------------------------------------- 1 | #include "systemdcontroller.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | static const QString s_serviceName = QStringLiteral("org.freedesktop.systemd1"); 12 | static const QString s_servicePath = QStringLiteral("/org/freedesktop/systemd1"); 13 | 14 | static const QString s_getMethod = QStringLiteral("Get"); 15 | static const QString s_getUnitMethod = QStringLiteral("GetUnit"); 16 | 17 | static const QString s_propertiesSignal = QStringLiteral("PropertiesChanged"); 18 | 19 | static const QString s_propertiesIface = QStringLiteral("org.freedesktop.DBus.Properties"); 20 | static const QString s_unitIface = QStringLiteral("org.freedesktop.systemd1.Unit"); 21 | static const QString s_managerIface = QStringLiteral("org.freedesktop.systemd1.Manager"); 22 | 23 | static const QString s_propertyActiveState = QStringLiteral("ActiveState"); 24 | 25 | static const QString s_valueStateActive = QStringLiteral("active"); 26 | static const QString s_valueStateDeactivating = QStringLiteral("deactivating"); 27 | 28 | static QHash s_instances; 29 | 30 | SystemdController::SystemdController(const QString &unit, QObject *parent) 31 | : QObject(parent) 32 | , m_unit(unit) 33 | { 34 | qDebug() << Q_FUNC_INFO << m_unit; 35 | 36 | QDBusMessage msg = QDBusMessage::createMethodCall( 37 | s_serviceName, 38 | s_servicePath, 39 | s_managerIface, 40 | s_getUnitMethod); 41 | msg.setArguments({m_unit}); 42 | QDBusPendingReply msgPending = QDBusConnection::systemBus().asyncCall(msg); 43 | QDBusPendingCallWatcher *msgWatcher = new QDBusPendingCallWatcher(msgPending); 44 | connect(msgWatcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *watcher){ 45 | watcher->deleteLater(); 46 | QDBusPendingReply reply = *watcher; 47 | if (reply.isError()) { 48 | qWarning() << Q_FUNC_INFO << reply.error().message(); 49 | return; 50 | } 51 | const QDBusObjectPath objectPath = reply.value(); 52 | m_path = objectPath.path(); 53 | qDebug() << Q_FUNC_INFO << "Resolved" << m_unit << "to" << m_path; 54 | connectProperties(); 55 | getActiveState(); 56 | }); 57 | } 58 | 59 | SystemdController::~SystemdController() 60 | { 61 | qDebug() << Q_FUNC_INFO << m_unit; 62 | 63 | if (s_instances.contains(m_unit)) { 64 | s_instances.remove(m_unit); 65 | } 66 | } 67 | 68 | SystemdController *SystemdController::GetInstance(const QString &unit) 69 | { 70 | qDebug() << Q_FUNC_INFO << unit; 71 | 72 | if (s_instances.contains(unit)) { 73 | return s_instances.value(unit); 74 | } 75 | 76 | SystemdController *instance = new SystemdController(unit, qApp); 77 | s_instances.insert(unit, instance); 78 | return instance; 79 | } 80 | 81 | bool SystemdController::isActive() const 82 | { 83 | return m_activeState == s_valueStateActive; 84 | } 85 | 86 | void SystemdController::propertiesChanged(const QString &, const QVariantMap &properties, const QStringList &) 87 | { 88 | const QString activeState = properties.value(s_propertyActiveState, QString()).toString(); 89 | setActiveState(activeState); 90 | } 91 | 92 | void SystemdController::getActiveState() 93 | { 94 | if (m_path.isEmpty()) { 95 | qWarning() << Q_FUNC_INFO << "Object path is empty!"; 96 | return; 97 | } 98 | 99 | QDBusMessage msg = QDBusMessage::createMethodCall( 100 | s_serviceName, 101 | m_path, 102 | s_propertiesIface, 103 | s_getMethod); 104 | msg.setArguments({s_unitIface, s_propertyActiveState}); 105 | QDBusPendingReply msgPending = QDBusConnection::systemBus().asyncCall(msg); 106 | QDBusPendingCallWatcher *msgWatcher = new QDBusPendingCallWatcher(msgPending); 107 | connect(msgWatcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *watcher){ 108 | watcher->deleteLater(); 109 | QDBusPendingReply reply = *watcher; 110 | if (reply.isError()) { 111 | qWarning() << Q_FUNC_INFO << reply.error().message(); 112 | return; 113 | } 114 | const QString activeState = reply.value().toString(); 115 | qDebug() << Q_FUNC_INFO << "ActiveState:" << activeState; 116 | setActiveState(activeState, true); 117 | }); 118 | } 119 | 120 | void SystemdController::setActiveState(const QString &activeState, bool init) 121 | { 122 | if (m_activeState == activeState) { 123 | return; 124 | } 125 | if (activeState.isEmpty() || activeState.isNull()) { 126 | return; 127 | } 128 | m_activeState = activeState; 129 | if (m_activeState == s_valueStateActive) { 130 | emit serviceStarted(); 131 | } else if (m_activeState == s_valueStateDeactivating && !init) { 132 | emit serviceStopped(); 133 | } 134 | } 135 | 136 | void SystemdController::connectProperties() 137 | { 138 | if (m_path.isEmpty()) { 139 | qWarning() << Q_FUNC_INFO << "Object path is empty!"; 140 | return; 141 | } 142 | 143 | bool ok = 144 | QDBusConnection::systemBus().connect( 145 | QString(), 146 | m_path, 147 | s_propertiesIface, 148 | s_propertiesSignal, 149 | this, 150 | SLOT(propertiesChanged(QString, QVariantMap, QStringList))); 151 | qDebug() << Q_FUNC_INFO << "Signal conncted" << s_propertiesSignal << ok; 152 | } 153 | -------------------------------------------------------------------------------- /common/src/systemdcontroller.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMDCONTROLLER_H 2 | #define SYSTEMDCONTROLLER_H 3 | 4 | #include 5 | 6 | class SystemdController : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit SystemdController( 11 | const QString &unit, 12 | QObject *parent = nullptr); 13 | virtual ~SystemdController(); 14 | 15 | static SystemdController *GetInstance(const QString &unit); 16 | bool isActive() const; 17 | 18 | signals: 19 | void serviceStopped(); 20 | void serviceStarted(); 21 | 22 | private slots: 23 | void propertiesChanged(const QString &, const QVariantMap &properties, const QStringList &); 24 | 25 | private: 26 | void connectProperties(); 27 | void getActiveState(); 28 | 29 | void setActiveState(const QString &activeState, bool init = false); 30 | 31 | QString m_activeState; 32 | QString m_path; 33 | QString m_unit; 34 | }; 35 | 36 | #endif // SYSTEMDCONTROLLER_H 37 | -------------------------------------------------------------------------------- /daemon/daemon.pro: -------------------------------------------------------------------------------- 1 | TARGET = aliendalvik-control 2 | target.path = /usr/bin 3 | 4 | INSTALLS += target 5 | 6 | QT += dbus network 7 | 8 | DEFINES += RPM_VERSION=\\\"$$RPM_VERSION\\\" 9 | DEFINES += HELPER_VERSION=\\\"$$HELPER_VERSION\\\" 10 | 11 | SOURCES += \ 12 | src/main.cpp \ 13 | src/dbusservice.cpp \ 14 | src/inotifywatcher.cpp \ 15 | ../common/src/aliendalvikcontroller.cpp \ 16 | ../common/src/systemdcontroller.cpp 17 | 18 | HEADERS += \ 19 | src/dbusservice.h \ 20 | src/inotifywatcher.h \ 21 | ../common/src/aliendalvikcontroller.h \ 22 | ../common/src/systemdcontroller.h 23 | 24 | DEFINES += QT_DEPRECATED_WARNINGS 25 | DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII 26 | 27 | EXTRA_CFLAGS=-W -Wall -Wextra -Wpedantic -Werror 28 | QMAKE_CXXFLAGS += $$EXTRA_CFLAGS 29 | QMAKE_CFLAGS += $$EXTRA_CFLAGS 30 | 31 | dbus.files = dbus/org.coderus.aliendalvikcontrol.service 32 | dbus.path = /usr/share/dbus-1/system-services/ 33 | 34 | INSTALLS += dbus 35 | 36 | dbusConf.files = dbus/org.coderus.aliendalvikcontrol.conf 37 | dbusConf.path = /etc/dbus-1/system.d/ 38 | 39 | INSTALLS += dbusConf 40 | 41 | desktop.files = \ 42 | desktop/android-open-url.desktop \ 43 | desktop/android-open-url-selector.desktop 44 | desktop.path = /usr/share/applications 45 | 46 | INSTALLS += desktop 47 | 48 | systemd.files = \ 49 | systemd/aliendalvik-control.service 50 | systemd.path = /lib/systemd/system/ 51 | 52 | INSTALLS += systemd 53 | 54 | settingsjson.files = settings/aliendalvikcontrol.json 55 | settingsjson.path = /usr/share/jolla-settings/entries 56 | 57 | INSTALLS += settingsjson 58 | 59 | settingsqml.files = \ 60 | settings/main.qml \ 61 | settings/NavbarToggle.qml 62 | settingsqml.path = /usr/share/jolla-settings/pages/aliendalvikcontrol 63 | 64 | INSTALLS += settingsqml 65 | 66 | apk.files = apk/app-release.apk 67 | apk.path = /usr/share/aliendalvik-control/apk 68 | 69 | INSTALLS += apk 70 | 71 | env.files = environment/10-debug.conf 72 | env.path = /var/lib/environment/aliendalvik-control 73 | 74 | INSTALLS += env 75 | 76 | ad_dbus_adaptor.files = ../dbus/org.coderus.aliendalvikcontrol.xml 77 | ad_dbus_adaptor.source_flags = -c DBusAdaptor 78 | ad_dbus_adaptor.header_flags = -c DBusAdaptor 79 | DBUS_ADAPTORS += ad_dbus_adaptor 80 | -------------------------------------------------------------------------------- /daemon/dbus/org.coderus.aliendalvikcontrol.conf: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /daemon/dbus/org.coderus.aliendalvikcontrol.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.coderus.aliendalvikcontrol 3 | Interface=org.coderus.aliendalvikcontrol 4 | Exec=/bin/false 5 | User=root 6 | SystemdService=aliendalvik-control.service 7 | -------------------------------------------------------------------------------- /daemon/desktop/android-open-url-selector.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Android open url selector 4 | Icon=icon-m-share-aliendalvik 5 | NotShowIn=X-MeeGo; 6 | MimeType=x-maemo-urischeme/http;x-maemo-urischeme/https; 7 | X-Maemo-Service=org.coderus.aliendalvikcontrol 8 | X-Maemo-Object-Path=/urlHandler 9 | X-Maemo-Method=org.coderus.aliendalvikcontrol.openSelector 10 | -------------------------------------------------------------------------------- /daemon/desktop/android-open-url.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Android open url 4 | Icon=icon-m-share-aliendalvik 5 | NotShowIn=X-MeeGo; 6 | MimeType=x-maemo-urischeme/http;x-maemo-urischeme/https; 7 | X-Maemo-Service=org.coderus.aliendalvikcontrol 8 | X-Maemo-Object-Path=/urlHandler 9 | X-Maemo-Method=org.coderus.aliendalvikcontrol.open 10 | -------------------------------------------------------------------------------- /daemon/environment/10-debug.conf: -------------------------------------------------------------------------------- 1 | QT_LOGGING_RULES="*.debug=true" 2 | -------------------------------------------------------------------------------- /daemon/settings/NavbarToggle.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | import Nemo.DBus 2.0 4 | import com.jolla.settings 1.0 5 | 6 | SettingsToggle { 7 | id: root 8 | 9 | property int apiVersion: 0 10 | 11 | DBusInterface { 12 | id: dbus 13 | 14 | bus: DBus.SystemBus 15 | service: "org.coderus.aliendalvikcontrol" 16 | path: "/" 17 | iface: "org.coderus.aliendalvikcontrol" 18 | 19 | Component.onCompleted: { 20 | dbus.typedCall("getApiVersion", [], 21 | function(result) { 22 | console.log("Api version:", result) 23 | apiVersion = result 24 | }) 25 | } 26 | } 27 | 28 | name: "NavBar" 29 | icon.source: "image://theme/icon-m-aliendalvik-back" + (apiVersion <= 19 ? "4" : "8") 30 | checked: true 31 | 32 | onToggled: { 33 | checked = !checked 34 | if (checked) { 35 | dbus.typedCall("showNavBar", []) 36 | } else { 37 | dbus.typedCall("hideNavBar", []) 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /daemon/settings/aliendalvikcontrol.json: -------------------------------------------------------------------------------- 1 | { 2 | "translation_catalog": "settings-system", 3 | "entries": [ 4 | { 5 | "path": "system_settings/look_and_feel/aliendalvikcontrol", 6 | "title": "Aliendalvik Control", 7 | "type": "page", 8 | "icon": "image://theme/icon-m-aliendalvikcontrol", 9 | "order": 1000, 10 | "params": { 11 | "source": "/usr/share/jolla-settings/pages/aliendalvikcontrol/main.qml" 12 | } 13 | }, 14 | { 15 | "path": "system_settings/look_and_feel/aliendalvikcontrol/toggle_navbar", 16 | "title": "Toggle android navbar", 17 | "type": "custom", 18 | "icon": "image://theme/icon-m-aliendalvik-back8", 19 | "params": { 20 | "source": "/usr/share/jolla-settings/pages/aliendalvikcontrol/NavbarToggle.qml", 21 | "type": "grid" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /daemon/src/dbusservice.h: -------------------------------------------------------------------------------- 1 | #ifndef DBUSSERVICE_H 2 | #define DBUSSERVICE_H 3 | 4 | #include "../common/src/aliendalvikcontroller.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | class DBusAdaptor; 18 | class INotifyWatcher; 19 | class QLocalServer; 20 | class QLocalSocket; 21 | class QTimer; 22 | class AlienAbstract; 23 | class DBusService : public AliendalvikController, public QDBusContext 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit DBusService(QObject *parent = nullptr); 29 | virtual ~DBusService(); 30 | 31 | public slots: 32 | void start(); 33 | 34 | signals: 35 | void isTopmostAndroidChanged(bool isAndroid); 36 | 37 | private slots: 38 | int getApiVersion(); 39 | int guessApiVersion(); 40 | 41 | void sendKeyevent(int code); 42 | void sendInput(const QString &text); 43 | void sendTap(int posx, int posy); 44 | void sendSwipe(int startx, int starty, int endx, int endy, int duration); 45 | void uriActivity(const QString &uri); 46 | void uriActivitySelector(const QString &uri); 47 | void hideNavBar(); 48 | void showNavBar(); 49 | void hideStatusBar(); 50 | void showStatusBar(); 51 | void openDownloads(); 52 | void openSettings(); 53 | void openContacts(); 54 | void openCamera(); 55 | void openGallery(); 56 | void openAppSettings(const QString &package); 57 | void launchApp(const QString &packageName); 58 | void launcherActivity(const QString &package, const QString &className, const QString &data = QString()); 59 | void componentActivity(const QString &package, const QString &className, const QString &data = QString()); 60 | void uriLaunchActivity(const QString &package, const QString &className, const QString &launcherClass, const QString &data = QString()); 61 | void forceStop(const QString &packageName); 62 | void shareContent(const QVariantMap &content, const QString &source); 63 | void shareFile(const QString &filename, const QString &mimetype); 64 | void shareText(const QString &text); 65 | void doShare(const QString &mimetype, 66 | const QString &filename, 67 | const QString &data, 68 | const QString &packageName, 69 | const QString &className, 70 | const QString &launcherClass); 71 | QString getFocusedApp(); 72 | bool isTopmostAndroid(); 73 | void getImeList(); 74 | void triggerImeMethod(const QString &ime, bool enable); 75 | void setImeMethod(const QString &ime); 76 | QString getSettings(const QString &nspace, const QString &key); 77 | void putSettings(const QString &nspace, const QString &key, const QString &value); 78 | QString getprop(const QString &key); 79 | void setprop(const QString &key, const QString &value); 80 | void quit(); 81 | 82 | void startReadingLocalServer(); 83 | void processHelperResult(const QByteArray &data); 84 | 85 | private: 86 | friend class DBusAdaptor; 87 | 88 | void checkHelperSocket(); 89 | void installApkSync(); 90 | 91 | bool checkFilePermissions(const QString &filename); 92 | 93 | int guessApi(); 94 | 95 | bool activateApp(const QString &packageName, const QString &launcherClass); 96 | void waitForAndroidWindow(); 97 | 98 | QString checkShareFile(const QString &shareFilePath); 99 | 100 | DBusAdaptor *m_adaptor = nullptr; 101 | 102 | QString _watchDir; 103 | INotifyWatcher *_watcher; 104 | 105 | bool _isTopmostAndroid; 106 | 107 | QThread *m_serverThread = nullptr; 108 | QLocalServer *m_localServer = nullptr; 109 | 110 | QHash m_pendingRequests; 111 | 112 | QVariantHash m_deviceProperties; 113 | 114 | QTimer *m_sessionBusConnector = nullptr; 115 | QDBusConnection m_sbus; 116 | 117 | AlienAbstract *m_alien = nullptr; 118 | QString m_localSocket; 119 | 120 | QProcessEnvironment m_alienEnvironment; 121 | 122 | private slots: 123 | void requestDeviceInfo(); 124 | 125 | void readApplications(const QString &); 126 | void desktopChanged(const QString &path); 127 | 128 | void topmostIdChanged(int pId); 129 | 130 | void serviceStopped() override; 131 | void serviceStarted() override; 132 | 133 | }; 134 | 135 | #endif // DBUSSERVICE_H 136 | -------------------------------------------------------------------------------- /daemon/src/inotifywatcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Lucien XU 3 | * Copyright (C) 2016 Andrey Kozhevnikov 4 | * 5 | * You may use this file under the terms of the BSD license as follows: 6 | * 7 | * "Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * * The names of its contributors may not be used to endorse or promote 17 | * products derived from this software without specific prior written 18 | * permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 31 | */ 32 | 33 | #ifndef INOTIFYWATCHER_HPP 34 | #define INOTIFYWATCHER_HPP 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | class QSocketNotifier; 41 | class INotifyWatcher : public QObject 42 | { 43 | Q_OBJECT 44 | public: 45 | explicit INotifyWatcher(QObject *parent = nullptr); 46 | virtual ~INotifyWatcher(); 47 | 48 | QStringList addPaths(const QStringList &paths); 49 | QStringList removePaths(const QStringList &paths); 50 | 51 | signals: 52 | void directoryChanged(const QString &path, bool removed); 53 | void fileChanged(const QString &path, bool removed); 54 | void contentChanged(const QString &path, bool created); 55 | 56 | private slots: 57 | void readFromInotify(); 58 | 59 | private: 60 | QString getPathFromID(int id) const; 61 | 62 | private: 63 | int inotifyFd = -1; 64 | QHash pathToID; 65 | QMultiHash idToPath; 66 | QSocketNotifier *notifier = nullptr; 67 | 68 | QStringList files; 69 | QStringList directories; 70 | }; 71 | 72 | #endif // INOTIFYWATCHER_HPP 73 | -------------------------------------------------------------------------------- /daemon/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "dbusservice.h" 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | if (argc > 1 && strcmp(argv[1], "restore") == 0) { 17 | QString appsDir = QStringLiteral("/usr/share/applications/"); 18 | QDir appl(appsDir); 19 | for (const QString &desktoppath : appl.entryList({QStringLiteral("apkd_launcher_*.desktop")})) { 20 | QString path = appsDir + desktoppath; 21 | QFile desktop(path); 22 | if (desktop.open(QFile::ReadWrite | QFile::Text)) { 23 | QString data; 24 | QTextStream stream(&desktop); 25 | stream.setCodec("UTF-8"); 26 | while (!stream.atEnd()) { 27 | QString line = stream.readLine(); 28 | if (!line.startsWith(QLatin1String("MimeType")) && 29 | !line.startsWith(QLatin1String("X-Maemo-Method")) && 30 | !line.startsWith(QLatin1String("X-Maemo-Object")) && 31 | !line.startsWith(QLatin1String("X-Maemo-Service"))) { 32 | data.append(line); 33 | data.append(QChar(u'\n')); 34 | } 35 | } 36 | desktop.seek(0); 37 | desktop.resize(0); 38 | stream << data; 39 | desktop.close(); 40 | } 41 | } 42 | return 0; 43 | } 44 | 45 | qputenv("DBUS_SESSION_BUS_ADDRESS", QByteArrayLiteral("unix:path=/run/user/100000/dbus/user_bus_socket")); 46 | qputenv("LC_ALL", QByteArrayLiteral("en_US.utf8")); 47 | 48 | QCoreApplication app(argc, argv); 49 | DBusService context; 50 | QTimer::singleShot(0, &context, &DBusService::start); 51 | 52 | return app.exec(); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /daemon/systemd/aliendalvik-control.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Aliendalvik Control 3 | After=dbus.socket 4 | Requires=dbus.socket 5 | 6 | [Service] 7 | Type=dbus 8 | ExecStart=/usr/bin/aliendalvik-control 9 | EnvironmentFile=-/var/lib/environment/aliendalvik-control/*.conf 10 | BusName=org.coderus.aliendalvikcontrol 11 | Restart=always 12 | RestartSec=15 13 | -------------------------------------------------------------------------------- /dbus/org.coderus.aliendalvikcontrol.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /edge/edge.pro: -------------------------------------------------------------------------------- 1 | TARGET = aliendalvik-control-edge 2 | target.path = /usr/bin 3 | 4 | INSTALLS += target 5 | 6 | QT += dbus gui-private 7 | CONFIG += sailfishapp c++11 8 | 9 | SOURCES += \ 10 | src/main.cpp \ 11 | src/nativewindowhelper.cpp 12 | 13 | systemd.files = systemd/aliendalvik-control-edge.service 14 | systemd.path = /usr/lib/systemd/user 15 | 16 | INSTALLS += systemd 17 | 18 | INCLUDEPATH += /usr/include 19 | 20 | HEADERS += \ 21 | src/nativewindowhelper.h 22 | -------------------------------------------------------------------------------- /edge/qml/aliendalvik-control-edge.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.6 2 | import Sailfish.Silica 1.0 3 | import Nemo.DBus 2.0 4 | import Nemo.Configuration 1.0 5 | import QtSensors 5.0 6 | import org.coderus.aliendalvikcontrol.edge 1.0 7 | 8 | Item { 9 | id: root 10 | 11 | width: Screen.width 12 | height: Screen.height 13 | 14 | property bool initialized: false 15 | property bool isTopmostAndroid: false 16 | property bool isTopUp: orientationSensor.reading.orientation === OrientationReading.TopUp 17 | readonly property bool isActive: configuration.active && isTopmostAndroid && isTopUp 18 | onIsActiveChanged: { 19 | setTouchRegion(isActive) 20 | } 21 | 22 | OrientationSensor { 23 | id: orientationSensor 24 | active: true 25 | } 26 | 27 | ConfigurationGroup { 28 | id: configuration 29 | path: "/org/coderus/aliendalvikcontrol/edge" 30 | property bool active: false 31 | property bool leftHanded: false 32 | onLeftHandedChanged: { 33 | if (!isActive) { 34 | return 35 | } 36 | 37 | setTouchRegionDelayed.start() 38 | } 39 | } 40 | 41 | Timer { 42 | id: setTouchRegionDelayed 43 | interval: 1000 44 | repeat: false 45 | onTriggered: setTouchRegion(isActive) 46 | } 47 | 48 | DBusInterface { 49 | id: control 50 | bus: DBus.SystemBus 51 | service: "org.coderus.aliendalvikcontrol" 52 | path: "/" 53 | iface: "org.coderus.aliendalvikcontrol" 54 | signalsEnabled: true 55 | 56 | function isTopmostAndroidChanged(value) { 57 | isTopmostAndroid = value 58 | } 59 | 60 | Component.onCompleted: { 61 | typedCall("isTopmostAndroid", [], 62 | function(value) { 63 | initialized = true 64 | isTopmostAndroid = value 65 | }) 66 | } 67 | } 68 | 69 | function setTouchRegion(enabled) { 70 | if (!initialized) { 71 | return 72 | } 73 | 74 | NativeWindowHelper.setTouchRegion(mouseArea, enabled) 75 | } 76 | 77 | function progressBetween(progress, minValue, maxValue) { 78 | return minValue - (progress * (minValue - maxValue)) 79 | } 80 | 81 | MouseArea { 82 | id: mouseArea 83 | 84 | x: configuration.leftHanded ? 0 : (parent.width - width) 85 | anchors.bottom: parent.bottom 86 | anchors.bottomMargin: Theme.itemSizeHuge 87 | 88 | height: Screen.height / 2 89 | width: Theme.horizontalPageMargin 90 | 91 | enabled: isActive 92 | 93 | Rectangle { 94 | anchors.fill: parent 95 | color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) 96 | visible: isActive 97 | } 98 | 99 | property point startPoint 100 | 101 | function processMouse(mouse) { 102 | if (configuration.leftHanded) { 103 | pointItem.progressX = Math.min(1, (mouse.x - startPoint.x - width / 2) / (Screen.width / 2)) 104 | } else { 105 | pointItem.progressX = Math.min(1, (startPoint.x - mouse.x - width / 2) / (Screen.width / 2)) 106 | } 107 | 108 | pointItem.offsetY = Math.max(0, mouse.y - startPoint.y) 109 | } 110 | 111 | onPressed: { 112 | startPoint = Qt.point(mouse.x, mouse.y) 113 | processMouse(mouse) 114 | pointItem.visible = true 115 | } 116 | 117 | onClicked: { 118 | // 119 | } 120 | 121 | onPositionChanged: { 122 | processMouse(mouse) 123 | } 124 | 125 | onReleased: { 126 | pointItem.visible = false 127 | var posx = parseInt(pointItem.x + pointItem.width / 2) 128 | var posy = parseInt(pointItem.y + pointItem.height / 2) 129 | control.call("sendTap", [posx, posy]) 130 | } 131 | 132 | onCanceled: { 133 | pointItem.visible = false 134 | } 135 | } 136 | 137 | Rectangle { 138 | id: pointItem 139 | property int offsetY 140 | property real progressX 141 | 142 | width: Theme.itemSizeSmall 143 | height: Theme.itemSizeSmall 144 | 145 | readonly property int posX: progressBetween(progressX, width, Screen.width) 146 | 147 | x: configuration.leftHanded ? posX - width 148 | : Screen.width - posX 149 | y: offsetY 150 | 151 | radius: width / 2 152 | color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) 153 | 154 | visible: false 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /edge/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include "nativewindowhelper.h" 9 | 10 | Q_DECL_EXPORT int main(int argc, char *argv[]) 11 | { 12 | qmlRegisterSingletonType("org.coderus.aliendalvikcontrol.edge", 1, 0, "NativeWindowHelper", &NativeWindowHelper::qmlSingleton); 13 | 14 | QScopedPointer app(SailfishApp::application(argc, argv)); 15 | QScopedPointer view(SailfishApp::createView()); 16 | QObject::connect(view->engine(), &QQmlEngine::quit, app.data(), &QGuiApplication::quit); 17 | 18 | view->setColor(QColor(Qt::transparent)); 19 | view->setClearBeforeRendering(true); 20 | view->create(); 21 | 22 | QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); 23 | native->setWindowProperty(view->handle(), QStringLiteral("CATEGORY"), QStringLiteral("notification")); 24 | native->setWindowProperty(view->handle(), QStringLiteral("MOUSE_REGION"), QRegion(0, 0, 0, 0)); 25 | 26 | view->setSource(SailfishApp::pathToMainQml()); 27 | view->show(); 28 | 29 | return app->exec(); 30 | } 31 | -------------------------------------------------------------------------------- /edge/src/nativewindowhelper.cpp: -------------------------------------------------------------------------------- 1 | #include "nativewindowhelper.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | NativeWindowHelper::NativeWindowHelper(QObject *parent) 11 | : QObject(parent) 12 | { 13 | 14 | } 15 | 16 | QObject *NativeWindowHelper::qmlSingleton(QQmlEngine *, QJSEngine *) 17 | { 18 | return new NativeWindowHelper(qGuiApp); 19 | } 20 | 21 | void NativeWindowHelper::setTouchRegion(QQuickItem *item, bool enabled) 22 | { 23 | QQuickWindow *quickWindow = item->window(); 24 | QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); 25 | QRegion region; 26 | if (enabled) { 27 | const QPointF position = item->position(); 28 | const QRectF rect = item->childrenRect(); 29 | region = QRegion(position.x(), position.y(), rect.width(), rect.height()); 30 | qDebug() << Q_FUNC_INFO << enabled << position << rect << region; 31 | } 32 | native->setWindowProperty(quickWindow->handle(), QStringLiteral("MOUSE_REGION"), region); 33 | } 34 | -------------------------------------------------------------------------------- /edge/src/nativewindowhelper.h: -------------------------------------------------------------------------------- 1 | #ifndef NATIVEWINDOWHELPER_H 2 | #define NATIVEWINDOWHELPER_H 3 | 4 | #include 5 | 6 | class QQmlEngine; 7 | class QJSEngine; 8 | class QQuickItem; 9 | class NativeWindowHelper : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | static QObject *qmlSingleton(QQmlEngine *, QJSEngine *); 14 | 15 | public slots: 16 | void setTouchRegion(QQuickItem *item, bool enabled); 17 | 18 | protected: 19 | explicit NativeWindowHelper(QObject *parent = nullptr); 20 | }; 21 | 22 | #endif // NATIVEWINDOWHELPER_H 23 | -------------------------------------------------------------------------------- /edge/systemd/aliendalvik-control-edge.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Aliendalvik Control Edge 3 | After=lipstick.service 4 | Requires=lipstick.service 5 | 6 | [Service] 7 | Type=simple 8 | ExecStart=/usr/bin/aliendalvik-control-edge 9 | Restart=always 10 | RestartSec=15 11 | 12 | [Install] 13 | WantedBy=user-session.target -------------------------------------------------------------------------------- /icons/icons.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = aux 2 | # Configures svg to png 3 | THEMENAME=sailfish-default 4 | CONFIG += sailfish-svg2png 5 | -------------------------------------------------------------------------------- /icons/svgs/icon-m-aliendalvik-back4.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml 43 | 46 | 48 | 53 | 54 | 55 | 58 | 59 | 62 | 63 | 66 | 67 | 70 | 71 | 74 | 75 | 78 | 79 | 82 | 83 | 86 | 87 | 90 | 91 | 94 | 95 | 98 | 99 | 102 | 103 | 106 | 107 | 110 | 111 | 114 | 115 | -------------------------------------------------------------------------------- /icons/svgs/icon-m-aliendalvik-back8.svg: -------------------------------------------------------------------------------- 1 | 2 | image/svg+xml 20 | 23 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 47 | 48 | 51 | 52 | 55 | 56 | 59 | 60 | 63 | 64 | 67 | 68 | 71 | 72 | 75 | 76 | 79 | 80 | 83 | 84 | 87 | 88 | -------------------------------------------------------------------------------- /icons/svgs/icon-m-aliendalvikcontrol.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | 12 | 20 | 33 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /icons/svgs/icon-m-share-aliendalvik.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml 46 | 48 | 49 | 56 | 60 | 64 | 65 | 72 | 79 | 81 | 82 | 83 | 84 | 85 | 92 | 93 | -------------------------------------------------------------------------------- /proxy/dbus/org.coderus.aliendalvikcontrol.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.coderus.aliendalvikcontrol 3 | Interface=org.coderus.aliendalvikcontrol 4 | Exec=/usr/bin/aliendalvik-control-proxy 5 | -------------------------------------------------------------------------------- /proxy/proxy.pro: -------------------------------------------------------------------------------- 1 | TARGET = aliendalvik-control-proxy 2 | target.path = /usr/bin 3 | 4 | INSTALLS += target 5 | 6 | QT += dbus 7 | 8 | SOURCES += \ 9 | src/main.cpp \ 10 | src/adaptor.cpp \ 11 | src/service.cpp \ 12 | src/handler.cpp 13 | 14 | HEADERS += \ 15 | src/adaptor.h \ 16 | src/service.h \ 17 | src/handler.h 18 | 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII 21 | 22 | EXTRA_CFLAGS=-W -Wall -Wextra -Wpedantic -Werror 23 | QMAKE_CXXFLAGS += $$EXTRA_CFLAGS 24 | QMAKE_CFLAGS += $$EXTRA_CFLAGS 25 | 26 | dbus.files = dbus/org.coderus.aliendalvikcontrol.service 27 | dbus.path = /usr/share/dbus-1/services/ 28 | 29 | INSTALLS += dbus 30 | 31 | ad_dbus_interface.files = ../dbus/org.coderus.aliendalvikcontrol.xml 32 | ad_dbus_interface.source_flags = -c DBusInterface 33 | ad_dbus_interface.header_flags = -c DBusInterface 34 | DBUS_INTERFACES += ad_dbus_interface 35 | -------------------------------------------------------------------------------- /proxy/src/adaptor.cpp: -------------------------------------------------------------------------------- 1 | #include "adaptor.h" 2 | #include "aliendalvikcontrol_interface.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static const QString s_introspect_xml = QStringLiteral( 9 | " \n" 10 | " \n" 11 | ); 12 | 13 | Adaptor::Adaptor(DBusInterface *iface, QObject *parent) 14 | : QDBusVirtualObject(parent) 15 | , m_iface(iface) 16 | { 17 | 18 | } 19 | 20 | Adaptor::~Adaptor() 21 | { 22 | 23 | } 24 | 25 | QString Adaptor::introspect(const QString &) const 26 | { 27 | return s_introspect_xml; 28 | } 29 | 30 | bool Adaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection) 31 | { 32 | const QString interface = message.interface(); 33 | 34 | if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) { 35 | return false; 36 | } 37 | 38 | const QString member = message.member(); 39 | const QVariantList dbusArguments = message.arguments(); 40 | qDebug() << Q_FUNC_INFO << interface << member << dbusArguments; 41 | 42 | if (interface == QLatin1String("org.coderus.aliendalvikcontrol")) { 43 | const QString serviceName = message.service(); 44 | const QString patchName = message.path(); 45 | const QString methodName = message.member(); 46 | QDBusMessage systemMessage = QDBusMessage::createMethodCall( 47 | interface, 48 | patchName, 49 | interface, 50 | methodName); 51 | systemMessage.setArguments(dbusArguments); 52 | qDebug() << Q_FUNC_INFO << "Forwarding to system bus:" << serviceName << patchName << interface << methodName << 53 | QDBusConnection::systemBus().send(systemMessage); 54 | return true; 55 | } 56 | 57 | const QString className = QString::fromLatin1(QByteArray::fromPercentEncoding(member.toLatin1().replace("_", "%"))); 58 | 59 | QString data; 60 | if (dbusArguments.size() == 1) { 61 | data = dbusArguments.first().toString(); 62 | } 63 | 64 | m_iface->launcherActivity(interface, className, data); 65 | 66 | connection.send(message.createReply()); 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /proxy/src/adaptor.h: -------------------------------------------------------------------------------- 1 | #ifndef ADAPTOR_H 2 | #define ADAPTOR_H 3 | 4 | #include 5 | 6 | class DBusInterface; 7 | class QDBusConnection; 8 | class QDBusMessage; 9 | 10 | class Adaptor : public QDBusVirtualObject 11 | { 12 | public: 13 | explicit Adaptor(DBusInterface *iface, QObject *parent = nullptr); 14 | virtual ~Adaptor(); 15 | 16 | QString introspect(const QString &) const override; 17 | bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) override; 18 | 19 | private: 20 | DBusInterface *m_iface; 21 | }; 22 | 23 | #endif // ADAPTOR_H 24 | -------------------------------------------------------------------------------- /proxy/src/handler.cpp: -------------------------------------------------------------------------------- 1 | #include "handler.h" 2 | #include "aliendalvikcontrol_interface.h" 3 | 4 | #include 5 | 6 | Handler::Handler(DBusInterface *iface, QObject *parent) 7 | : QObject(parent) 8 | , m_iface(iface) 9 | { 10 | 11 | } 12 | 13 | void Handler::open(const QStringList ¶ms) 14 | { 15 | qDebug() << Q_FUNC_INFO << params; 16 | 17 | m_iface->uriActivity(params.first()); 18 | } 19 | 20 | void Handler::openSelector(const QStringList ¶ms) 21 | { 22 | qDebug() << Q_FUNC_INFO << params; 23 | 24 | m_iface->uriActivitySelector(params.first()); 25 | } 26 | -------------------------------------------------------------------------------- /proxy/src/handler.h: -------------------------------------------------------------------------------- 1 | #ifndef HANDLER_H 2 | #define HANDLER_H 3 | 4 | #include 5 | 6 | class DBusInterface; 7 | class Handler : public QObject 8 | { 9 | Q_OBJECT 10 | Q_CLASSINFO("D-Bus Interface", "org.coderus.aliendalvikcontrol") 11 | public: 12 | explicit Handler(DBusInterface *iface, QObject *parent = nullptr); 13 | 14 | public slots: 15 | void open(const QStringList ¶ms); 16 | void openSelector(const QStringList ¶ms); 17 | 18 | private: 19 | DBusInterface *m_iface; 20 | }; 21 | 22 | #endif // HANDLER_H 23 | -------------------------------------------------------------------------------- /proxy/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "service.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QCoreApplication app(argc, argv); 9 | Service service(&app); 10 | QTimer::singleShot(0, &service, &Service::start); 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /proxy/src/service.cpp: -------------------------------------------------------------------------------- 1 | #include "adaptor.h" 2 | #include "handler.h" 3 | #include "service.h" 4 | #include "aliendalvikcontrol_interface.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | static const QString c_dbus_service = QStringLiteral("org.coderus.aliendalvikcontrol"); 12 | static const QString c_dbus_path = QStringLiteral("/"); 13 | 14 | Service::Service(QObject *parent) 15 | : QObject(parent) 16 | , m_iface(new DBusInterface(c_dbus_service, c_dbus_path, QDBusConnection::systemBus(), this)) 17 | { 18 | 19 | } 20 | 21 | void Service::start() 22 | { 23 | const QString service = QStringLiteral("org.coderus.aliendalvikcontrol"); 24 | qDebug() << Q_FUNC_INFO << "Starting dbus service" << service << "..."; 25 | bool success = QDBusConnection::sessionBus().registerService(service); 26 | if (!success) { 27 | qWarning() << Q_FUNC_INFO << "Register service failed!"; 28 | QCoreApplication::exit(0); 29 | return; 30 | } 31 | qDebug() << Q_FUNC_INFO << "Service registered successfully!"; 32 | 33 | Handler *urlHandler = new Handler(m_iface, this); 34 | const bool urlHandlerSuccess = 35 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/urlHandler"), urlHandler, QDBusConnection::ExportAllSlots); 36 | if (!urlHandlerSuccess) { 37 | qWarning() << Q_FUNC_INFO << "Register urlHandler failed!"; 38 | QCoreApplication::exit(0); 39 | return; 40 | } 41 | qDebug() << Q_FUNC_INFO << "urlHandler registered successfully!"; 42 | 43 | Adaptor *adaptor = new Adaptor(m_iface, this); 44 | const bool adaptorSuccess = 45 | QDBusConnection::sessionBus().registerVirtualObject(QStringLiteral("/"), adaptor); 46 | if (adaptorSuccess) { 47 | qDebug() << Q_FUNC_INFO << "D-Bus handler registered successfully!"; 48 | } else { 49 | qWarning() << Q_FUNC_INFO << "Register hanler failed!"; 50 | QCoreApplication::exit(0); 51 | return; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /proxy/src/service.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICE_H 2 | #define SERVICE_H 3 | 4 | #include 5 | 6 | class DBusInterface; 7 | class Service : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Service(QObject *parent = nullptr); 12 | 13 | public slots: 14 | void start(); 15 | 16 | private: 17 | DBusInterface *m_iface; 18 | }; 19 | 20 | #endif // SERVICE_H 21 | -------------------------------------------------------------------------------- /rpm/aliendalvik-control.spec: -------------------------------------------------------------------------------- 1 | %define theme sailfish-default 2 | %{!?qtc_qmake5:%define qtc_qmake5 %qmake5} 3 | %{!?qtc_make:%define qtc_make make} 4 | %define __requires_exclude ^libgbinder.*$ 5 | 6 | Name: aliendalvik-control 7 | Summary: Aliendalvik control 8 | Version: 9.3.0 9 | Release: 2 10 | Group: Qt/Qt 11 | License: WTFPL 12 | URL: https://github.com/CODeRUS/aliendalvik-control 13 | Source0: %{name}-%{version}.tar.bz2 14 | Source1: https://github.com/CODeRUS/AliendalvikControlJava/releases/download/103/app-release.apk 15 | Requires: sailfish-version >= 3 16 | Requires: sailfishsilica-qt5 >= 0.10.9 17 | Conflicts: android-shareui 18 | Obsoletes: android-shareui 19 | Requires: nemo-transferengine-qt5 >= 0.3.1 20 | BuildRequires: pkgconfig(sailfishapp) >= 1.0.2 21 | BuildRequires: pkgconfig(Qt5Core) 22 | BuildRequires: pkgconfig(Qt5Qml) 23 | BuildRequires: pkgconfig(Qt5Quick) 24 | BuildRequires: pkgconfig(Qt5Network) 25 | BuildRequires: desktop-file-utils 26 | BuildRequires: pkgconfig(nemotransferengine-qt5) 27 | BuildRequires: sailfish-svg2png >= 0.1.5 28 | BuildRequires: pkgconfig(libgbinder) 29 | 30 | %description 31 | D-Bus daemon for sending commands to aliendalvik 32 | 33 | %prep 34 | %setup -q -n %{name}-%{version} 35 | 36 | %build 37 | 38 | %qtc_qmake5 \ 39 | RPM_VERSION=%{version}-%{release} \ 40 | HELPER_VERSION=103 41 | 42 | %qtc_make %{?_smp_mflags} 43 | 44 | %install 45 | rm -rf %{buildroot} 46 | %qmake5_install 47 | 48 | %post 49 | systemctl daemon-reload 50 | if /sbin/pidof aliendalvik-control-proxy > /dev/null; then 51 | killall -9 aliendalvik-control-proxy ||: 52 | fi 53 | 54 | if /sbin/pidof aliendalvik-control-share > /dev/null; then 55 | killall -9 aliendalvik-control-share ||: 56 | fi 57 | 58 | if [ -f /var/lib/lxc/aliendalvik/config ]; then 59 | if grep /home/.media /var/lib/lxc/aliendalvik/extra_config > /dev/null; then 60 | sed -i "/\\.media/ d" /var/lib/lxc/aliendalvik/extra_config 61 | fi 62 | fi 63 | 64 | systemctl restart aliendalvik-control ||: 65 | #systemctl-user restart aliendalvik-control-edge ||: 66 | #systemctl-user enable aliendalvik-control-edge ||: 67 | 68 | %preun 69 | if [ "$1" = "0" ]; then 70 | systemctl stop aliendalvik-control ||: 71 | if /sbin/pidof aliendalvik-control > /dev/null; then 72 | killall -9 aliendalvik-control ||: 73 | fi 74 | 75 | # systemctl-user stop aliendalvik-control-edge ||: 76 | # if /sbin/pidof aliendalvik-control-edge > /dev/null; then 77 | # killall -9 aliendalvik-control-edge ||: 78 | # fi 79 | 80 | if /sbin/pidof aliendalvik-control-share > /dev/null; then 81 | killall -9 aliendalvik-control-share ||: 82 | fi 83 | 84 | /usr/bin/aliendalvik-control restore ||: 85 | /usr/bin/update-desktop-database ||: 86 | 87 | if [ -f /opt/alien/data/app/aliendalvik-control.apk ]; then 88 | apkd-uninstall /opt/alien/data/app/aliendalvik-control.apk ||: 89 | else 90 | apkd-uninstall org.coderus.aliendalvikcontrol ||: 91 | fi 92 | 93 | if [ -f /var/lib/lxc/aliendalvik/config ]; then 94 | sed -i "/\\.media/ d" /var/lib/lxc/aliendalvik/extra_config 95 | sed -i "/\\.empty/ d" /var/lib/lxc/aliendalvik/extra_config 96 | 97 | systemctl stop aliendalvik-sd-mount.service ||: 98 | systemctl disable aliendalvik-sd-mount.service ||: 99 | fi 100 | fi 101 | 102 | %files 103 | %defattr(-,root,root,-) 104 | %{_bindir}/aliendalvik-control 105 | %{_bindir}/aliendalvik-control-proxy 106 | %{_bindir}/aliendalvik-control-share 107 | %{_bindir}/aliendalvik-control-selector 108 | #%{_bindir}/aliendalvik-control-edge 109 | 110 | %{_libdir}/libaliendalvikcontrolplugin-chroot.so 111 | %{_libdir}/libaliendalvikcontrolplugin-binder8.so 112 | 113 | %{_datadir}/dbus-1/system-services/org.coderus.aliendalvikcontrol.service 114 | %{_sysconfdir}/dbus-1/system.d/org.coderus.aliendalvikcontrol.conf 115 | /lib/systemd/system/aliendalvik-control.service 116 | 117 | #%{_libdir}/systemd/user/aliendalvik-control-edge.service 118 | 119 | %{_datadir}/dbus-1/services/org.coderus.aliendalvikcontrol.service 120 | %{_datadir}/dbus-1/services/org.coderus.aliendalvikshare.service 121 | %{_datadir}/dbus-1/services/org.coderus.aliendalvikselector.service 122 | 123 | %{_datadir}/applications/android-open-url.desktop 124 | %{_datadir}/applications/android-open-url-selector.desktop 125 | 126 | %{_datadir}/jolla-settings/entries/aliendalvikcontrol.json 127 | 128 | %{_datadir}/jolla-settings/pages/aliendalvikcontrol/main.qml 129 | %{_datadir}/jolla-settings/pages/aliendalvikcontrol/NavbarToggle.qml 130 | 131 | %{_libdir}/nemo-transferengine/plugins/libaliendalvikshareplugin.so 132 | %{_datadir}/nemo-transferengine/plugins/AliendalvikShare.qml 133 | 134 | %{_datadir}/aliendalvik-control-share/qml/aliendalvik-control-share.qml 135 | %{_datadir}/aliendalvik-control-share/qml/aliendalvik-control-share-cover.qml 136 | 137 | %{_datadir}/aliendalvik-control-selector/qml/aliendalvik-control-selector.qml 138 | 139 | #%{_datadir}/aliendalvik-control-edge/qml/aliendalvik-control-edge.qml 140 | 141 | %{_datadir}/aliendalvik-control/apk/app-release.apk 142 | 143 | %{_datadir}/themes/%{theme}/meegotouch/z1.0/icons/*.png 144 | %{_datadir}/themes/%{theme}/meegotouch/z1.25/icons/*.png 145 | %{_datadir}/themes/%{theme}/meegotouch/z1.5/icons/*.png 146 | %{_datadir}/themes/%{theme}/meegotouch/z1.5-large/icons/*.png 147 | %{_datadir}/themes/%{theme}/meegotouch/z1.75/icons/*.png 148 | %{_datadir}/themes/%{theme}/meegotouch/z2.0/icons/*.png 149 | 150 | %package logging 151 | Summary: Aliendalvik control logging enabler 152 | Requires: %{name} 153 | BuildArch: noarch 154 | 155 | %description logging 156 | %{summary}. 157 | 158 | %files logging 159 | %defattr(-,root,root,-) 160 | %{_sharedstatedir}/environment/aliendalvik-control/10-debug.conf 161 | -------------------------------------------------------------------------------- /selector/dbus/org.coderus.aliendalvikselector.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.coderus.aliendalvikselector 3 | Interface=org.coderus.aliendalvikselector 4 | Exec=/usr/bin/aliendalvik-control-selector 5 | -------------------------------------------------------------------------------- /selector/qml/aliendalvik-control-selector.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | import Sailfish.Silica.private 1.0 4 | import Nemo.DBus 2.0 5 | import Nemo.Configuration 1.0 6 | 7 | MouseArea 8 | { 9 | id: root 10 | 11 | width: Screen.width 12 | height: Screen.height 13 | 14 | property string url 15 | 16 | onClicked: { 17 | Qt.quit() 18 | } 19 | 20 | ConfigurationGroup { 21 | id: config 22 | path: "/org/coderus/aliendalvikcontrol/selector" 23 | property int windowPosX: -1 24 | property int windowPosY: -1 25 | } 26 | 27 | Wallpaper { 28 | id: bg 29 | x: config.windowPosX >= 0 ? config.windowPosX : (root.width - bg.width) / 2 30 | y: config.windowPosY >= 0 ? config.windowPosY : (root.height - bg.height) / 2 31 | width: parent.width - Theme.horizontalPageMargin * 2 32 | height: Math.min(Theme.itemSizeMedium * 5, contentView.contentHeight) 33 | clip: true 34 | blending: true 35 | 36 | Rectangle { 37 | anchors.fill: parent 38 | border.width: 1 39 | border.color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) 40 | color: "transparent" 41 | } 42 | 43 | SilicaListView { 44 | id: contentView 45 | anchors.fill: parent 46 | header: Component { 47 | MouseArea { 48 | width: parent.width 49 | height: Theme.itemSizeMedium 50 | 51 | drag.minimumX: 0 52 | drag.maximumX: root.width - bg.width 53 | drag.minimumY: 0 54 | drag.maximumY: root.height - Theme.itemSizeMedium * 5 55 | 56 | onPressAndHold: { 57 | drag.target = bg 58 | } 59 | 60 | onReleased: { 61 | drag.target = undefined 62 | config.windowPosX = bg.x 63 | config.windowPosY = bg.y 64 | console.log("### saving posx:", config.windowPosX, "posy:", config.windowPosY) 65 | } 66 | 67 | onCanceled: { 68 | drag.target = undefined 69 | } 70 | 71 | Column { 72 | width: parent.width 73 | anchors.centerIn: parent 74 | 75 | Label { 76 | anchors.horizontalCenter: parent.horizontalCenter 77 | text: "Open url with" 78 | } 79 | 80 | Label { 81 | anchors.left: parent.left 82 | anchors.right: parent.right 83 | anchors.margins: Theme.horizontalPageMargin 84 | truncationMode: TruncationMode.Fade 85 | text: root.url 86 | font.pixelSize: Theme.fontSizeSmall 87 | color: Theme.secondaryColor 88 | } 89 | } 90 | } 91 | } 92 | delegate: Component { 93 | BackgroundItem { 94 | id: content 95 | width: ListView.view.width 96 | 97 | Image { 98 | id: icon 99 | anchors.left: parent.left 100 | anchors.leftMargin: Theme.horizontalPageMargin 101 | anchors.verticalCenter: parent.verticalCenter 102 | sourceSize.width: Theme.itemSizeSmall - Theme.paddingMedium 103 | sourceSize.height: Theme.itemSizeSmall - Theme.paddingMedium 104 | source: "data:image/png;base64," + modelData.icon 105 | } 106 | 107 | Label { 108 | anchors.left: icon.right 109 | anchors.leftMargin: Theme.paddingMedium 110 | anchors.right: parent.right 111 | anchors.rightMargin: Theme.horizontalPageMargin 112 | anchors.verticalCenter: parent.verticalCenter 113 | text: modelData.prettyName 114 | color: content.highlighted ? Theme.highlightColor : Theme.primaryColor 115 | } 116 | 117 | onClicked: { 118 | console.log("###", modelData.packageName) 119 | control.call("uriLaunchActivity", [modelData.packageName, modelData.className, modelData.launcherClass, modelData.data]) 120 | 121 | Qt.quit() 122 | } 123 | } 124 | } 125 | VerticalScrollDecorator {} 126 | } 127 | } 128 | 129 | DBusAdaptor { 130 | id: adaptor 131 | bus: DBus.SessionBus 132 | service: "org.coderus.aliendalvikselector" 133 | path: "/" 134 | iface: "org.coderus.aliendalvikselector" 135 | 136 | xml: ' \n' + 137 | ' \n' + 138 | ' ' + 139 | ' ' + 140 | ' \n' + 141 | ' \n' 142 | 143 | function openUrl(url, candidates) { 144 | root.url = url 145 | contentView.model = candidates 146 | } 147 | } 148 | 149 | DBusInterface { 150 | id: control 151 | bus: DBus.SystemBus 152 | service: "org.coderus.aliendalvikcontrol" 153 | path: "/" 154 | iface: "org.coderus.aliendalvikcontrol" 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /selector/selector.pro: -------------------------------------------------------------------------------- 1 | TARGET = aliendalvik-control-selector 2 | target.path = /usr/bin 3 | 4 | INSTALLS += target 5 | 6 | QT += dbus gui-private 7 | CONFIG += sailfishapp c++11 8 | 9 | SOURCES += \ 10 | src/main.cpp 11 | 12 | dbus.files = dbus/org.coderus.aliendalvikselector.service 13 | dbus.path = /usr/share/dbus-1/services/ 14 | 15 | INSTALLS += dbus 16 | -------------------------------------------------------------------------------- /selector/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | Q_DECL_EXPORT int main(int argc, char *argv[]) 10 | { 11 | QScopedPointer app(SailfishApp::application(argc, argv)); 12 | QScopedPointer view(SailfishApp::createView()); 13 | QObject::connect(view->engine(), &QQmlEngine::quit, app.data(), &QGuiApplication::quit); 14 | 15 | view->setColor(QColor(Qt::transparent)); 16 | view->setClearBeforeRendering(true); 17 | view->create(); 18 | 19 | QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); 20 | native->setWindowProperty(view->handle(), QStringLiteral("CATEGORY"), QStringLiteral("dialog")); 21 | 22 | view->setSource(SailfishApp::pathToMainQml()); 23 | view->show(); 24 | 25 | return app->exec(); 26 | } 27 | -------------------------------------------------------------------------------- /share/dbus/org.coderus.aliendalvikshare.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.coderus.aliendalvikshare 3 | Interface=org.coderus.aliendalvikshare 4 | Exec=/usr/bin/aliendalvik-control-share 5 | -------------------------------------------------------------------------------- /share/qml/aliendalvik-control-share-cover.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | 4 | CoverBackground { 5 | CoverPlaceholder { 6 | icon.source: "image://theme/icon-launcher-jolla-apps" 7 | text: "Share from Android" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /share/qml/aliendalvik-control-share.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | import Nemo.DBus 2.0 4 | 5 | ApplicationWindow 6 | { 7 | id: appWindow 8 | cover: Qt.resolvedUrl("aliendalvik-control-share-cover.qml") 9 | 10 | property string titleText: "Share from Android" 11 | 12 | BusyIndicator { 13 | id: busyInicator 14 | anchors.centerIn: parent 15 | size: BusyIndicatorSize.Large 16 | running: visible 17 | visible: false 18 | 19 | Timer { 20 | id: busyTimer 21 | running: true 22 | repeat: false 23 | interval: 300 24 | onTriggered: { 25 | if (pageStack.currentPage == null) { 26 | busyInicator.visible = true 27 | } 28 | } 29 | } 30 | } 31 | 32 | Component { 33 | id: expiredPage 34 | Page { 35 | id: mainPage 36 | 37 | SilicaFlickable { 38 | anchors.fill: parent 39 | contentHeight: content.height 40 | 41 | Column { 42 | id: content 43 | width: parent.width 44 | 45 | PageHeader { 46 | title: titleText 47 | } 48 | } 49 | 50 | ViewPlaceholder { 51 | enabled: visible 52 | text: "Application started without share parameters" 53 | } 54 | } 55 | } 56 | } 57 | 58 | Timer { 59 | id: expireTimer 60 | running: true 61 | repeat: false 62 | interval: 1000 63 | onTriggered: { 64 | busyInicator.visible = false 65 | pageStack.animatorPush(expiredPage) 66 | } 67 | } 68 | 69 | DBusAdaptor { 70 | id: adaptor 71 | bus: DBus.SessionBus 72 | service: "org.coderus.aliendalvikshare" 73 | path: "/" 74 | iface: "org.coderus.aliendalvikshare" 75 | 76 | xml: ' \n' + 77 | ' \n' + 78 | ' ' + 79 | ' ' + 80 | ' ' + 81 | ' \n' + 82 | ' \n' 83 | 84 | function share(mimeType, data, fileName) { 85 | console.log("share called:", mimeType, data, fileName) 86 | busyInicator.visible = false 87 | expireTimer.stop() 88 | 89 | appWindow.activate() 90 | pageStack.clear() 91 | 92 | var shareData = { 93 | "mimeType": mimeType 94 | } 95 | 96 | if (fileName && fileName.length > 0) { 97 | shareData["source"] = Qt.resolvedUrl(fileName) 98 | } else { 99 | shareData["data"] = data 100 | } 101 | 102 | pageStack.animatorPush( 103 | "Sailfish.TransferEngine.SharePage", shareData) 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /share/share.pro: -------------------------------------------------------------------------------- 1 | TARGET = aliendalvik-control-share 2 | target.path = /usr/bin 3 | 4 | INSTALLS += target 5 | 6 | QT += dbus 7 | CONFIG += sailfishapp c++11 8 | 9 | dbus.files = dbus/org.coderus.aliendalvikshare.service 10 | dbus.path = /usr/share/dbus-1/services/ 11 | 12 | INSTALLS += dbus 13 | 14 | SOURCES += \ 15 | src/main.cpp 16 | -------------------------------------------------------------------------------- /share/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Q_DECL_EXPORT int main(int argc, char *argv[]) 4 | { 5 | return SailfishApp::main(argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /shareui/qml/AliendalvikShare.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import Sailfish.Silica 1.0 3 | import Sailfish.TransferEngine 1.0 4 | import Nemo.DBus 2.0 5 | 6 | ShareDialog { 7 | id: root 8 | 9 | property string sourceString: source 10 | property var contentVariant: root.content || {} 11 | 12 | property bool ready: false 13 | 14 | Component.onCompleted: { 15 | if (aliendalvikServiceIface.isActive()) { 16 | control.call("shareContent", [root.contentVariant, root.sourceString]) 17 | } 18 | } 19 | 20 | canAccept: false 21 | 22 | SilicaListView { 23 | id: sharingView 24 | anchors.fill: parent 25 | visible: aliendalvikServiceIface.isActive() 26 | header: PageHeader { 27 | title: qsTrId("Share to Android") 28 | } 29 | delegate: BackgroundItem { 30 | width: ListView.view.width 31 | 32 | Image { 33 | id: icon 34 | anchors.left: parent.left 35 | anchors.leftMargin: Theme.horizontalPageMargin 36 | anchors.verticalCenter: parent.verticalCenter 37 | sourceSize.width: Theme.itemSizeSmall - Theme.paddingMedium 38 | sourceSize.height: Theme.itemSizeSmall - Theme.paddingMedium 39 | source: "data:image/png;base64," + modelData.icon 40 | } 41 | 42 | Label { 43 | anchors.left: icon.right 44 | anchors.leftMargin: Theme.paddingMedium 45 | anchors.right: parent.right 46 | anchors.rightMargin: Theme.horizontalPageMargin 47 | anchors.verticalCenter: parent.verticalCenter 48 | text: modelData.prettyName 49 | color: parent.pressed && parent.down ? Theme.highlightColor : Theme.primaryColor 50 | } 51 | 52 | onClicked: { 53 | control.call("doShare", [modelData.mimeType, modelData.fileName, modelData.data, modelData.packageName, modelData.className, modelData.launcherClass]) 54 | pageStack.pop() 55 | } 56 | } 57 | 58 | ViewPlaceholder { 59 | enabled: ready && sharingView.count == 0 60 | text: "No candidates for sharing to" 61 | } 62 | } 63 | 64 | DBusInterface { 65 | id: control 66 | bus: DBus.SystemBus 67 | service: "org.coderus.aliendalvikcontrol" 68 | path: "/" 69 | iface: "org.coderus.aliendalvikcontrol" 70 | signalsEnabled: true 71 | 72 | function sharingListReady(sharingList) { 73 | __silica_applicationwindow_instance.activate() 74 | ready = true 75 | sharingView.model = sharingList 76 | } 77 | } 78 | 79 | DBusInterface { 80 | id: aliendalvikServiceIface 81 | bus: DBus.SystemBus 82 | service: 'org.freedesktop.systemd1' 83 | path: '/org/freedesktop/systemd1/unit/aliendalvik_2eservice' 84 | iface: 'org.freedesktop.systemd1.Unit' 85 | 86 | function isActive() { 87 | var activeProperty = getProperty("ActiveState") 88 | return activeProperty === "active" 89 | } 90 | } 91 | 92 | BusyIndicator { 93 | anchors.centerIn: parent 94 | size: BusyIndicatorSize.Large 95 | running: !ready && aliendalvikServiceIface.isActive() 96 | visible: running 97 | } 98 | 99 | Label { 100 | anchors.centerIn: parent 101 | width: parent.width - Theme.paddingLarge * 2 102 | wrapMode: Text.Wrap 103 | horizontalAlignment: Text.AlignHCenter 104 | text: "Aliendalvik not running! Please start any android application first to use this function." 105 | visible: !aliendalvikServiceIface.isActive() 106 | } 107 | } 108 | 109 | -------------------------------------------------------------------------------- /shareui/shareui.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | TARGET = $$qtLibraryTarget(aliendalvikshareplugin) 4 | target.path = /usr/lib/nemo-transferengine/plugins 5 | 6 | QT += dbus 7 | CONFIG += plugin link_pkgconfig 8 | PKGCONFIG += nemotransferengine-qt5 9 | 10 | HEADERS += \ 11 | src/transferiface.h \ 12 | src/plugininfo.h \ 13 | src/mediatransfer.h 14 | 15 | SOURCES += \ 16 | src/transferiface.cpp \ 17 | src/plugininfo.cpp \ 18 | src/mediatransfer.cpp 19 | 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII 22 | 23 | EXTRA_CFLAGS=-W -Wall -Wextra -Wpedantic -Werror 24 | QMAKE_CXXFLAGS += $$EXTRA_CFLAGS 25 | QMAKE_CFLAGS += $$EXTRA_CFLAGS 26 | 27 | qml.files = qml/AliendalvikShare.qml 28 | qml.path = /usr/share/nemo-transferengine/plugins 29 | 30 | INSTALLS += target qml 31 | -------------------------------------------------------------------------------- /shareui/src/mediatransfer.cpp: -------------------------------------------------------------------------------- 1 | #include "mediatransfer.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | MediaTransfer::MediaTransfer(QObject *parent) : 15 | MediaTransferInterface(parent) 16 | { 17 | } 18 | 19 | MediaTransfer::~MediaTransfer() 20 | { 21 | 22 | } 23 | 24 | bool MediaTransfer::cancelEnabled() const 25 | { 26 | return false; 27 | } 28 | 29 | QString MediaTransfer::displayName() const 30 | { 31 | return QStringLiteral("Android"); 32 | } 33 | 34 | bool MediaTransfer::restartEnabled() const 35 | { 36 | return false; 37 | } 38 | 39 | QUrl MediaTransfer::serviceIcon() const 40 | { 41 | return QUrl(); 42 | } 43 | 44 | void MediaTransfer::shareFile(const QString &filename, const QString mimetype) 45 | { 46 | QDBusMessage shareFile = QDBusMessage::createMethodCall(QStringLiteral("org.coderus.aliendalvikcontrol"), 47 | QStringLiteral("/"), 48 | QStringLiteral("org.coderus.aliendalvikcontrol"), 49 | QStringLiteral("shareFile")); 50 | shareFile.setArguments({filename, mimetype}); 51 | QDBusConnection::systemBus().send(shareFile); 52 | } 53 | 54 | void MediaTransfer::shareText(const QString &data) 55 | { 56 | QDBusMessage shareText = QDBusMessage::createMethodCall(QStringLiteral("org.coderus.aliendalvikcontrol"), 57 | QStringLiteral("/"), 58 | QStringLiteral("org.coderus.aliendalvikcontrol"), 59 | QStringLiteral("shareText")); 60 | shareText.setArguments({data}); 61 | QDBusConnection::systemBus().send(shareText); 62 | } 63 | 64 | void MediaTransfer::cancel() 65 | { 66 | setStatus(MediaTransferInterface::TransferCanceled); 67 | } 68 | 69 | void MediaTransfer::start() 70 | { 71 | const QUrl url = mediaItem()->value(MediaItem::Url).toUrl(); 72 | if (!url.isValid()) { 73 | const QString mimeType = mediaItem()->value(MediaItem::MimeType).toString(); 74 | const QString content = mediaItem()->value(MediaItem::ContentData).toString(); 75 | 76 | if (mimeType == QLatin1String("text/vcard")) { 77 | QFile tmp(QStringLiteral("/home/nemo/.aliendalvik-control-share.vcf")); 78 | if (tmp.open(QFile::WriteOnly)) { 79 | tmp.write(content.toUtf8()); 80 | shareFile(tmp.fileName(), mimeType); 81 | } 82 | } else if (mimeType == QLatin1String("text/x-url")) { 83 | const QVariantMap userData = mediaItem()->value(MediaItem::UserData).toMap(); 84 | if (userData.isEmpty()) { 85 | setStatus(MediaTransferInterface::TransferInterrupted); 86 | return; 87 | } 88 | const QString data = userData.value(QStringLiteral("status")).toString(); 89 | if (data.isEmpty()) { 90 | setStatus(MediaTransferInterface::TransferInterrupted); 91 | return; 92 | } 93 | shareText(data); 94 | } 95 | else { 96 | shareText(content); 97 | } 98 | } else { 99 | const QMimeType mimeType = QMimeDatabase().mimeTypeForFile(url.toString()); 100 | 101 | shareFile(url.toString(QUrl::PreferLocalFile), mimeType.name()); 102 | } 103 | 104 | setStatus(MediaTransferInterface::TransferFinished); 105 | } 106 | -------------------------------------------------------------------------------- /shareui/src/mediatransfer.h: -------------------------------------------------------------------------------- 1 | #ifndef MEDIATRANSFER_H 2 | #define MEDIATRANSFER_H 3 | 4 | #include 5 | 6 | class MediaTransfer : public MediaTransferInterface 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit MediaTransfer(QObject * parent = nullptr); 11 | virtual ~MediaTransfer(); 12 | 13 | bool cancelEnabled() const; 14 | QString displayName() const; 15 | bool restartEnabled() const; 16 | QUrl serviceIcon() const; 17 | 18 | private: 19 | void shareFile(const QString &filename, const QString mimetype); 20 | void shareText(const QString &data); 21 | 22 | public slots: 23 | void cancel(); 24 | void start(); 25 | 26 | }; 27 | 28 | #endif // MEDIATRANSFER_H 29 | -------------------------------------------------------------------------------- /shareui/src/plugininfo.cpp: -------------------------------------------------------------------------------- 1 | #include "plugininfo.h" 2 | 3 | PluginInfo::PluginInfo(): m_ready(false) 4 | { 5 | } 6 | 7 | PluginInfo::~PluginInfo() 8 | { 9 | 10 | } 11 | 12 | QList PluginInfo::info() const 13 | { 14 | return m_infoList; 15 | } 16 | 17 | void PluginInfo::query() 18 | { 19 | TransferMethodInfo info; 20 | 21 | info.displayName = QStringLiteral("Android"); 22 | info.methodId = QStringLiteral("AliendalvikSharePlugin"); 23 | info.shareUIPath = QStringLiteral("/usr/share/nemo-transferengine/plugins/AliendalvikShare.qml"); 24 | info.capabilitities = QStringList({QStringLiteral("*")}); 25 | info.accountIcon = QStringLiteral("image://theme/icon-m-share-aliendalvik"); 26 | m_infoList.clear(); 27 | m_infoList << info; 28 | 29 | m_ready = true; 30 | emit infoReady(); 31 | } 32 | 33 | bool PluginInfo::ready() const 34 | { 35 | return m_ready; 36 | } 37 | -------------------------------------------------------------------------------- /shareui/src/plugininfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PLUGININFO_H 2 | #define PLUGININFO_H 3 | 4 | #include 5 | #include 6 | 7 | class PluginInfo : public TransferPluginInfo 8 | { 9 | Q_OBJECT 10 | public: 11 | PluginInfo(); 12 | ~PluginInfo(); 13 | QList info() const; 14 | void query(); 15 | bool ready() const; 16 | 17 | private: 18 | QList m_infoList; 19 | bool m_ready; 20 | 21 | }; 22 | 23 | #endif // PLUGININFO_H 24 | -------------------------------------------------------------------------------- /shareui/src/transferiface.cpp: -------------------------------------------------------------------------------- 1 | #include "transferiface.h" 2 | #include "plugininfo.h" 3 | #include "mediatransfer.h" 4 | 5 | #include 6 | 7 | SharePlugin::SharePlugin() 8 | { 9 | 10 | } 11 | 12 | SharePlugin::~SharePlugin() 13 | { 14 | 15 | } 16 | 17 | QString SharePlugin::pluginId() const 18 | { 19 | return QLatin1String("AliendalvikSharePlugin"); 20 | } 21 | 22 | bool SharePlugin::enabled() const 23 | { 24 | return true; 25 | } 26 | 27 | TransferPluginInfo *SharePlugin::infoObject() 28 | { 29 | return new PluginInfo; 30 | } 31 | 32 | MediaTransferInterface *SharePlugin::transferObject() 33 | { 34 | return new MediaTransfer; 35 | } 36 | -------------------------------------------------------------------------------- /shareui/src/transferiface.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSFERIFACE_H 2 | #define TRANSFERIFACE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SharePlugin : public QObject, public TransferPluginInterface 10 | { 11 | Q_OBJECT 12 | Q_PLUGIN_METADATA(IID "aliendalvik.transfer.plugin") 13 | Q_INTERFACES(TransferPluginInterface) 14 | public: 15 | SharePlugin(); 16 | ~SharePlugin(); 17 | 18 | QString pluginId() const; 19 | bool enabled() const; 20 | TransferPluginInfo *infoObject(); 21 | MediaTransferInterface *transferObject(); 22 | }; 23 | 24 | #endif // TRANSFERIFACE_H 25 | --------------------------------------------------------------------------------