Skip to content

Initialize Firebase in direct boot mode #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions firebase-common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="${applicationId}.firebaseinitprovider"
android:directBootAware="true"
android:exported="false"
android:initOrder="100" />
<service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ public static FirebaseApp initializeApp(
* @param options represents the global {@link FirebaseOptions}
* @param name unique name for the app. It is an error to initialize an app with an already
* existing name. Starting and ending whitespace characters in the name are ignored (trimmed).
* @throws IllegalStateException if an app with the same name has already been initialized.
* @return an instance of {@link FirebaseApp}
* @throws IllegalStateException if an app with the same name has already been initialized.
*/
@NonNull
public static FirebaseApp initializeApp(
Expand Down Expand Up @@ -395,8 +395,8 @@ public void setDataCollectionDefaultEnabled(Boolean enabled) {
* <p>Note: this value is respected by all SDKs unless overridden by the developer via SDK
* specific mechanisms.
*
* @deprecated Use {@link #setDataCollectionDefaultEnabled(Boolean)} instead.
* @hide
* @deprecated Use {@link #setDataCollectionDefaultEnabled(Boolean)} instead.
*/
@KeepForSdk
@Deprecated
Expand Down Expand Up @@ -467,8 +467,8 @@ private void notifyBackgroundStateChangeListeners(boolean background) {
* <p>If automatic resource management is enabled and the app is in the background a callback is
* triggered immediately.
*
* @see BackgroundStateChangeListener
* @hide
* @see BackgroundStateChangeListener
*/
@KeepForSdk
public void addBackgroundStateChangeListener(BackgroundStateChangeListener listener) {
Expand Down Expand Up @@ -572,9 +572,14 @@ private static List<String> getAllAppNames() {
private void initializeAllApis() {
boolean inDirectBoot = !UserManagerCompat.isUserUnlocked(applicationContext);
if (inDirectBoot) {
Log.i(
LOG_TAG,
"Device in Direct Boot Mode: postponing initialization of Firebase APIs for app "
+ getName());
// Ensure that all APIs are initialized once the user unlocks the phone.
UserUnlockReceiver.ensureReceiverRegistered(applicationContext);
} else {
Log.i(LOG_TAG, "Device unlocked: initializing all Firebase APIs for app " + getName());
componentRuntime.initializeEagerComponents(isDefaultApp());
}
}
Expand Down Expand Up @@ -686,6 +691,7 @@ public void onBackgroundStateChanged(boolean background) {
}

private static class UiExecutor implements Executor {

private static final Handler HANDLER = new Handler(Looper.getMainLooper());

@Override
Expand Down