Update the carrier service UID when onCarrierServiceChanged
Tests show that when the carrier service package changes, sometimes
neither onCarrierPrivilegesChanged is called nor the
ACTION_MULTI_SIM_CONFIG_CHANGED broadcast is sent.
Because updating synchronously can be done at any time, it's a
strict improvement to also do it onCarrierServiceChanged.
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: I9525bfe074dd686720d50e19be15529b248e9dbb
diff --git a/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java b/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java
index 90fc0fa..e40b8d4 100644
--- a/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java
+++ b/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java
@@ -21,6 +21,7 @@
import static com.android.server.connectivity.ConnectivityFlags.CARRIER_SERVICE_CHANGED_USE_CALLBACK;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -139,6 +140,15 @@
// with the onSubscriptionsChangedListener and broadcasts.
updateCarrierServiceUid();
}
+ @Override
+ public void onCarrierServiceChanged(
+ @Nullable final String carrierServicePackageName,
+ final int carrierServiceUid) {
+ // Re-trigger the synchronous check (which is also very cheap due
+ // to caching in CarrierPrivilegesTracker). This allows consistency
+ // with the onSubscriptionsChangedListener and broadcasts.
+ updateCarrierServiceUid();
+ }
};
addCarrierPrivilegesListener(i, executor, carrierPrivilegesListener);
mCarrierPrivilegesChangedListeners.add(carrierPrivilegesListener);