]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
app_manager: Add launch intent
authorAlessandro Astone <ales.astone@gmail.com>
Fri, 1 Jul 2022 13:41:37 +0000 (15:41 +0200)
committerErfan Abdi <erfangplus@gmail.com>
Wed, 6 Jul 2022 16:44:07 +0000 (21:14 +0430)
tools/__init__.py
tools/actions/app_manager.py
tools/helpers/arguments.py
tools/interfaces/IPlatform.py

index ac67a03c6af7a036087dfe457a150f59ac68ac36..2443e6ebb5d6a7a5c2f580bdbca6288094fe5896 100644 (file)
@@ -91,6 +91,8 @@ def main():
                 actions.app_manager.remove(args)
             elif args.subaction == "launch":
                 actions.app_manager.launch(args)
                 actions.app_manager.remove(args)
             elif args.subaction == "launch":
                 actions.app_manager.launch(args)
+            elif args.subaction == "intent":
+                actions.app_manager.intent(args)
             elif args.subaction == "list":
                 actions.app_manager.list(args)
             else:
             elif args.subaction == "list":
                 actions.app_manager.list(args)
             else:
index cd66ab5e4ce40336749036077f3481e8d88893c6..e0c3dda2223972dbd426dc59ea387f093bd5a701 100644 (file)
@@ -116,3 +116,24 @@ def showFullUI(args):
                 time.sleep(0.5)
                 statusBarService.collapse()
     maybeLaunchLater(args, showFullUI, justShow)
                 time.sleep(0.5)
                 statusBarService.collapse()
     maybeLaunchLater(args, showFullUI, justShow)
+
+def intent(args):
+    def justLaunch():
+        platformService = IPlatform.get_service(args)
+        if platformService:
+            ret = platformService.launchIntent(args.ACTION, args.URI)
+            if ret == "":
+                return
+            pkg = ret if ret != "android" else "Waydroid"
+            platformService.setprop("waydroid.active_apps", pkg)
+            multiwin = platformService.getprop(
+                "persist.waydroid.multi_windows", "false")
+            if multiwin == "false":
+                platformService.settingsPutString(
+                    2, "policy_control", "immersive.status=*")
+            else:
+                platformService.settingsPutString(
+                    2, "policy_control", "immersive.full=*")
+        else:
+            logging.error("Failed to access IPlatform service")
+    maybeLaunchLater(args, intent, justLaunch)
index f686032b5726eace8ae9153366bcaf1ea0599c49..79ab8533fd107a80b3ab9ce5c1be5b54af93cb6d 100644 (file)
@@ -82,6 +82,9 @@ def arguments_app(subparser):
     remove.add_argument('PACKAGE', help="package name of app to remove")
     launch = sub.add_parser("launch", help="start single application")
     launch.add_argument('PACKAGE', help="package name of app to launch")
     remove.add_argument('PACKAGE', help="package name of app to remove")
     launch = sub.add_parser("launch", help="start single application")
     launch.add_argument('PACKAGE', help="package name of app to launch")
+    intent = sub.add_parser("intent", help="start single application")
+    intent.add_argument('ACTION', help="action name")
+    intent.add_argument('URI', help="data uri")
     sub.add_parser("list", help="list installed applications")
     return ret
 
     sub.add_parser("list", help="list installed applications")
     return ret
 
index a8a5410758b365bcbd6d7e65f4f9641e56372f60..a5d6d08a602c7566182815eb1b417a3e8efc2dfb 100644 (file)
@@ -18,7 +18,8 @@ TRANSACTION_getAppName = 8
 TRANSACTION_settingsPutString = 9
 TRANSACTION_settingsGetString = 10
 TRANSACTION_settingsPutInt = 11
 TRANSACTION_settingsPutString = 9
 TRANSACTION_settingsGetString = 10
 TRANSACTION_settingsPutInt = 11
-TRANSACTION_getAppName = 12
+TRANSACTION_settingsGetInt = 12
+TRANSACTION_launchIntent = 13
 
 class IPlatform:
     def __init__(self, remote):
 
 class IPlatform:
     def __init__(self, remote):
@@ -182,6 +183,25 @@ class IPlatform:
             if exception != 0:
                 logging.error("Failed with code: {}".format(exception))
 
             if exception != 0:
                 logging.error("Failed with code: {}".format(exception))
 
+    def launchIntent(self, arg1, arg2):
+        request = self.client.new_request()
+        request.append_string16(arg1)
+        request.append_string16(arg2)
+        reply, status = self.client.transact_sync_reply(
+            TRANSACTION_launchIntent, request)
+
+        if status:
+            logging.error("Sending reply failed")
+        else:
+            reader = reply.init_reader()
+            status, exception = reader.read_int32()
+            if exception == 0:
+                rep1 = reader.read_string16()
+                return rep1
+            else:
+                logging.error("Failed with code: {}".format(exception))
+        return None
+
     def getAppName(self, arg1):
         request = self.client.new_request()
         request.append_string16(arg1)
     def getAppName(self, arg1):
         request = self.client.new_request()
         request.append_string16(arg1)