Fix issue #2492387: system server crash in WallpaperManagerService
Also move some of the important framework error logs over to Slog.
Change-Id: If6697c3e4f18498612ebd7b0e4e4f042fd713372
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b0a59c7..7b5b63e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -59,6 +59,7 @@
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
+import android.util.Slog;
import android.view.Display;
import android.view.View;
import android.view.ViewDebug;
@@ -542,7 +543,7 @@
}
warned = true;
Thread.currentThread().setContextClassLoader(getParent());
- Log.w(TAG, "ClassLoader." + methodName + ": " +
+ Slog.w(TAG, "ClassLoader." + methodName + ": " +
"The class loader returned by " +
"Thread.getContextClassLoader() may fail for processes " +
"that host multiple applications. You should explicitly " +
@@ -677,7 +678,7 @@
"originally registered here. Are you missing a " +
"call to unregisterReceiver()?");
leak.setStackTrace(rd.getLocation().getStackTrace());
- Log.e(TAG, leak.getMessage(), leak);
+ Slog.e(TAG, leak.getMessage(), leak);
try {
ActivityManagerNative.getDefault().unregisterReceiver(
rd.getIIntentReceiver());
@@ -698,7 +699,7 @@
what + " " + who + " has leaked ServiceConnection "
+ sd.getServiceConnection() + " that was originally bound here");
leak.setStackTrace(sd.getLocation().getStackTrace());
- Log.e(TAG, leak.getMessage(), leak);
+ Slog.e(TAG, leak.getMessage(), leak);
try {
ActivityManagerNative.getDefault().unbindService(
sd.getIServiceConnection());
@@ -823,7 +824,7 @@
try {
mgr.finishReceiver(this, resultCode, data, extras, false);
} catch (RemoteException e) {
- Log.w(TAG, "Couldn't finish broadcast to unregistered receiver");
+ Slog.w(TAG, "Couldn't finish broadcast to unregistered receiver");
}
}
}
@@ -1721,7 +1722,7 @@
try {
Process.setProcessGroup(Process.myPid(), group);
} catch (Exception e) {
- Log.w(TAG, "Failed setting process group to " + group, e);
+ Slog.w(TAG, "Failed setting process group to " + group, e);
}
}
@@ -2833,7 +2834,7 @@
String classname = data.appInfo.backupAgentName;
if (classname == null) {
if (data.backupMode == IApplicationThread.BACKUP_MODE_INCREMENTAL) {
- Log.e(TAG, "Attempted incremental backup but no defined agent for "
+ Slog.e(TAG, "Attempted incremental backup but no defined agent for "
+ packageName);
return;
}
@@ -2860,7 +2861,7 @@
} catch (Exception e) {
// If this is during restore, fail silently; otherwise go
// ahead and let the user see the crash.
- Log.e(TAG, "Agent threw during creation: " + e);
+ Slog.e(TAG, "Agent threw during creation: " + e);
if (data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE) {
throw e;
}
@@ -2890,12 +2891,12 @@
try {
agent.onDestroy();
} catch (Exception e) {
- Log.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
+ Slog.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
e.printStackTrace();
}
mBackupAgents.remove(packageName);
} else {
- Log.w(TAG, "Attempt to destroy unknown backup agent " + data);
+ Slog.w(TAG, "Attempt to destroy unknown backup agent " + data);
}
}
@@ -3284,7 +3285,7 @@
RuntimeException e = new RuntimeException(
"Performing pause of activity that is not resumed: "
+ r.intent.getComponent().toShortString());
- Log.e(TAG, e.getMessage(), e);
+ Slog.e(TAG, e.getMessage(), e);
}
Bundle state = null;
if (finished) {
@@ -3353,7 +3354,7 @@
RuntimeException e = new RuntimeException(
"Performing stop of activity that is not resumed: "
+ r.intent.getComponent().toShortString());
- Log.e(TAG, e.getMessage(), e);
+ Slog.e(TAG, e.getMessage(), e);
}
if (info != null) {
@@ -3998,13 +3999,13 @@
Debug.startMethodTracing(pcd.path, pcd.fd.getFileDescriptor(),
8 * 1024 * 1024, 0);
} catch (RuntimeException e) {
- Log.w(TAG, "Profiling failed on path " + pcd.path
+ Slog.w(TAG, "Profiling failed on path " + pcd.path
+ " -- can the process access this path?");
} finally {
try {
pcd.fd.close();
} catch (IOException e) {
- Log.w(TAG, "Failure closing profile fd", e);
+ Slog.w(TAG, "Failure closing profile fd", e);
}
}
} else {
@@ -4249,7 +4250,7 @@
} catch (RemoteException ex) {
}
if (holder == null) {
- Log.e(TAG, "Failed to find provider info for " + name);
+ Slog.e(TAG, "Failed to find provider info for " + name);
return null;
}
if (holder.permissionFailure != null) {
@@ -4419,7 +4420,7 @@
}
}
if (c == null) {
- Log.w(TAG, "Unable to get context for package " +
+ Slog.w(TAG, "Unable to get context for package " +
ai.packageName +
" while loading content provider " +
info.name);
@@ -4431,7 +4432,7 @@
loadClass(info.name).newInstance();
provider = localProvider.getIContentProvider();
if (provider == null) {
- Log.e(TAG, "Failed to instantiate class " +
+ Slog.e(TAG, "Failed to instantiate class " +
info.name + " from sourceDir " +
info.applicationInfo.sourceDir);
return null;
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java
index c134d88..599a7fe 100644
--- a/core/java/com/android/internal/os/RuntimeInit.java
+++ b/core/java/com/android/internal/os/RuntimeInit.java
@@ -18,26 +18,19 @@
import android.app.ActivityManagerNative;
import android.app.ApplicationErrorReport;
-import android.app.IActivityManager;
import android.os.Build;
import android.os.Debug;
import android.os.IBinder;
import android.os.Process;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.SystemProperties;
import android.util.Config;
import android.util.Log;
+import android.util.Slog;
import com.android.internal.logging.AndroidConfig;
import dalvik.system.VMRuntime;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.concurrent.atomic.AtomicInteger;
@@ -74,9 +67,9 @@
mCrashing = true;
if (mApplicationObject == null) {
- Log.e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
+ Slog.e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
} else {
- Log.e(TAG, "FATAL EXCEPTION: " + t.getName(), e);
+ Slog.e(TAG, "FATAL EXCEPTION: " + t.getName(), e);
}
// Bring up crash dialog, wait for it to be dismissed
@@ -84,9 +77,9 @@
mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
} catch (Throwable t2) {
try {
- Log.e(TAG, "Error reporting crash", t2);
+ Slog.e(TAG, "Error reporting crash", t2);
} catch (Throwable t3) {
- // Even Log.e() fails! Oh well.
+ // Even Slog.e() fails! Oh well.
}
} finally {
// Try everything to make sure this process goes away.
@@ -97,14 +90,14 @@
}
private static final void commonInit() {
- if (Config.LOGV) Log.d(TAG, "Entered RuntimeInit!");
+ if (Config.LOGV) Slog.d(TAG, "Entered RuntimeInit!");
/* set default handler; this applies to all threads in the VM */
Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
int hasQwerty = getQwertyKeyboard();
- if (Config.LOGV) Log.d(TAG, ">>>>> qwerty keyboard = " + hasQwerty);
+ if (Config.LOGV) Slog.d(TAG, ">>>>> qwerty keyboard = " + hasQwerty);
if (hasQwerty == 1) {
System.setProperty("qwerty", "1");
}
@@ -144,7 +137,7 @@
*/
String trace = SystemProperties.get("ro.kernel.android.tracing");
if (trace.equals("1")) {
- Log.i(TAG, "NOTE: emulator trace profiling enabled");
+ Slog.i(TAG, "NOTE: emulator trace profiling enabled");
Debug.enableEmulatorTraceOutput();
}
@@ -241,7 +234,7 @@
*/
finishInit();
- if (Config.LOGV) Log.d(TAG, "Leaving RuntimeInit!");
+ if (Config.LOGV) Slog.d(TAG, "Leaving RuntimeInit!");
}
public static final native void finishInit();
@@ -286,7 +279,7 @@
}
if (curArg == argv.length) {
- Log.e(TAG, "Missing classname argument to RuntimeInit!");
+ Slog.e(TAG, "Missing classname argument to RuntimeInit!");
// let the process exit
return;
}
@@ -334,7 +327,7 @@
System.exit(10);
}
} catch (Throwable t2) {
- Log.e(TAG, "Error reporting WTF", t2);
+ Slog.e(TAG, "Error reporting WTF", t2);
}
}