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

Commit 498cb3df authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Add timeout to AMS.getContentProviderImpl()"

parents 2288590e 747b8a0f
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -455,6 +455,12 @@ public class ActivityManagerService extends IActivityManager.Stub
    // before we decide it must be hung.
    static final int CONTENT_PROVIDER_PUBLISH_TIMEOUT = 10*1000;
    /**
     * How long we wait for an provider to be published. Should be longer than
     * {@link #CONTENT_PROVIDER_PUBLISH_TIMEOUT}.
     */
    static final int CONTENT_PROVIDER_WAIT_TIMEOUT = 20 * 1000;
    // How long we wait for a launched process to attach to the activity manager
    // before we decide it's never going to come up for real, when the process was
    // started with a wrapper for instrumentation (such as Valgrind) because it
@@ -7374,6 +7380,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        ContentProviderRecord cpr;
        ContentProviderConnection conn = null;
        ProviderInfo cpi = null;
        boolean providerRunning = false;
        synchronized(this) {
            long startTime = SystemClock.uptimeMillis();
@@ -7413,8 +7420,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
            }
            boolean providerRunning = false;
            if (cpr != null && cpr.proc != null) {
                providerRunning = !cpr.proc.killed;
@@ -7739,6 +7744,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        // Wait for the provider to be published...
        final long timeout = SystemClock.uptimeMillis() + CONTENT_PROVIDER_WAIT_TIMEOUT;
        synchronized (cpr) {
            while (cpr.provider == null) {
                if (cpr.launchingApp == null) {
@@ -7753,13 +7759,22 @@ public class ActivityManagerService extends IActivityManager.Stub
                    return null;
                }
                try {
                    final long wait = Math.max(0L, timeout - SystemClock.uptimeMillis());
                    if (DEBUG_MU) Slog.v(TAG_MU,
                            "Waiting to start provider " + cpr
                            + " launchingApp=" + cpr.launchingApp);
                            + " launchingApp=" + cpr.launchingApp + " for " + wait + " ms");
                    if (conn != null) {
                        conn.waiting = true;
                    }
                    cpr.wait();
                    cpr.wait(wait);
                    if (cpr.provider == null) {
                        Slog.wtf(TAG, "Timeout waiting for provider "
                                + cpi.applicationInfo.packageName + "/"
                                + cpi.applicationInfo.uid + " for provider "
                                + name
                                + " providerRunning=" + providerRunning);
                        return null;
                    }
                } catch (InterruptedException ex) {
                } finally {
                    if (conn != null) {