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

Commit d284612d authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Remove isPackageInstalled

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

Change-Id: I132e49087faad28b637f98cf79d7ec56dcb26ecd
parent 8e87364a
Loading
Loading
Loading
Loading
+6 −18
Original line number Diff line number Diff line
@@ -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));
        }
        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 {