OSDN Git Service

Fix the error that the broadcast receiver cannot be registered
authorqingxi <qingxi@google.com>
Wed, 12 Jul 2017 20:15:51 +0000 (13:15 -0700)
committerqingxi <qingxi@google.com>
Wed, 12 Jul 2017 20:15:51 +0000 (13:15 -0700)
Factory reset of eSIM failed due to the euiccWipeFinishReceiver cannot
be registered by the context directly. This CL changes the context to
application context to solve this problem.

Bug: 63610700
Test: E2E
Change-Id: I7e4c8b75b5b5b4203efd7302677ffa5cf00198b5

core/java/android/os/RecoverySystem.java

index 2c6c7f9..1f8de04 100644 (file)
@@ -808,7 +808,8 @@ public class RecoverySystem {
             HandlerThread euiccHandlerThread = new HandlerThread("euiccWipeFinishReceiverThread");
             euiccHandlerThread.start();
             Handler euiccHandler = new Handler(euiccHandlerThread.getLooper());
-            context.registerReceiver(euiccWipeFinishReceiver, filterConsent, null, euiccHandler);
+            context.getApplicationContext()
+                    .registerReceiver(euiccWipeFinishReceiver, filterConsent, null, euiccHandler);
             if (isWipeEuicc) {
                 euiccManager.eraseSubscriptions(callbackIntent);
             } else {
@@ -831,7 +832,7 @@ public class RecoverySystem {
                         Log.e(TAG, "Timeout retaining eUICC data.");
                     }
                 }
-                context.unregisterReceiver(euiccWipeFinishReceiver);
+                context.getApplicationContext().unregisterReceiver(euiccWipeFinishReceiver);
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 if (isWipeEuicc) {