Open
Description
- Firebase Component: Common
- Component version: 20.4.2
Steps to reproduce:
Crashlytics notified us about a crash in FirebaseApp.UserUnlockReceiver.unregister
. The method is only called from FirebaseApp.UserUnlockReceiver.onReceive
which in turn only responds to android.intent.action.USER_UNLOCKED
. I don't know how many times the system sends the broadcast but it apparently isn't just once.
Relevant Code:
FirebaseApp
initialization may be idempotent but Context.unregisterReceiver
isn't. The method crashes if the receiver isn't registered.
Suggested solution
public void unregister() {
try {
applicationContext.unregisterReceiver(this);
} catch (IllegalArgumentException ignore) {
// The receiver isn't registered.
}
}