diff options
author | Yohei Yukawa <yukawa@google.com> | 2014-10-27 18:03:15 +0900 |
---|---|---|
committer | Yohei Yukawa <yukawa@google.com> | 2014-10-29 00:52:46 +0000 |
commit | 7e351fdae8e9f40a095fa16d9cf39ce9a463a652 (patch) | |
tree | 2cc3524d8e0a72d6cc5001ff516ce788c5eb3e09 | |
parent | ea2e042f7a2a04a48663f677b97d3da1817f793a (diff) | |
download | frameworks_base-7e351fdae8e9f40a095fa16d9cf39ce9a463a652.zip frameworks_base-7e351fdae8e9f40a095fa16d9cf39ce9a463a652.tar.gz frameworks_base-7e351fdae8e9f40a095fa16d9cf39ce9a463a652.tar.bz2 |
Stop querying package names unnecessarily
This is just a code clean-up. No behavior change is intended.
BUG: 18131340
Change-Id: Ia88374cde7845553530ddd1176f983101e4ec13f
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 308fcd8..04a7cb6 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -45,6 +45,7 @@ import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; +import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.database.ContentObserver; import android.hardware.usb.UsbManager; @@ -4275,8 +4276,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { try { ApplicationInfo applicationInfo = pm.getApplicationInfo(enabledPackage, PackageManager.GET_UNINSTALLED_PACKAGES, userIdToCheck); - systemService = (applicationInfo.flags - & ApplicationInfo.FLAG_SYSTEM) != 0; + systemService = (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; } catch (RemoteException e) { Log.i(LOG_TAG, "Can't talk to package managed", e); } @@ -4410,15 +4410,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { IPackageManager pm = AppGlobals.getPackageManager(); if (installedServices != null) { for (AccessibilityServiceInfo service : installedServices) { - String packageName = service.getResolveInfo().serviceInfo.packageName; - try { - ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, - PackageManager.GET_UNINSTALLED_PACKAGES, userId); - if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { - result.add(packageName); - } - } catch (RemoteException e) { - Log.i(LOG_TAG, "Accessibility service in missing package", e); + ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo; + ApplicationInfo applicationInfo = serviceInfo.applicationInfo; + if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { + result.add(serviceInfo.packageName); } } } @@ -4569,16 +4564,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { IPackageManager pm = AppGlobals.getPackageManager(); if (imes != null) { for (InputMethodInfo ime : imes) { - String packageName = ime.getPackageName(); - try { - ApplicationInfo applicationInfo = pm.getApplicationInfo( - packageName, PackageManager.GET_UNINSTALLED_PACKAGES, - userId); - if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { - result.add(packageName); - } - } catch (RemoteException e) { - Log.i(LOG_TAG, "Input method for missing package", e); + ServiceInfo serviceInfo = ime.getServiceInfo(); + ApplicationInfo applicationInfo = serviceInfo.applicationInfo; + if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { + result.add(serviceInfo.packageName); } } } @@ -4945,7 +4934,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { throws RemoteException { ApplicationInfo appInfo = pm.getApplicationInfo(packageName, GET_UNINSTALLED_PACKAGES, userId); - return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0; + return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; } @Override |