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

Commit 3e195893 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Skip publishContentProviders() when we have zero.

If the list of providers for the application being bound is empty,
don't bother trying to register them.

Bug: 27510621
Change-Id: I921fb70a4c97433fa123fa88e170745ee013ee35
parent 9dd3b216
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
import com.android.org.conscrypt.OpenSSLSocketImpl;
import com.android.org.conscrypt.TrustedCertificateStore;
@@ -5264,9 +5265,8 @@ public final class ActivityThread {
            // don't bring up providers in restricted mode; they may depend on the
            // app's custom Application class
            if (!data.restrictedBackupMode) {
                List<ProviderInfo> providers = data.providers;
                if (providers != null) {
                    installContentProviders(app, providers);
                if (!ArrayUtils.isEmpty(data.providers)) {
                    installContentProviders(app, data.providers);
                    // For process that contains content providers, we want to
                    // ensure that the JIT is enabled "at some point".
                    mH.sendEmptyMessageDelayed(H.ENABLE_JIT, 10*1000);
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import libcore.util.EmptyArray;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
@@ -123,6 +124,13 @@ public class ArrayUtils {
        return (T[]) cache;
    }

    /**
     * Checks if given array is null or has zero elements.
     */
    public static boolean isEmpty(@Nullable List<?> array) {
        return array == null || array.isEmpty();
    }

    /**
     * Checks if given array is null or has zero elements.
     */
+3 −3
Original line number Diff line number Diff line
@@ -9902,11 +9902,11 @@ public final class ActivityManagerService extends ActivityManagerNative
    private final List<ProviderInfo> generateApplicationProvidersLocked(ProcessRecord app) {
        List<ProviderInfo> providers = null;
        try {
            ParceledListSlice<ProviderInfo> slice = AppGlobals.getPackageManager()
            providers = AppGlobals.getPackageManager()
                    .queryContentProviders(app.processName, app.uid,
                            STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS
                                    | MATCH_DEBUG_TRIAGED_MISSING);
            providers = slice != null ? slice.getList() : null;
                                    | MATCH_DEBUG_TRIAGED_MISSING)
                    .getList();
        } catch (RemoteException ex) {
        }
        if (DEBUG_MU) Slog.v(TAG_MU,