Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +7 −9 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi IntentFilter filter = new IntentFilter(); filter.addAction(KeyChain.ACTION_TRUST_STORE_CHANGED); filter.addAction(Intent.ACTION_USER_UNLOCKED); context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, bgHandler); Loading Loading @@ -298,14 +299,11 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi } else { mVpnUserId = mCurrentUserId; } refreshCACerts(); fireCallbacks(); } private void refreshCACerts() { new CACertLoader().execute(mCurrentUserId); int workProfileId = getWorkProfileUserId(mCurrentUserId); if (workProfileId != UserHandle.USER_NULL) new CACertLoader().execute(workProfileId); private void refreshCACerts(int userId) { new CACertLoader().execute(userId); } private String getNameForVpnConfig(VpnConfig cfg, UserHandle user) { Loading Loading @@ -401,7 +399,10 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (KeyChain.ACTION_TRUST_STORE_CHANGED.equals(intent.getAction())) { refreshCACerts(); refreshCACerts(getSendingUserId()); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId != UserHandle.USER_NULL) refreshCACerts(userId); } } }; Loading @@ -416,9 +417,6 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi return new Pair<Integer, Boolean>(userId[0], hasCACerts); } catch (RemoteException | InterruptedException | AssertionError e) { Log.i(TAG, "failed to get CA certs", e); mBgHandler.postDelayed( () -> new CACertLoader().execute(userId[0]), CA_CERT_LOADING_RETRY_TIME_IN_MS); return new Pair<Integer, Boolean>(userId[0], null); } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SecurityControllerTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -93,9 +93,9 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon when(mKeyChainService.queryLocalInterface("android.security.IKeyChainService")) .thenReturn(mKeyChainService); // Wait for callbacks from 1) the CACertLoader and 2) the onUserSwitched() function in the // Wait for callbacks from the onUserSwitched() function in the // constructor of mSecurityController mStateChangedLatch = new CountDownLatch(2); mStateChangedLatch = new CountDownLatch(1); // TODO: Migrate this test to TestableLooper and use a handler attached // to that. mSecurityController = new SecurityControllerImpl(mContext, Loading Loading @@ -169,7 +169,6 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon assertTrue(mSecurityController.hasCACertInCurrentUser()); // Exception mStateChangedLatch = new CountDownLatch(1); when(mKeyChainService.getUserCaAliases()) Loading @@ -181,9 +180,12 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon assertFalse(mStateChangedLatch.await(1, TimeUnit.SECONDS)); assertTrue(mSecurityController.hasCACertInCurrentUser()); // The retry takes 30s //assertTrue(mStateChangedLatch.await(31, TimeUnit.SECONDS)); //assertFalse(mSecurityController.hasCACertInCurrentUser()); mSecurityController.new CACertLoader() .execute(0); assertTrue(mStateChangedLatch.await(1, TimeUnit.SECONDS)); assertFalse(mSecurityController.hasCACertInCurrentUser()); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +7 −9 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi IntentFilter filter = new IntentFilter(); filter.addAction(KeyChain.ACTION_TRUST_STORE_CHANGED); filter.addAction(Intent.ACTION_USER_UNLOCKED); context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, bgHandler); Loading Loading @@ -298,14 +299,11 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi } else { mVpnUserId = mCurrentUserId; } refreshCACerts(); fireCallbacks(); } private void refreshCACerts() { new CACertLoader().execute(mCurrentUserId); int workProfileId = getWorkProfileUserId(mCurrentUserId); if (workProfileId != UserHandle.USER_NULL) new CACertLoader().execute(workProfileId); private void refreshCACerts(int userId) { new CACertLoader().execute(userId); } private String getNameForVpnConfig(VpnConfig cfg, UserHandle user) { Loading Loading @@ -401,7 +399,10 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (KeyChain.ACTION_TRUST_STORE_CHANGED.equals(intent.getAction())) { refreshCACerts(); refreshCACerts(getSendingUserId()); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId != UserHandle.USER_NULL) refreshCACerts(userId); } } }; Loading @@ -416,9 +417,6 @@ public class SecurityControllerImpl extends CurrentUserTracker implements Securi return new Pair<Integer, Boolean>(userId[0], hasCACerts); } catch (RemoteException | InterruptedException | AssertionError e) { Log.i(TAG, "failed to get CA certs", e); mBgHandler.postDelayed( () -> new CACertLoader().execute(userId[0]), CA_CERT_LOADING_RETRY_TIME_IN_MS); return new Pair<Integer, Boolean>(userId[0], null); } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SecurityControllerTest.java +8 −6 Original line number Diff line number Diff line Loading @@ -93,9 +93,9 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon when(mKeyChainService.queryLocalInterface("android.security.IKeyChainService")) .thenReturn(mKeyChainService); // Wait for callbacks from 1) the CACertLoader and 2) the onUserSwitched() function in the // Wait for callbacks from the onUserSwitched() function in the // constructor of mSecurityController mStateChangedLatch = new CountDownLatch(2); mStateChangedLatch = new CountDownLatch(1); // TODO: Migrate this test to TestableLooper and use a handler attached // to that. mSecurityController = new SecurityControllerImpl(mContext, Loading Loading @@ -169,7 +169,6 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon assertTrue(mSecurityController.hasCACertInCurrentUser()); // Exception mStateChangedLatch = new CountDownLatch(1); when(mKeyChainService.getUserCaAliases()) Loading @@ -181,9 +180,12 @@ public class SecurityControllerTest extends SysuiTestCase implements SecurityCon assertFalse(mStateChangedLatch.await(1, TimeUnit.SECONDS)); assertTrue(mSecurityController.hasCACertInCurrentUser()); // The retry takes 30s //assertTrue(mStateChangedLatch.await(31, TimeUnit.SECONDS)); //assertFalse(mSecurityController.hasCACertInCurrentUser()); mSecurityController.new CACertLoader() .execute(0); assertTrue(mStateChangedLatch.await(1, TimeUnit.SECONDS)); assertFalse(mSecurityController.hasCACertInCurrentUser()); } @Test Loading