Merge "DO NOT MERGE ANYWHERE Fix NPE when UID has no packages." into cw-e-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
eae242cfe8
@@ -2692,7 +2692,7 @@ public abstract class PackageManager {
|
|||||||
* @return Returns an array of one or more packages assigned to the user
|
* @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.
|
* 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
|
* Retrieve the official name associated with a user id. This name is
|
||||||
@@ -2705,7 +2705,7 @@ public abstract class PackageManager {
|
|||||||
* @return Returns a unique name for the given user id, or null if the
|
* @return Returns a unique name for the given user id, or null if the
|
||||||
* user id is not currently assigned.
|
* 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
|
* Return the user id associated with a shared user name. Multiple
|
||||||
|
|||||||
@@ -2319,11 +2319,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
final String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
|
final String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
|
||||||
final int userId = UserHandle.getUserId(uid);
|
final int userId = UserHandle.getUserId(uid);
|
||||||
|
|
||||||
|
if (!ArrayUtils.isEmpty(packages)) {
|
||||||
for (String packageName : packages) {
|
for (String packageName : packages) {
|
||||||
if (!mUsageStats.isAppIdle(packageName, uid, userId)) {
|
if (!mUsageStats.isAppIdle(packageName, uid, userId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user