From e095d2f708a7be623caf1547ee587f66907d217c Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 26 Apr 2016 14:35:54 -0700 Subject: [PATCH] Stop user faster and clear stale broadcasts Moved several USER_STOPPING registered receivers to listen to USER_STOPPED, since they don't need to be blocking the shutdown of the user. Clear all stale broadcasts when stopping a user, so that we don't unnecessarily start up processes and deliver stale broadcasts. This was causing code to run when the user was already stopped and resulted in crashes when other providers and services couldn't be started anymore. Hopefully this fixes many of those races. Bug: 28371487 Change-Id: Ic35a7a23fa8fe009a53f8bf7545d4dad5fa34134 --- .../core/java/com/android/server/ConnectivityService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 0287332bb5..d85827e990 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -730,7 +730,7 @@ public class ConnectivityService extends IConnectivityManager.Stub //set up the listener for user state for creating user VPNs IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_USER_STARTING); - intentFilter.addAction(Intent.ACTION_USER_STOPPING); + intentFilter.addAction(Intent.ACTION_USER_STOPPED); intentFilter.addAction(Intent.ACTION_USER_ADDED); intentFilter.addAction(Intent.ACTION_USER_REMOVED); intentFilter.addAction(Intent.ACTION_USER_UNLOCKED); @@ -3619,7 +3619,7 @@ public class ConnectivityService extends IConnectivityManager.Stub synchronized(mVpns) { Vpn userVpn = mVpns.get(userId); if (userVpn == null) { - loge("Stopping user has no VPN"); + loge("Stopped user has no VPN"); return; } mVpns.delete(userId); @@ -3664,7 +3664,7 @@ public class ConnectivityService extends IConnectivityManager.Stub if (Intent.ACTION_USER_STARTING.equals(action)) { onUserStart(userId); - } else if (Intent.ACTION_USER_STOPPING.equals(action)) { + } else if (Intent.ACTION_USER_STOPPED.equals(action)) { onUserStop(userId); } else if (Intent.ACTION_USER_ADDED.equals(action)) { onUserAdded(userId);