"am startservice -n org.traccar.client/.TrackingService"
Olá, talvez ajude...
Thank you!
When I run it, I get the below response. It seems the user context I am running in, inside the terminal, is u0a177
; but the shell command asked to run as user -2
, when the command was run, according to the error output.
Does this make sense? Is there a way to switch user context in the terminal session or is it as easy as adding the android.permission.INTERACT_ACROSS_USERS_FULL
or android.permission.INTERACT_ACROSS_USERS
permissions to the AndroidManifest.xml, the compiling our own custom package for use on our devices with this additional permission? Would this modification violate the Traccar usage license?
Starting service: Intent { cmp=org.traccar.client/.TrackingService }
Exception occurred while executing 'startservice':
java.lang.SecurityException: Permission Denial: service from com.android.shell asks to run as user -2 but is calling from uid u0a177; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS
at com.android.server.am.UserController.handleIncomingUser(UserController.java:1943)
at com.android.server.am.ActiveServices.retrieveServiceLocked(ActiveServices.java:2430)
at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:525)
at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:499)
at com.android.server.am.ActivityManagerService.startService(ActivityManagerService.java:15227)
at com.android.server.am.ActivityManagerShellCommand.runStartService(ActivityManagerShellCommand.java:689)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:191)
at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
at android.os.ShellCommand.exec(ShellCommand.java:44)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10695)
at android.os.Binder.shellCommand(Binder.java:929)
at android.os.Binder.onTransact(Binder.java:813)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5061)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2940)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
Now that I think about it, we would need to add these permissions to our shell, not to Traccar Client. Isn't this correct?
How can a Traccar Client be enabled over android shell/terminal? Android's "am" functionality has the following syntax to start an Android application and run a specific command from within the app:
am start -n com.package.name/com.package.name.ActivityName
It should be possible to launch a command similar to this one to start the Android Traccar Client's service:
am start -n org.traccar.client/org.traccar.action.SERVICE_STARTED
There are also intent-filters:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName
It should be possible to launch a command similar to this one to start the Android Traccar Client's service:
am start -a org.traccar.action.SERVICE_STARTED -n org.traccar.client/<START_SERVICE>
or
am start -a android.intent.action.MAIN -n org.traccar.client/<START_SERVICE>
This is what I get when trying these 2 commands:
Command 1:
am start -a android.intent.action.MAIN -n org.traccar.action.SERVICE_STARTED>
Error 1:
Error type 3 Error: Activity class {org.traccar.client/org.traccar.action.SERVICE_STARTED} does not exist.
Command 2:
am start -a android.intent.action.MAIN -n org.traccar.action.SERVICE_STARTED
Error 2:
Bad component name: org.traccar.action.SERVICE_STARTED
Any assistance in guiding me towards the action and package info required to make a command work to start the Traccar Client's service in the terminal would be amazing! Thanks to all who reply.