зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1501648 - Prevent crashes for unregistered receivers from MmaDelegate and GeckoMediaControlAgent; r=jchen,JanH
Although this two receivers are guarded by checks for if they were initialized (and so registered) there are reports of crashes because of trying to unregister them without them actually being registered. The underlying issue will be investigated further in bug 1505685 but for the moment wrapping the unregister operations in a try-catch saves the users from a crash and because the unregister is done when the app is closed (for the MmaDelegate receiver) or when the app finished playing media (for the GeckoMediaControlAgent receiver) the user doesn't loose any functionality going forward. Differential Revision: https://phabricator.services.mozilla.com/D11177 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8da710e1bf
Коммит
c18e433f14
|
@ -541,7 +541,16 @@ public class GeckoMediaControlAgent {
|
|||
}
|
||||
|
||||
void unregisterReceiver(Context context) {
|
||||
context.unregisterReceiver(HeadSetStateReceiver.this);
|
||||
try {
|
||||
// TODO investigate why the receiver would not be registered - bug 1505685
|
||||
context.unregisterReceiver(HeadSetStateReceiver.this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (AppConstants.RELEASE_OR_BETA) {
|
||||
Log.w(LOGTAG, "bug 1505685", e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,9 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.Experiments;
|
||||
import org.mozilla.gecko.MmaConstants;
|
||||
import org.mozilla.gecko.PrefsHelper;
|
||||
|
@ -298,7 +300,16 @@ public class MmaDelegate {
|
|||
|
||||
private static void unregisterInstalledPackagesReceiver(@NonNull final Activity activity) {
|
||||
if (packageAddedReceiver != null) {
|
||||
activity.unregisterReceiver(packageAddedReceiver);
|
||||
try {
|
||||
// TODO investigate why the receiver would not be registered - bug 1505685
|
||||
activity.unregisterReceiver(packageAddedReceiver);
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (AppConstants.RELEASE_OR_BETA) {
|
||||
Log.w(TAG, "bug 1505685", e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
packageAddedReceiver = null;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче