diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index cb64173b78090..4130f80742245 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -7563,10 +7563,15 @@ public class AppOpsManager { @SystemApi @RequiresPermission(android.Manifest.permission.GET_APP_OPS_STATS) public @NonNull List getPackagesForOps(@Nullable String[] ops) { - final int opCount = ops.length; - final int[] opCodes = new int[opCount]; - for (int i = 0; i < opCount; i++) { - opCodes[i] = sOpStrToOp.get(ops[i]); + final int[] opCodes; + if (ops != null) { + final int opCount = ops.length; + opCodes = new int[opCount]; + for (int i = 0; i < opCount; i++) { + opCodes[i] = sOpStrToOp.get(ops[i]); + } + } else { + opCodes = null; } final List result = getPackagesForOps(opCodes); return (result != null) ? result : Collections.emptyList();