diff options
-rw-r--r-- | core/api/system-current.txt | 6 | ||||
-rw-r--r-- | core/java/android/telephony/TelephonyRegistryManager.java | 140 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 81 |
3 files changed, 21 insertions, 206 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index d5be20f326ba..77cc03c0cb39 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -11596,7 +11596,6 @@ package android.telephony { } public class TelephonyManager { - method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void addCarrierPrivilegesListener(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CarrierPrivilegesListener); method @RequiresPermission(anyOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION}) @WorkerThread public void bootstrapAuthenticationRequest(int, @NonNull android.net.Uri, @NonNull android.telephony.gba.UaSecurityProtocolIdentifier, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.BootstrapAuthenticationCallback); method @Deprecated @RequiresPermission(android.Manifest.permission.CALL_PHONE) public void call(String, String); method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.PinResult changeIccLockPin(@NonNull String, @NonNull String); @@ -11697,7 +11696,6 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.REBOOT) public int prepareForUnattendedReboot(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void registerCarrierPrivilegesCallback(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CarrierPrivilegesCallback); - method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void removeCarrierPrivilegesListener(@NonNull android.telephony.TelephonyManager.CarrierPrivilegesListener); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void reportDefaultNetworkStatus(boolean); method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestModemActivityInfo(@NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.telephony.ModemActivityInfo,android.telephony.TelephonyManager.ModemActivityInfoException>); @@ -11857,10 +11855,6 @@ package android.telephony { method public default void onCarrierServiceChanged(@Nullable String, int); } - @Deprecated public static interface TelephonyManager.CarrierPrivilegesListener { - method @Deprecated public void onCarrierPrivilegesChanged(@NonNull java.util.List<java.lang.String>, @NonNull int[]); - } - public static class TelephonyManager.ModemActivityInfoException extends java.lang.Exception { ctor public TelephonyManager.ModemActivityInfoException(int); method public int getErrorCode(); diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 0d8b1f83b7fe..9c7f23e56617 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -38,7 +38,6 @@ import android.telephony.Annotation.RadioPowerState; import android.telephony.Annotation.SimActivationState; import android.telephony.Annotation.SrvccState; import android.telephony.TelephonyManager.CarrierPrivilegesCallback; -import android.telephony.TelephonyManager.CarrierPrivilegesListener; import android.telephony.emergency.EmergencyNumber; import android.telephony.ims.ImsReasonInfo; import android.util.ArraySet; @@ -1262,149 +1261,52 @@ public class TelephonyRegistryManager { pkgName, attributionTag, callback, new int[0], notifyNow); } - // TODO(b/216549778): Remove listener logic once all clients switch to CarrierPrivilegesCallback private static class CarrierPrivilegesCallbackWrapper extends ICarrierPrivilegesCallback.Stub implements ListenerExecutor { - // Either mListener or mCallback may be null, never both - @Nullable private final WeakReference<CarrierPrivilegesListener> mListener; - @Nullable private final WeakReference<CarrierPrivilegesCallback> mCallback; + @NonNull private final WeakReference<CarrierPrivilegesCallback> mCallback; @NonNull private final Executor mExecutor; CarrierPrivilegesCallbackWrapper( @NonNull CarrierPrivilegesCallback callback, @NonNull Executor executor) { - mListener = null; mCallback = new WeakReference<>(callback); mExecutor = executor; } - CarrierPrivilegesCallbackWrapper( - @NonNull CarrierPrivilegesListener listener, @NonNull Executor executor) { - mListener = new WeakReference<>(listener); - mCallback = null; - mExecutor = executor; - } - @Override public void onCarrierPrivilegesChanged( @NonNull List<String> privilegedPackageNames, @NonNull int[] privilegedUids) { - if (mListener != null) { - Binder.withCleanCallingIdentity( - () -> - executeSafely( - mExecutor, - mListener::get, - cpl -> - cpl.onCarrierPrivilegesChanged( - privilegedPackageNames, privilegedUids))); - } - - if (mCallback != null) { - // AIDL interface does not support Set, keep the List/Array and translate them here - Set<String> privilegedPkgNamesSet = Set.copyOf(privilegedPackageNames); - Set<Integer> privilegedUidsSet = Arrays.stream(privilegedUids).boxed().collect( - Collectors.toSet()); - Binder.withCleanCallingIdentity( - () -> - executeSafely( - mExecutor, - mCallback::get, - cpc -> - cpc.onCarrierPrivilegesChanged( - privilegedPkgNamesSet, privilegedUidsSet))); - } + // AIDL interface does not support Set, keep the List/Array and translate them here + Set<String> privilegedPkgNamesSet = Set.copyOf(privilegedPackageNames); + Set<Integer> privilegedUidsSet = Arrays.stream(privilegedUids).boxed().collect( + Collectors.toSet()); + Binder.withCleanCallingIdentity( + () -> + executeSafely( + mExecutor, + mCallback::get, + cpc -> + cpc.onCarrierPrivilegesChanged( + privilegedPkgNamesSet, privilegedUidsSet))); } @Override public void onCarrierServiceChanged(@Nullable String packageName, int uid) { - if (mCallback != null) { - Binder.withCleanCallingIdentity( - () -> - executeSafely( - mExecutor, - mCallback::get, - cpc -> cpc.onCarrierServiceChanged(packageName, uid))); - } + Binder.withCleanCallingIdentity( + () -> + executeSafely( + mExecutor, + mCallback::get, + cpc -> cpc.onCarrierServiceChanged(packageName, uid))); } } - // TODO(b/216549778): Change the map key to CarrierPrivilegesCallback once all clients switch to - // CarrierPrivilegesCallback. Before that, the key is either CarrierPrivilegesCallback or - // CarrierPrivilegesListener, no logic actually depends on the type. @NonNull @GuardedBy("sCarrierPrivilegeCallbacks") - private static final WeakHashMap<Object, WeakReference<CarrierPrivilegesCallbackWrapper>> + private static final WeakHashMap<CarrierPrivilegesCallback, + WeakReference<CarrierPrivilegesCallbackWrapper>> sCarrierPrivilegeCallbacks = new WeakHashMap<>(); /** - * Registers a {@link CarrierPrivilegesListener} on the given {@code logicalSlotIndex} to - * receive callbacks when the set of packages with carrier privileges changes. The callback will - * immediately be called with the latest state. - * - * @param logicalSlotIndex The SIM slot to listen on - * @param executor The executor where {@code listener} will be invoked - * @param listener The callback to register - * - * @deprecated Use {@link #addCarrierPrivilegesCallback} instead. This API will be removed - * prior to API finalization. - */ - @Deprecated - public void addCarrierPrivilegesListener( - int logicalSlotIndex, - @NonNull @CallbackExecutor Executor executor, - @NonNull CarrierPrivilegesListener listener) { - if (listener == null || executor == null) { - throw new IllegalArgumentException("listener and executor must be non-null"); - } - synchronized (sCarrierPrivilegeCallbacks) { - WeakReference<CarrierPrivilegesCallbackWrapper> existing = - sCarrierPrivilegeCallbacks.get(listener); - if (existing != null && existing.get() != null) { - Log.d(TAG, "addCarrierPrivilegesListener: listener already registered"); - return; - } - CarrierPrivilegesCallbackWrapper wrapper = - new CarrierPrivilegesCallbackWrapper(listener, executor); - sCarrierPrivilegeCallbacks.put(listener, new WeakReference<>(wrapper)); - try { - sRegistry.addCarrierPrivilegesCallback( - logicalSlotIndex, - wrapper, - mContext.getOpPackageName(), - mContext.getAttributionTag()); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - } - - /** - * Unregisters a {@link CarrierPrivilegesListener}. - * - * @param listener The callback to unregister - * - * @deprecated Use {@link #removeCarrierPrivilegesCallback} instead. The callback will prior - * to API finalization. - */ - @Deprecated - public void removeCarrierPrivilegesListener(@NonNull CarrierPrivilegesListener listener) { - if (listener == null) { - throw new IllegalArgumentException("listener must be non-null"); - } - synchronized (sCarrierPrivilegeCallbacks) { - WeakReference<CarrierPrivilegesCallbackWrapper> ref = - sCarrierPrivilegeCallbacks.remove(listener); - if (ref == null) return; - CarrierPrivilegesCallbackWrapper wrapper = ref.get(); - if (wrapper == null) return; - try { - sRegistry.removeCarrierPrivilegesCallback(wrapper, mContext.getOpPackageName()); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - } - - /** * Registers a {@link CarrierPrivilegesCallback} on the given {@code logicalSlotIndex} to * receive callbacks when the set of packages with carrier privileges changes. The callback will * immediately be called with the latest state. diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index cdba6355e798..db1f49760865 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -16426,32 +16426,6 @@ public class TelephonyManager { } /** - * Callback to listen for when the set of packages with carrier privileges for a SIM changes. - * - * @hide - * @deprecated Use {@link CarrierPrivilegesCallback} instead. This API will be removed soon - * prior to API finalization. - */ - @Deprecated - @SystemApi - public interface CarrierPrivilegesListener { - /** - * Called when the set of packages with carrier privileges has changed. - * - * <p>Of note, this callback will <b>not</b> be fired if a carrier triggers a SIM profile - * switch and the same set of packages remains privileged after the switch. - * - * <p>At registration, the callback will receive the current set of privileged packages. - * - * @param privilegedPackageNames The updated set of package names that have carrier - * privileges - * @param privilegedUids The updated set of UIDs that have carrier privileges - */ - void onCarrierPrivilegesChanged( - @NonNull List<String> privilegedPackageNames, @NonNull int[] privilegedUids); - } - - /** * Callbacks to listen for when the set of packages with carrier privileges for a SIM changes. * * <p>Of note, when multiple callbacks are registered, they may be triggered one after another. @@ -16500,61 +16474,6 @@ public class TelephonyManager { } /** - * Registers a {@link CarrierPrivilegesListener} on the given {@code logicalSlotIndex} to - * receive callbacks when the set of packages with carrier privileges changes. The callback will - * immediately be called with the latest state. - * - * @param logicalSlotIndex The SIM slot to listen on - * @param executor The executor where {@code listener} will be invoked - * @param listener The callback to register - * @hide - * @deprecated Use {@link #registerCarrierPrivilegesCallback} instead. This API will be - * removed prior to API finalization. - */ - @Deprecated - @SystemApi - @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public void addCarrierPrivilegesListener( - int logicalSlotIndex, - @NonNull @CallbackExecutor Executor executor, - @NonNull CarrierPrivilegesListener listener) { - if (mContext == null) { - throw new IllegalStateException("Telephony service is null"); - } else if (executor == null || listener == null) { - throw new IllegalArgumentException( - "CarrierPrivilegesListener and executor must be non-null"); - } - mTelephonyRegistryMgr = mContext.getSystemService(TelephonyRegistryManager.class); - if (mTelephonyRegistryMgr == null) { - throw new IllegalStateException("Telephony registry service is null"); - } - mTelephonyRegistryMgr.addCarrierPrivilegesListener(logicalSlotIndex, executor, listener); - } - - /** - * Unregisters an existing {@link CarrierPrivilegesListener}. - * - * @hide - * @deprecated Use {@link #unregisterCarrierPrivilegesCallback} instead. This API will be - * removed prior to API finalization. - */ - @Deprecated - @SystemApi - @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public void removeCarrierPrivilegesListener(@NonNull CarrierPrivilegesListener listener) { - if (mContext == null) { - throw new IllegalStateException("Telephony service is null"); - } else if (listener == null) { - throw new IllegalArgumentException("CarrierPrivilegesListener must be non-null"); - } - mTelephonyRegistryMgr = mContext.getSystemService(TelephonyRegistryManager.class); - if (mTelephonyRegistryMgr == null) { - throw new IllegalStateException("Telephony registry service is null"); - } - mTelephonyRegistryMgr.removeCarrierPrivilegesListener(listener); - } - - /** * Registers a {@link CarrierPrivilegesCallback} on the given {@code logicalSlotIndex} to * receive callbacks when the set of packages with carrier privileges changes. The callback will * immediately be called with the latest state. |