Merge "Set a default wtf handler for system_server at initialization" into rvc-dev am: 35c6b8f0ab

Change-Id: Iec5d3f8aed88e1b32f96ea6998854fde32c21179
This commit is contained in:
Jing Ji
2020-04-20 06:10:58 +00:00
committed by Automerger Merge Worker
3 changed files with 121 additions and 4 deletions

View File

@@ -21,6 +21,8 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.IServiceManager.DUMP_FLAG_PROTO;
import static android.os.Process.SYSTEM_UID;
import static android.os.Process.myPid;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.server.utils.TimingsTraceAndSlog.SYSTEM_SERVER_TIMING_TAG;
@@ -29,6 +31,7 @@ import android.annotation.NonNull;
import android.annotation.StringRes;
import android.app.ActivityThread;
import android.app.AppCompatCallbacks;
import android.app.ApplicationErrorReport;
import android.app.INotificationManager;
import android.app.SystemServiceRegistry;
import android.app.usage.UsageStatsManagerInternal;
@@ -53,6 +56,7 @@ import android.os.Debug;
import android.os.Environment;
import android.os.FactoryTest;
import android.os.FileUtils;
import android.os.IBinder;
import android.os.IIncidentManager;
import android.os.Looper;
import android.os.Message;
@@ -67,16 +71,19 @@ import android.os.UserHandle;
import android.os.storage.IStorageManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.server.ServerProtoEnums;
import android.sysprop.VoldProperties;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Pair;
import android.util.Slog;
import android.view.contentcapture.ContentCaptureManager;
import com.android.internal.R;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
import com.android.internal.util.ConcurrentUtils;
import com.android.internal.util.EmergencyAffordanceManager;
import com.android.internal.util.FrameworkStatsLog;
@@ -179,6 +186,7 @@ import com.google.android.startop.iorap.IorapForwardingService;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Timer;
import java.util.concurrent.CountDownLatch;
@@ -351,6 +359,11 @@ public final class SystemServer {
private Future<?> mZygotePreload;
private Future<?> mBlobStoreServiceStart;
/**
* The pending WTF to be logged into dropbox.
*/
private static LinkedList<Pair<String, ApplicationErrorReport.CrashInfo>> sPendingWtfs;
/**
* Start the sensor service. This is a blocking call and can take time.
*/
@@ -562,6 +575,9 @@ public final class SystemServer {
t.traceEnd(); // InitBeforeStartServices
}
// Setup the default WTF handler
RuntimeInit.setDefaultApplicationWtfHandler(SystemServer::handleEarlySystemWtf);
// Start services.
try {
t.traceBegin("StartServices");
@@ -2108,6 +2124,14 @@ public final class SystemServer {
}
t.traceEnd();
// Emit any pending system_server WTFs
synchronized (SystemService.class) {
if (sPendingWtfs != null) {
mActivityManagerService.schedulePendingSystemServerWtfs(sPendingWtfs);
sPendingWtfs = null;
}
}
if (safeMode) {
mActivityManagerService.showSafeModeOverlay();
}
@@ -2497,4 +2521,29 @@ public final class SystemServer {
context.startServiceAsUser(intent, UserHandle.SYSTEM);
windowManager.onSystemUiStarted();
}
/**
* Handle the serious errors during early system boot, used by {@link Log} via
* {@link com.android.internal.os.RuntimeInit}.
*/
private static boolean handleEarlySystemWtf(final IBinder app, final String tag, boolean system,
final ApplicationErrorReport.ParcelableCrashInfo crashInfo, int immediateCallerPid) {
final String processName = "system_server";
final int myPid = myPid();
com.android.server.am.EventLogTags.writeAmWtf(UserHandle.getUserId(SYSTEM_UID), myPid,
processName, -1, tag, crashInfo.exceptionMessage);
FrameworkStatsLog.write(FrameworkStatsLog.WTF_OCCURRED, SYSTEM_UID, tag, processName,
myPid, ServerProtoEnums.SYSTEM_SERVER);
synchronized (SystemServer.class) {
if (sPendingWtfs == null) {
sPendingWtfs = new LinkedList<>();
}
sPendingWtfs.add(new Pair<>(tag, crashInfo));
}
return false;
}
}