Fix the dumpsys using deprecated API for getting calling package names
Some system services were not receiving the right calling package names which was being used to verify the caller. This change makes it easier to get the calling package name using the context API. BUG=241041706 Test: "adb shell dumpsys hardware_properties" works now. Change-Id: I3489d39980c9a4c72011115b911a59b43980799e
This commit is contained in:
@@ -98,12 +98,17 @@ public class HardwarePropertiesManagerService extends IHardwarePropertiesManager
|
||||
}
|
||||
|
||||
private String getCallingPackageName() {
|
||||
final String[] packages = mContext.getPackageManager().getPackagesForUid(
|
||||
Binder.getCallingUid());
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
final int uid = Binder.getCallingUid();
|
||||
final String[] packages = pm.getPackagesForUid(uid);
|
||||
if (packages != null && packages.length > 0) {
|
||||
return packages[0];
|
||||
}
|
||||
return "unknown";
|
||||
final String name = pm.getNameForUid(uid);
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
return String.valueOf(uid);
|
||||
}
|
||||
|
||||
private void dumpTempValues(String pkg, PrintWriter pw, int type,
|
||||
|
||||
Reference in New Issue
Block a user