From 2c61d9ebf14b7eb2775022939813736bef17037f Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Fri, 27 Jan 2017 11:59:22 +0000 Subject: [PATCH] Reinstate USER_PRESENT for ConnectivityService Reverts half of commit 224743c6b7a2e1fef48a96e5f0b82efe33e4d1bb Reverts parts of commit 4908ef3e42a149ae4d93d33a3b39d6d96c1ae5c1 Lockdown VPN still needs this to start properly on devices without FBE, such as phones upgraded from M. Without listening to USER_PRESENT the first unlock of keystore may get missed, since USER_UNLOCKED is sent too soon to be useful. Bug: 34587043 Change-Id: If7a2f5a3173b0f6856244a5f7904bf00c9a5b5e7 --- .../java/com/android/server/ConnectivityService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 803c2db83d..0c798ec606 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -815,6 +815,8 @@ public class ConnectivityService extends IConnectivityManager.Stub intentFilter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser( mUserIntentReceiver, UserHandle.ALL, intentFilter, null, null); + mContext.registerReceiverAsUser(mUserPresentReceiver, UserHandle.SYSTEM, + new IntentFilter(Intent.ACTION_USER_PRESENT), null, null); try { mNetd.registerObserver(mTethering); @@ -4000,6 +4002,16 @@ public class ConnectivityService extends IConnectivityManager.Stub } }; + private BroadcastReceiver mUserPresentReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + // Try creating lockdown tracker, since user present usually means + // unlocked keystore. + updateLockdownVpn(); + mContext.unregisterReceiver(this); + } + }; + private final HashMap mNetworkFactoryInfos = new HashMap(); private final HashMap mNetworkRequests =