Merge "Pass fake package name for ROOT_UID in WorkSource." am: fbd5642752 am: 3b40a8707d am: 71a721debb
Original change: https://android-review.googlesource.com/c/platform/packages/services/Telephony/+/2048523
Change-Id: I60abc83048b2847eab5505da37ee697e58c3aef5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index d4ec2f6..cd9dbad 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -8510,6 +8510,16 @@
private WorkSource getWorkSource(int uid) {
String packageName = mApp.getPackageManager().getNameForUid(uid);
+ if (uid == Process.ROOT_UID && packageName == null) {
+ // Downstream WorkSource attribution inside the RIL requires both a UID and package name
+ // to be set for wakelock tracking, otherwise RIL requests fail with a runtime
+ // exception. ROOT_UID seems not to have a valid package name returned by
+ // PackageManager, so just fake it here to avoid issues when running telephony shell
+ // commands that plumb through the RIL as root, like so:
+ // $ adb root
+ // $ adb shell cmd phone ...
+ packageName = "root";
+ }
return new WorkSource(uid, packageName);
}