Skip to content
Commit ad448160 authored by Robin Lee's avatar Robin Lee
Browse files

adb shell pm: create context as the right user

Prevents cross-user shell commands throwing an exception like the
following and crashing PackageManagerShellCommand.

java.lang.SecurityException: You need INTERACT_ACROSS_USERS or
MANAGE_USERS permission to: check isUserUnlockingOrUnlocked
	at UserManagerService.checkManageOrInteractPermissionIfCallerInOtherProfileGroup(UserManagerService.java:1534)
	at UserManagerService.isUserUnlockingOrUnlocked(UserManagerService.java:1472)
	at PackageManagerService.updateFlags(PackageManagerService.java:5410)
	at PackageManagerService.updateFlagsForPackage(PackageManagerService.java:5439)
	at PackageManagerService.updateFlagsForApplication(PackageManagerService.java:5446)
	at PackageManagerService.getApplicationInfoInternal(PackageManagerService.java:5120)
	at PackageManagerService.getApplicationInfo(PackageManagerService.java:5108)
	at PackageManager.getApplicationInfoAsUserUncached(PackageManager.java:8785)
	at PackageManager.access$000(PackageManager.java:102)
	at PackageManager$1.recompute(PackageManager.java:8798)
	at PackageManager$1.recompute(PackageManager.java:8795)
	at PropertyInvalidatedCache.query(PropertyInvalidatedCache.java:455)
	at PackageManager.getApplicationInfoAsUserCached(PackageManager.java:8813)
	at ActivityThread.getPackageInfo(ActivityThread.java:2275)
	at ContextImpl.createPackageContextAsUser(ContextImpl.java:2359)
	at ContextImpl.createPackageContext(ContextImpl.java:2346)
	at PackageManagerShellCommand.<init>(PackageManagerShellCommand.java:162)
	at PackageManagerService.onShellCommand(PackageManagerService.java:22329)
	at Binder.shellCommand(Binder.java:949)
	at Binder.onTransact(Binder.java:832)
	at IPackageManager$Stub.onTransact(IPackageManager.java:4767)
	at PackageManagerService.onTransact(PackageManagerService.java:4505)
	at Binder.execTransactInternal(Binder.java:1186)
	at Binder.execTransact(Binder.java:1145)

Bug: 159157348
Change-Id: I4854a3100f55b3190f9ad974a507be64ca9defa8
parent 3eaff51d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment