Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95204e0b authored by Robin Lee's avatar Robin Lee
Browse files

Reinstate USER_PRESENT for ConnectivityService

Reverts half of commit 89e7a696
Reverts parts of commit 9a5f4853

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
parent b8bbd302
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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<Messenger, NetworkFactoryInfo> mNetworkFactoryInfos =
            new HashMap<Messenger, NetworkFactoryInfo>();
    private final HashMap<NetworkRequest, NetworkRequestInfo> mNetworkRequests =