diff --git a/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java b/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java index ce955fd6a4..b06c8aa8c3 100644 --- a/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java +++ b/service/src/com/android/server/connectivity/CarrierPrivilegeAuthenticator.java @@ -29,7 +29,6 @@ import android.content.pm.PackageManager; import android.net.NetworkCapabilities; import android.net.NetworkSpecifier; import android.net.TelephonyNetworkSpecifier; -import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Process; @@ -94,11 +93,7 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver { @NonNull final TelephonyManager t) { mContext = c; mTelephonyManager = t; - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S) { - mTelephonyManagerShim = new TelephonyManagerShimImpl(mTelephonyManager); - } else { - mTelephonyManagerShim = null; - } + mTelephonyManagerShim = TelephonyManagerShimImpl.newInstance(mTelephonyManager); mThread = new HandlerThread(TAG); mThread.start(); mHandler = new Handler(mThread.getLooper()) {}; @@ -192,36 +187,30 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver { private void addCarrierPrivilegesListener(int logicalSlotIndex, Executor executor, CarrierPrivilegesListenerShim listener) { - if (mTelephonyManagerShim == null) { - return; - } try { mTelephonyManagerShim.addCarrierPrivilegesListener( logicalSlotIndex, executor, listener); } catch (UnsupportedApiLevelException unsupportedApiLevelException) { + // Should not happen since CarrierPrivilegeAuthenticator is only used on T+ Log.e(TAG, "addCarrierPrivilegesListener API is not available"); } } private void removeCarrierPrivilegesListener(CarrierPrivilegesListenerShim listener) { - if (mTelephonyManagerShim == null) { - return; - } try { mTelephonyManagerShim.removeCarrierPrivilegesListener(listener); } catch (UnsupportedApiLevelException unsupportedApiLevelException) { + // Should not happen since CarrierPrivilegeAuthenticator is only used on T+ Log.e(TAG, "removeCarrierPrivilegesListener API is not available"); } } private String getCarrierServicePackageNameForLogicalSlot(int logicalSlotIndex) { - if (mTelephonyManagerShim == null) { - return null; - } try { return mTelephonyManagerShim.getCarrierServicePackageNameForLogicalSlot( logicalSlotIndex); } catch (UnsupportedApiLevelException unsupportedApiLevelException) { + // Should not happen since CarrierPrivilegeAuthenticator is only used on T+ Log.e(TAG, "getCarrierServicePackageNameForLogicalSlot API is not available"); } return null;