Bring back wtf() for missing services.
Publish DropBox extremely early during boot process so that it can
pick up wtf() calls while booting.
Bug: 28634953
Change-Id: Ie71d53fc125ebc47fa08ef59a8b7e4f66f2e805c
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index c999257..2d46495 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -831,7 +831,7 @@
service = createService(ctx);
cache[mCacheIndex] = service;
} catch (ServiceNotFoundException e) {
- Log.w(TAG, e.getMessage(), e);
+ Log.wtf(TAG, e.getMessage(), e);
}
}
return (T)service;
@@ -855,7 +855,7 @@
try {
mCachedInstance = createService();
} catch (ServiceNotFoundException e) {
- Log.w(TAG, e.getMessage(), e);
+ Log.wtf(TAG, e.getMessage(), e);
}
}
return mCachedInstance;
@@ -888,7 +888,7 @@
try {
mCachedInstance = createService(appContext != null ? appContext : ctx);
} catch (ServiceNotFoundException e) {
- Log.w(TAG, e.getMessage(), e);
+ Log.wtf(TAG, e.getMessage(), e);
}
}
return mCachedInstance;
diff --git a/services/core/java/com/android/server/DropBoxManagerService.java b/services/core/java/com/android/server/DropBoxManagerService.java
index 129fbaa..040d22c 100644
--- a/services/core/java/com/android/server/DropBoxManagerService.java
+++ b/services/core/java/com/android/server/DropBoxManagerService.java
@@ -179,20 +179,6 @@
@Override
public void onStart() {
- // Set up intent receivers
- IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
- getContext().registerReceiver(mReceiver, filter);
-
- mContentResolver.registerContentObserver(
- Settings.Global.CONTENT_URI, true,
- new ContentObserver(new Handler()) {
- @Override
- public void onChange(boolean selfChange) {
- mReceiver.onReceive(getContext(), (Intent) null);
- }
- });
-
publishBinderService(Context.DROPBOX_SERVICE, mStub);
// The real work gets done lazily in init() -- that way service creation always
@@ -202,6 +188,21 @@
@Override
public void onBootPhase(int phase) {
switch (phase) {
+ case PHASE_SYSTEM_SERVICES_READY:
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
+ getContext().registerReceiver(mReceiver, filter);
+
+ mContentResolver.registerContentObserver(
+ Settings.Global.CONTENT_URI, true,
+ new ContentObserver(new Handler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ mReceiver.onReceive(getContext(), (Intent) null);
+ }
+ });
+ break;
+
case PHASE_BOOT_COMPLETED:
mBooted = true;
break;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1c038a0..96580d06 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -13734,11 +13734,12 @@
// NOTE -- this must never acquire the ActivityManagerService lock,
// otherwise the watchdog may be prevented from resetting the system.
- final String dropboxTag = processClass(process) + "_" + eventType;
- final DropBoxManager dbox = (DropBoxManager)
- mContext.getSystemService(Context.DROPBOX_SERVICE);
+ // Bail early if not published yet
+ if (ServiceManager.getService(Context.DROPBOX_SERVICE) == null) return;
+ final DropBoxManager dbox = mContext.getSystemService(DropBoxManager.class);
// Exit early if the dropbox isn't configured to accept this report type.
+ final String dropboxTag = processClass(process) + "_" + eventType;
if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
// Rate-limit how often we're willing to do the heavy lifting below to
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 548f831..2524600 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -498,6 +498,9 @@
* Starts some essential services that are not tangled up in the bootstrap process.
*/
private void startCoreServices() {
+ // Records errors and logs, for example wtf()
+ mSystemServiceManager.startService(DropBoxManagerService.class);
+
// Tracks the battery level. Requires LightService.
mSystemServiceManager.startService(BatteryService.class);
@@ -930,8 +933,6 @@
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
}
- mSystemServiceManager.startService(DropBoxManagerService.class);
-
if (!disableNonCoreServices && context.getResources().getBoolean(
R.bool.config_enableWallpaperService)) {
traceBeginAndSlog("StartWallpaperManagerService");