mirror of
https://github.com/waydroid/waydroid.git
synced 2026-04-20 23:19:56 -04:00
app_manager: Add launch intent
This commit is contained in:
committed by
Erfan Abdi
parent
f11e373fdf
commit
f7e35b68a2
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user