Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions about adding own workloads #1234

Open
hosunhc opened this issue Aug 30, 2023 · 2 comments
Open

Some questions about adding own workloads #1234

hosunhc opened this issue Aug 30, 2023 · 2 comments
Labels

Comments

@hosunhc
Copy link

hosunhc commented Aug 30, 2023

So I've been trying to get some of the already made workloads to work and trying to add some of my own, but with little success.
The target device that I am using is Pixel 6 with Android 13. I have two questions/issues that I would like to have figured out.

  1. Some workloads have an error because the android.permission.WRITE_SETTINGS returns a non-zero exit status 255. I've attempted two workloads that return this error.
  • GFXBench. The error comes up like below when I try to run wa run -f gfxbench.yaml.
ERROR            Command 'export PATH=/data/local/tmp/bin:$PATH && export LC_ALL=C && pm grant com.glbenchmark.glbenchmark27 android.permission.WRITE_SETTINGS' returned non-zero exit status 255.
ERROR            STDOUT: 
ERROR            STDERR: Exception occurred while executing 'grant':
ERROR            java.lang.SecurityException: Permission android.permission.WRITE_SETTINGS is managed by role
ERROR                   at com.android.server.pm.permission.PermissionManagerServiceImpl.grantRuntimePermissionInternal(PermissionManagerServiceImpl.java:1388)
ERROR                   at com.android.server.pm.permission.PermissionManagerServiceImpl.grantRuntimePermission(PermissionManagerServiceImpl.java:1319)
ERROR                   at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:547)
ERROR                   at android.permission.PermissionManager.grantRuntimePermission(PermissionManager.java:597)
ERROR                   at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2546)
ERROR                   at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:292)
ERROR                   at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
ERROR                   at android.os.ShellCommand.exec(ShellCommand.java:38)
ERROR                   at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:5964)
ERROR                   at android.os.Binder.shellCommand(Binder.java:1049)
ERROR                   at android.os.Binder.onTransact(Binder.java:877)
ERROR                   at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313)
ERROR                   at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5948)
ERROR                   at android.os.Binder.execTransactInternal(Binder.java:1285)
ERROR                   at android.os.Binder.execTransact(Binder.java:1244)
  • VLC that I added personally. I created a workload and in .workload_automation/plugins/vlc/__init__.py, I have the following code:
class Vlc(ApkReventWorkload):
    name = 'vlc'
    description = "VLC"
    # Replace with a list of supported package names in the APK file(s).
    package_names = ['org.videolan.vlc']

But when I try to record a revent so I can play my video (wa record -r -w vlc), I get the following error:

ERROR    Command 'export PATH=/data/local/tmp/bin:$PATH && export LC_ALL=C && pm grant org.videolan.vlc android.permission.WRITE_SETTINGS' returned non-zero exit status 255.
ERROR    STDOUT: 
ERROR    STDERR: Exception occurred while executing 'grant':
ERROR    java.lang.SecurityException: Permission android.permission.WRITE_SETTINGS is managed by role
ERROR           at com.android.server.pm.permission.PermissionManagerServiceImpl.grantRuntimePermissionInternal(PermissionManagerServiceImpl.java:1388)
ERROR           at com.android.server.pm.permission.PermissionManagerServiceImpl.grantRuntimePermission(PermissionManagerServiceImpl.java:1319)
ERROR           at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:547)
ERROR           at android.permission.PermissionManager.grantRuntimePermission(PermissionManager.java:597)
ERROR           at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2546)
ERROR           at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:292)
ERROR           at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
ERROR           at android.os.ShellCommand.exec(ShellCommand.java:38)
ERROR           at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:5964)
ERROR           at android.os.Binder.shellCommand(Binder.java:1049)
ERROR           at android.os.Binder.onTransact(Binder.java:877)
ERROR           at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4313)
ERROR           at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:5948)
ERROR           at android.os.Binder.execTransactInternal(Binder.java:1285)
ERROR           at android.os.Binder.execTransact(Binder.java:1244)
  1. My second question is regard UiAutomation. I've been trying to run Geekbench 6 through the given code, but it always fails at the point right after Run CPU Benchmark button is clicked. Once terminal shows that job wk1 is running, the button for Run CPU Benchmark is clicked and then WA pauses when workload pop up opens and is about to begin. I attached the
    run.log.
    But as someone who is using Android UiAutomation for the first time, is there a good documentation for finding the button IDs, etc so that I can fix the automation for my application version and build my own workloads? I've checked the Android Developer Website, but was hoping for a more direct example. Or maybe a suggestion on where I can start when I try adding my own workload applications to find the UI object IDs and commands.

Thanks!
Also the version of WA I'm using is wa 3.4.0.dev1.

@hosunhc
Copy link
Author

hosunhc commented Sep 1, 2023

I didn't realize question 1 was asked previously at #1212. But still not sure how to proceed and fix this issue.

@marcbonnici
Copy link
Contributor

Hi,

  1. This looks like this was introduced in the later versions of Android. I have opened a PR for devlib [1] to not throw an error if attempting to configure such a permission. Please let me know if this allows you to make progress.

  2. The easiest way is to use the UiAutomatorViewer tool [2]. This allows you to take a snapshot/ui dump of the device. (FYI as part of WA's error handling code it should automatically try and capture the state of the device at point of failure and these files can also be opened by UiAutomatorViewer directly.) This tool allows you to select GUI elements and see the details of each element that can by used by the UiAutomator code.

Please let me know if helps.

[1] ARM-software/devlib#647
[2] https://developer.android.com/training/testing/other-components/ui-automator#inspect-ui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants