Defeat @Nullable String[] with empty list.

Test: builds, boots
Bug: 37577123
Change-Id: I6bf1af565398c30aecc0939a23846c0f85c13ffe
This commit is contained in:
Jeff Sharkey
2017-05-05 15:26:13 -06:00
parent e44125cd3a
commit 2abd66c4ff
2 changed files with 8 additions and 2 deletions

View File

@@ -583,4 +583,8 @@ public class ArrayUtils {
}
return size - leftIdx;
}
public static @NonNull String[] defeatNullable(@Nullable String[] val) {
return (val != null) ? val : EmptyArray.STRING;
}
}

View File

@@ -16,6 +16,8 @@
package com.android.server.usage;
import static com.android.internal.util.ArrayUtils.defeatNullable;
import android.app.AppOpsManager;
import android.app.usage.ExternalStorageStats;
import android.app.usage.IStorageStatsManager;
@@ -232,7 +234,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
enforcePermission(Binder.getCallingUid(), callingPackage);
}
if (mPackage.getPackagesForUid(appInfo.uid).length == 1) {
if (defeatNullable(mPackage.getPackagesForUid(appInfo.uid)).length == 1) {
// Only one package inside UID means we can fast-path
return queryStatsForUid(volumeUuid, appInfo.uid, callingPackage);
} else {
@@ -276,7 +278,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
enforcePermission(Binder.getCallingUid(), callingPackage);
}
final String[] packageNames = mPackage.getPackagesForUid(uid);
final String[] packageNames = defeatNullable(mPackage.getPackagesForUid(uid));
final long[] ceDataInodes = new long[packageNames.length];
String[] codePaths = new String[0];