Merge "Check Carrier Privilege on Hidden Subs"
This commit is contained in:
@@ -2116,29 +2116,36 @@ public class SubscriptionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO(b/137102918) Make this static, tests use this as an instance method currently.
|
||||||
|
*
|
||||||
* @return the list of subId's that are active,
|
* @return the list of subId's that are active,
|
||||||
* is never null but the length maybe 0.
|
* is never null but the length maybe 0.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public @NonNull int[] getActiveSubscriptionIdList() {
|
public @NonNull int[] getActiveSubscriptionIdList() {
|
||||||
int[] subId = null;
|
return getActiveSubscriptionIdList(/* visibleOnly */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO(b/137102918) Make this static, tests use this as an instance method currently.
|
||||||
|
*
|
||||||
|
* @return a non-null list of subId's that are active.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public @NonNull int[] getActiveSubscriptionIdList(boolean visibleOnly) {
|
||||||
try {
|
try {
|
||||||
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
|
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
|
||||||
if (iSub != null) {
|
if (iSub != null) {
|
||||||
subId = iSub.getActiveSubIdList(/*visibleOnly*/true);
|
int[] subId = iSub.getActiveSubIdList(visibleOnly);
|
||||||
|
if (subId != null) return subId;
|
||||||
}
|
}
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
// ignore it
|
// ignore it
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subId == null) {
|
return new int[0];
|
||||||
subId = new int[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return subId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -593,26 +593,21 @@ public final class TelephonyPermissions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns whether the provided uid has carrier privileges for any active subscription ID. */
|
||||||
* Returns whether the provided uid has carrier privileges for any active subscription ID.
|
private static boolean checkCarrierPrivilegeForAnySubId(
|
||||||
*/
|
Context context, Supplier<ITelephony> telephonySupplier, int uid) {
|
||||||
private static boolean checkCarrierPrivilegeForAnySubId(Context context,
|
|
||||||
Supplier<ITelephony> telephonySupplier, int uid) {
|
|
||||||
SubscriptionManager sm = (SubscriptionManager) context.getSystemService(
|
SubscriptionManager sm = (SubscriptionManager) context.getSystemService(
|
||||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||||
int[] activeSubIds = sm.getActiveSubscriptionIdList();
|
int[] activeSubIds = sm.getActiveSubscriptionIdList(/* visibleOnly */ false);
|
||||||
if (activeSubIds != null) {
|
for (int activeSubId : activeSubIds) {
|
||||||
for (int activeSubId : activeSubIds) {
|
if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid)
|
||||||
if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid)
|
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
|
||||||
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int getCarrierPrivilegeStatus(
|
private static int getCarrierPrivilegeStatus(
|
||||||
Supplier<ITelephony> telephonySupplier, int subId, int uid) {
|
Supplier<ITelephony> telephonySupplier, int subId, int uid) {
|
||||||
ITelephony telephony = telephonySupplier.get();
|
ITelephony telephony = telephonySupplier.get();
|
||||||
|
|||||||
Reference in New Issue
Block a user