From c5510138527eaf0782b52c3ed9c1bd8b6ce1eec6 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 2 Nov 2018 10:36:54 -0700 Subject: [PATCH] Enhance provider timeout error message Bug: 118839305 Bug: 110030490 Test: Manual test with setting "timeout" to true. Change-Id: Ie433bc244a64ba5457dc92c990e27c02ce15122b --- .../server/am/ActivityManagerService.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 88558b48b2e51..ece9b5b8012ec 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6490,6 +6490,7 @@ public class ActivityManagerService extends IActivityManager.Stub // Wait for the provider to be published... final long timeout = SystemClock.uptimeMillis() + CONTENT_PROVIDER_WAIT_TIMEOUT; + boolean timedOut = false; synchronized (cpr) { while (cpr.provider == null) { if (cpr.launchingApp == null) { @@ -6513,12 +6514,8 @@ public class ActivityManagerService extends IActivityManager.Stub } 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; + timedOut = true; + break; } } catch (InterruptedException ex) { } finally { @@ -6528,7 +6525,26 @@ public class ActivityManagerService extends IActivityManager.Stub } } } - return cpr != null ? cpr.newHolder(conn) : null; + if (timedOut) { + // Note we do it afer releasing the lock. + String callerName = "unknown"; + synchronized (this) { + final ProcessRecord record = mProcessList.getLRURecordForAppLocked(caller); + if (record != null) { + callerName = record.processName; + } + } + + Slog.wtf(TAG, "Timeout waiting for provider " + + cpi.applicationInfo.packageName + "/" + + cpi.applicationInfo.uid + " for provider " + + name + + " providerRunning=" + providerRunning + + " caller=" + callerName + "/" + Binder.getCallingUid()); + return null; + } + + return cpr.newHolder(conn); } private static final class StartActivityRunnable implements Runnable {