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

Commit bc215b84 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE when UID has no packages."

parents 3ea44a52 377ded0f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3173,7 +3173,7 @@ public abstract class PackageManager {
     * @return Returns an array of one or more packages assigned to the user
     * id, or null if there are no known packages with the given id.
     */
    public abstract String[] getPackagesForUid(int uid);
    public abstract @Nullable String[] getPackagesForUid(int uid);

    /**
     * Retrieve the official name associated with a user id.  This name is
@@ -3186,7 +3186,7 @@ public abstract class PackageManager {
     * @return Returns a unique name for the given user id, or null if the
     * user id is not currently assigned.
     */
    public abstract String getNameForUid(int uid);
    public abstract @Nullable String getNameForUid(int uid);

    /**
     * Return the user id associated with a shared user name. Multiple
+5 −3
Original line number Diff line number Diff line
@@ -2234,11 +2234,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        final String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
        final int userId = UserHandle.getUserId(uid);

        if (!ArrayUtils.isEmpty(packages)) {
            for (String packageName : packages) {
                if (!mUsageStats.isAppIdle(packageName, uid, userId)) {
                    return false;
                }
            }
        }
        return true;
    }