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

Commit 2abd66c4 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Defeat @Nullable String[] with empty list.

Test: builds, boots
Bug: 37577123
Change-Id: I6bf1af565398c30aecc0939a23846c0f85c13ffe
parent e44125cd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -583,4 +583,8 @@ public class ArrayUtils {
        }
        return size - leftIdx;
    }

    public static @NonNull String[] defeatNullable(@Nullable String[] val) {
        return (val != null) ? val : EmptyArray.STRING;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -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];