Merge "Defeat @Nullable String[] with empty list." into oc-dev

am: 5a421ad0ef

Change-Id: Iad313a998a159049cfc55fff978b47be93f5e834
This commit is contained in:
Jeff Sharkey
2017-05-07 17:49:39 +00:00
committed by android-build-merger
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;
@@ -237,7 +239,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 {
@@ -281,7 +283,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];