WifiServiceImpl: Clear identity before retrieving app info

Bug: 120398026
Test: Add a secondary user and ensure crash is not oberved.
Change-Id: I1bab7b10027fdf86d420c9299a6ce8a80d21250e
(cherry picked from commit 4395bc65a746e407c2841cc43582713c575f91a7)
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index aba10b9..6fd4924 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -716,6 +716,7 @@
 
     // Helper method to check if the entity initiating the binder call is a system app.
     private boolean isSystem(String packageName) {
+        long ident = Binder.clearCallingIdentity();
         try {
             ApplicationInfo info = mContext.getPackageManager().getApplicationInfo(packageName, 0);
             return info.isSystemApp() || info.isUpdatedSystemApp();
@@ -723,6 +724,8 @@
             // In case of exception, assume unknown app (more strict checking)
             // Note: This case will never happen since checkPackage is
             // called to verify validity before checking App's version.
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
         return false;
     }
@@ -796,6 +799,7 @@
     }
 
     private boolean isTargetSdkLessThan(String packageName, int versionCode) {
+        long ident = Binder.clearCallingIdentity();
         try {
             if (mContext.getPackageManager().getApplicationInfo(packageName, 0).targetSdkVersion
                     < versionCode) {
@@ -805,9 +809,10 @@
             // In case of exception, assume unknown app (more strict checking)
             // Note: This case will never happen since checkPackage is
             // called to verify validity before checking App's version.
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
         return false;
-
     }
 
     /**