Explicitly Select UID for Target SDK Check

To ensure that the correct ApplicationInfo is retrieved
for the target SDK check, expicitly invoke the package
manager for the context of the calling UID.

Bug: 136597456
Bug: 136359936
Test: manual - verified on Crosshatch
    -Install Slides on a Work Profile
    -Open Slides (crash)
    -CP this patch; build; flash
    -Open Slides (no crash)
Merged-In: I70a09ea22a2b3e7a866b2b97aa30487ea300b686
Change-Id: I70a09ea22a2b3e7a866b2b97aa30487ea300b686
(cherry picked from commit ec1847440d4eac460aa166acfbc18ef7d9a879c6)
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 073606f..4778608 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2030,14 +2030,18 @@
     /**
      * Returns the target SDK version number for a given package name.
      *
+     * This call MUST be invoked before clearing the calling UID.
+     *
      * @return target SDK if the package is found or INT_MAX.
      */
     private int getTargetSdk(String packageName) {
         try {
-            final ApplicationInfo ai = mApp.getPackageManager().getApplicationInfo(
-                            packageName, 0);
+            final ApplicationInfo ai = mApp.getPackageManager().getApplicationInfoAsUser(
+                    packageName, 0, UserHandle.getUserId(Binder.getCallingUid()));
             if (ai != null) return ai.targetSdkVersion;
         } catch (PackageManager.NameNotFoundException unexpected) {
+            loge("Failed to get package info for pkg="
+                    + packageName + ", uid=" + Binder.getCallingUid());
         }
         return Integer.MAX_VALUE;
     }