Remove isPackageInstalled

It's not required to check whether package is installed before sending a
broadcast.

Change-Id: I132e49087faad28b637f98cf79d7ec56dcb26ecd
This commit is contained in:
Fyodor Kupolov
2016-02-11 18:06:34 -08:00
parent 8e87364a67
commit d284612d8f

View File

@@ -1749,16 +1749,6 @@ public class UserManagerService extends IUserManager.Stub {
}
}
private boolean isPackageInstalled(String pkg, int userId) {
final ApplicationInfo info = mPm.getApplicationInfo(pkg,
PackageManager.GET_UNINSTALLED_PACKAGES,
userId);
if (info == null || (info.flags&ApplicationInfo.FLAG_INSTALLED) == 0) {
return false;
}
return true;
}
/**
* Removes the app restrictions file for a specific package and user id, if it exists.
*/
@@ -2201,20 +2191,18 @@ public class UserManagerService extends IUserManager.Stub {
}
}
if (isPackageInstalled(packageName, userId)) {
// Notify package of changes via an intent - only sent to explicitly registered receivers.
Intent changeIntent = new Intent(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
changeIntent.setPackage(packageName);
changeIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(changeIntent, new UserHandle(userId));
}
// Notify package of changes via an intent - only sent to explicitly registered receivers.
Intent changeIntent = new Intent(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
changeIntent.setPackage(packageName);
changeIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(changeIntent, UserHandle.of(userId));
}
private int getUidForPackage(String packageName) {
long ident = Binder.clearCallingIdentity();
try {
return mContext.getPackageManager().getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES).uid;
PackageManager.MATCH_UNINSTALLED_PACKAGES).uid;
} catch (NameNotFoundException nnfe) {
return -1;
} finally {