How to trigger “Ok google” from adb shell?

1

I'm trying to simulate "Ok google" from adb shell on Android O(8.0), but I couldn't find solution.

I've found that the app which shows after "Ok google" has cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity. However, I couldn't launch it via adb due to below error.

$adb shell am start -n com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity
Starting: Intent { cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity }
Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity } from null (pid=29706, uid=2000) not exported from uid 10044

java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity } from null (pid=29706, uid=2000) not exported from uid 10044
    at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1688)
    at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:460)
    at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:277)
    at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:920)
    at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4693)
    at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:410)
    at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:141)
    at android.os.ShellCommand.exec(ShellCommand.java:96)
    at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:15401)
    at android.os.Binder.shellCommand(Binder.java:576)
    at android.os.Binder.onTransact(Binder.java:476)
    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4341)
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3040)
    at android.os.Binder.execTransact(Binder.java:681)

I expect some solution to launch the above app by adb.

  • Avoid security exception for $adb shell am start -n com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity
  • By another adb command
android
adb
voice
asked on Stack Overflow Oct 20, 2019 by Mori

1 Answer

0

Probably need to run adb root first

> adb root
> adb shell am start -n com.google.android.googlequicksearchbox/com.google.android.apps.gsa.staticplugins.opa.OpaActivity
answered on Stack Overflow Apr 28, 2020 by user3667359

User contributions licensed under CC BY-SA 3.0