AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
339 stars 102 forks source link

Unable to start a new session because of failed command adb list packages on secured devices #1445

Open luprochazka-cen63872 opened 2 days ago

luprochazka-cen63872 commented 2 days ago

Describe the bug In versions higher than 9.0.1 I see the problem mentioned here https://github.com/appium/appium-uiautomator2-driver/issues/795 I have some restriction on devices because of our company MDM, but it worked with version 9.0.1. Did you make any changes which might have affected it?

`WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Users/cenXXXXX/Library/Android/sdk/platform-tools/adb -P 5037 -s RZCCCCCCCC shell pm list packages' exited with code 255'; Command output: Exception occurred while executing 'list': java.lang.SecurityException: Shell does not have permission to access user 10 com.android.server.am.ActivityManagerService.handleIncomingUser:15970 android.app.ActivityManager.handleIncomingUser:5152 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733 at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892) at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15970) at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5152) at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733) at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1074) at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:960) [ Message content over the limit has been removed. ] at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:237) at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97) at android.os.ShellCommand.exec(ShellCommand.java:38) at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7136) at android.os.Binder.shellCommand(Binder.java:1104) at android.os.Binder.onTransact(Binder.java:914) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905) at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7120) at android.os.Binder.execTransactInternal(Binder.java:1380) at android.os.Binder.execTransact(Binder.java:1311)

at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1145:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:485:57)`

Environment

  1. Appium version (or git revision) that exhibits the issue: 2.12.1
  2. Node.js version (unless using Appium.app|exe): v18.20.2
  3. Npm or Yarn package manager: 10.5.0
  4. Mobile platform/version under test: Android 14
  5. Real device or emulator/simulator: Galaxy A54
  6. uiautomator2@3.8.2
saikrishna321 commented 1 day ago

@luprochazka-cen63872 Nope we have not made any changes. Also this error is coming during executing adb command, we don't do much

luprochazka-cen63872 commented 1 day ago

With device-farm disabled (clear Appium) or 9.0.1 is everything ok, but if I update device-farm the issue appears. Any idea what to check?

saikrishna321 commented 1 day ago

@luprochazka-cen63872 What is the output when you run the command from your terminal

adb -P 5037 -s RZCCCCCCCC shell pm list packages

luprochazka-cen63872 commented 1 day ago

@luprochazka-cen63872 What is the output when you run the command from your terminal

adb -P 5037 -s RZCCCCCCCC shell pm list packages

% adb -P 5037 -s RZCCCCCCCC shell pm list packages

Exception occurred while executing 'list': java.lang.SecurityException: Shell does not have permission to access user 10 com.android.server.am.ActivityManagerService.handleIncomingUser:15970 android.app.ActivityManager.handleIncomingUser:5152 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733 at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892) at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15970) at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5152) at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733) at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1074) at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:960) at com.android.server.pm.PackageManagerShellCommand.runList(PackageManagerShellCommand.java:800) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:237) at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97) at android.os.ShellCommand.exec(ShellCommand.java:38) at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7136) at android.os.Binder.shellCommand(Binder.java:1104) at android.os.Binder.onTransact(Binder.java:914) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905) at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7120) at android.os.Binder.execTransactInternal(Binder.java:1380) at android.os.Binder.execTransact(Binder.java:1311)

but this works: adb -P 5037 -s RZCW91QDTHJ shell pm list packages --user 0

package:com.sec.android.RilServiceModeApp package:com.samsung.oda.service package:com.google.android.overlay.modules.permissioncontroller.forframework ...