Merge changes I1731e65e,I2df84427 into main
* changes: Factorize CarrierPrivilegeAuthenticator constructors Change mCarrierServiceUid from int[] to SparseIntArray
This commit is contained in:
commit
f411c02294
1 changed files with 7 additions and 19 deletions
|
|
@ -35,6 +35,7 @@ import android.os.Process;
|
|||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
|
@ -63,7 +64,7 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver {
|
|||
private final TelephonyManagerShim mTelephonyManagerShim;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
@GuardedBy("mLock")
|
||||
private int[] mCarrierServiceUid;
|
||||
private final SparseIntArray mCarrierServiceUid = new SparseIntArray(2 /* initialCapacity */);
|
||||
@GuardedBy("mLock")
|
||||
private int mModemCount = 0;
|
||||
private final Object mLock = new Object();
|
||||
|
|
@ -75,7 +76,7 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver {
|
|||
|
||||
public CarrierPrivilegeAuthenticator(@NonNull final Context c,
|
||||
@NonNull final TelephonyManager t,
|
||||
@NonNull final TelephonyManagerShimImpl telephonyManagerShim) {
|
||||
@NonNull final TelephonyManagerShim telephonyManagerShim) {
|
||||
mContext = c;
|
||||
mTelephonyManager = t;
|
||||
mTelephonyManagerShim = telephonyManagerShim;
|
||||
|
|
@ -91,17 +92,7 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver {
|
|||
|
||||
public CarrierPrivilegeAuthenticator(@NonNull final Context c,
|
||||
@NonNull final TelephonyManager t) {
|
||||
mContext = c;
|
||||
mTelephonyManager = t;
|
||||
mTelephonyManagerShim = TelephonyManagerShimImpl.newInstance(mTelephonyManager);
|
||||
mThread = new HandlerThread(TAG);
|
||||
mThread.start();
|
||||
mHandler = new Handler(mThread.getLooper()) {};
|
||||
synchronized (mLock) {
|
||||
mModemCount = mTelephonyManager.getActiveModemCount();
|
||||
registerForCarrierChanges();
|
||||
updateCarrierServiceUid();
|
||||
}
|
||||
this(c, t, TelephonyManagerShimImpl.newInstance(t));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -233,9 +224,9 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver {
|
|||
@VisibleForTesting
|
||||
void updateCarrierServiceUid() {
|
||||
synchronized (mLock) {
|
||||
mCarrierServiceUid = new int[mModemCount];
|
||||
mCarrierServiceUid.clear();
|
||||
for (int i = 0; i < mModemCount; i++) {
|
||||
mCarrierServiceUid[i] = getCarrierServicePackageUidForSlot(i);
|
||||
mCarrierServiceUid.put(i, getCarrierServicePackageUidForSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -244,11 +235,8 @@ public class CarrierPrivilegeAuthenticator extends BroadcastReceiver {
|
|||
int getCarrierServiceUidForSubId(int subId) {
|
||||
final int slotId = getSlotIndex(subId);
|
||||
synchronized (mLock) {
|
||||
if (slotId != SubscriptionManager.INVALID_SIM_SLOT_INDEX && slotId < mModemCount) {
|
||||
return mCarrierServiceUid[slotId];
|
||||
}
|
||||
return mCarrierServiceUid.get(slotId, Process.INVALID_UID);
|
||||
}
|
||||
return Process.INVALID_UID;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
|
|||
Loading…
Reference in a new issue