Java Code Examples for android.content.Intent#ACTION_USER_UNLOCKED
The following examples show how to use
android.content.Intent#ACTION_USER_UNLOCKED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirebaseAppTest.java From firebase-android-sdk with Apache License 2.0 | 8 votes |
@Test public void testDirectBoot_shouldPreserveDataCollectionAfterUnlock() { Context mockContext = createForwardingMockContext(); isUserUnlocked.set(false); FirebaseApp firebaseApp = FirebaseApp.initializeApp(mockContext); assert (firebaseApp != null); firebaseApp.setDataCollectionDefaultEnabled(false); assertFalse(firebaseApp.isDataCollectionDefaultEnabled()); // User unlocks the device. isUserUnlocked.set(true); Intent userUnlockBroadcast = new Intent(Intent.ACTION_USER_UNLOCKED); localBroadcastManager.sendBroadcastSync(userUnlockBroadcast); assertFalse(firebaseApp.isDataCollectionDefaultEnabled()); firebaseApp.setDataCollectionDefaultEnabled(true); assertTrue(firebaseApp.isDataCollectionDefaultEnabled()); firebaseApp.setDataCollectionDefaultEnabled(false); assertFalse(firebaseApp.isDataCollectionDefaultEnabled()); // Because default is true. firebaseApp.setDataCollectionDefaultEnabled(null); assertTrue(firebaseApp.isDataCollectionDefaultEnabled()); }
Example 2
Source File: FirebaseApp.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
private static void ensureReceiverRegistered(Context applicationContext) { if (INSTANCE.get() == null) { UserUnlockReceiver receiver = new UserUnlockReceiver(applicationContext); if (INSTANCE.compareAndSet(null /* expected */, receiver)) { IntentFilter intentFilter = new IntentFilter(Intent.ACTION_USER_UNLOCKED); applicationContext.registerReceiver(receiver, intentFilter); } } }
Example 3
Source File: FirebaseAppTest.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
@Test public void testDirectBoot_shouldInitializeEagerComponentsOnDeviceUnlock() { Context mockContext = createForwardingMockContext(); isUserUnlocked.set(false); FirebaseApp firebaseApp = FirebaseApp.initializeApp(mockContext); InitTracker tracker = firebaseApp.get(InitTracker.class); EagerSdkVerifier sdkVerifier = firebaseApp.get(EagerSdkVerifier.class); // APIs are not initialized. assertThat(tracker.isInitialized()).isFalse(); assertThat(sdkVerifier.isAuthInitialized()).isFalse(); assertThat(sdkVerifier.isAnalyticsInitialized()).isFalse(); // User unlocks the device. isUserUnlocked.set(true); Intent userUnlockBroadcast = new Intent(Intent.ACTION_USER_UNLOCKED); localBroadcastManager.sendBroadcastSync(userUnlockBroadcast); // APIs are initialized. assertThat(tracker.isInitialized()).isTrue(); assertThat(sdkVerifier.isAuthInitialized()).isTrue(); assertThat(sdkVerifier.isAnalyticsInitialized()).isTrue(); }
Example 4
Source File: UserController.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Step from {@link UserState#STATE_RUNNING_UNLOCKING} to * {@link UserState#STATE_RUNNING_UNLOCKED}. */ void finishUserUnlocked(final UserState uss) { final int userId = uss.mHandle.getIdentifier(); // Only keep marching forward if user is actually unlocked if (!StorageManager.isUserKeyUnlocked(userId)) return; synchronized (mLock) { // Bail if we ended up with a stale user if (mStartedUsers.get(uss.mHandle.getIdentifier()) != uss) return; // Do not proceed if unexpected state if (!uss.setState(STATE_RUNNING_UNLOCKING, STATE_RUNNING_UNLOCKED)) { return; } } mInjector.getUserManagerInternal().setUserState(userId, uss.state); uss.mUnlockProgress.finish(); // Get unaware persistent apps running and start any unaware providers // in already-running apps that are partially aware if (userId == UserHandle.USER_SYSTEM) { mInjector.startPersistentApps(PackageManager.MATCH_DIRECT_BOOT_UNAWARE); } mInjector.installEncryptionUnawareProviders(userId); // Dispatch unlocked to external apps final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED); unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); unlockedIntent.addFlags( Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); mInjector.broadcastIntent(unlockedIntent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, userId); if (getUserInfo(userId).isManagedProfile()) { UserInfo parent = mInjector.getUserManager().getProfileParent(userId); if (parent != null) { final Intent profileUnlockedIntent = new Intent( Intent.ACTION_MANAGED_PROFILE_UNLOCKED); profileUnlockedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId)); profileUnlockedIntent.addFlags( Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); mInjector.broadcastIntent(profileUnlockedIntent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, parent.id); } } // Send PRE_BOOT broadcasts if user fingerprint changed; we // purposefully block sending BOOT_COMPLETED until after all // PRE_BOOT receivers are finished to avoid ANR'ing apps final UserInfo info = getUserInfo(userId); if (!Objects.equals(info.lastLoggedInFingerprint, Build.FINGERPRINT)) { // Suppress double notifications for managed profiles that // were unlocked automatically as part of their parent user // being unlocked. final boolean quiet; if (info.isManagedProfile()) { quiet = !uss.tokenProvided || !mLockPatternUtils.isSeparateProfileChallengeEnabled(userId); } else { quiet = false; } mInjector.sendPreBootBroadcast(userId, quiet, () -> finishUserUnlockedCompleted(uss)); } else { finishUserUnlockedCompleted(uss); } }