Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5734ae2d authored by Karthik Ravi Shankar's avatar Karthik Ravi Shankar
Browse files

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
parent 3c237a9a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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,