app_manager: Add launch intent

This commit is contained in:
Alessandro Astone
2022-07-01 15:41:37 +02:00
committed by Erfan Abdi
parent f11e373fdf
commit f7e35b68a2
4 changed files with 47 additions and 1 deletions

View File

@@ -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:

View File

@@ -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)

View 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")
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

View File

@@ -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)