From: Alessandro Astone Date: Fri, 1 Jul 2022 13:41:37 +0000 (+0200) Subject: app_manager: Add launch intent X-Git-Tag: 1.3.0~27 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/commitdiff_plain/f7e35b68a2f659dceeaecd52bd3e52a38ae5160f app_manager: Add launch intent --- diff --git a/tools/__init__.py b/tools/__init__.py index ac67a03..2443e6e 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -91,6 +91,8 @@ def main(): 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: diff --git a/tools/actions/app_manager.py b/tools/actions/app_manager.py index cd66ab5..e0c3dda 100644 --- a/tools/actions/app_manager.py +++ b/tools/actions/app_manager.py @@ -116,3 +116,24 @@ def showFullUI(args): 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) diff --git a/tools/helpers/arguments.py b/tools/helpers/arguments.py index f686032..79ab853 100644 --- a/tools/helpers/arguments.py +++ b/tools/helpers/arguments.py @@ -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") + 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 diff --git a/tools/interfaces/IPlatform.py b/tools/interfaces/IPlatform.py index a8a5410..a5d6d08 100644 --- a/tools/interfaces/IPlatform.py +++ b/tools/interfaces/IPlatform.py @@ -18,7 +18,8 @@ TRANSACTION_getAppName = 8 TRANSACTION_settingsPutString = 9 TRANSACTION_settingsGetString = 10 TRANSACTION_settingsPutInt = 11 -TRANSACTION_getAppName = 12 +TRANSACTION_settingsGetInt = 12 +TRANSACTION_launchIntent = 13 class IPlatform: def __init__(self, remote): @@ -182,6 +183,25 @@ class IPlatform: 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)