From 95204e0be76b0646407301cca185dca4746ca713 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 89e7a696f0902f1116f3ccc7eec786aec0c5de97 Reverts parts of commit 9a5f48535d5d2972308c06d81fd55adf7e44dc49 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 803c2db83d13b..0c798ec606c70 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 =