Add APIs to remove sub from a group and get subs in the same gorup.
Add APIs in SubscriptionController so that caller with permissions can remove subscriptions from a group or get all subscriptions with the same group. Bug: 118349116 Test: unittest Change-Id: Iba4d31b437b372b3f41a6ed23f03b96a685a324c Merged-In: Iba4d31b437b372b3f41a6ed23f03b96a685a324c
This commit is contained in:
@@ -42869,12 +42869,14 @@ package android.telephony {
|
|||||||
method public static int getSlotIndex(int);
|
method public static int getSlotIndex(int);
|
||||||
method public int[] getSubscriptionIds(int);
|
method public int[] getSubscriptionIds(int);
|
||||||
method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int);
|
method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int);
|
||||||
|
method public java.util.List<android.telephony.SubscriptionInfo> getSubscriptionsInGroup(int);
|
||||||
method public boolean isActiveSubscriptionId(int);
|
method public boolean isActiveSubscriptionId(int);
|
||||||
method public boolean isNetworkRoaming(int);
|
method public boolean isNetworkRoaming(int);
|
||||||
method public static boolean isUsableSubscriptionId(int);
|
method public static boolean isUsableSubscriptionId(int);
|
||||||
method public static boolean isValidSubscriptionId(int);
|
method public static boolean isValidSubscriptionId(int);
|
||||||
method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener);
|
method public void removeOnOpportunisticSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener);
|
||||||
method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
|
method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
|
||||||
|
method public boolean removeSubscriptionsFromGroup(int[]);
|
||||||
method public java.lang.String setSubscriptionGroup(int[]);
|
method public java.lang.String setSubscriptionGroup(int[]);
|
||||||
method public void setSubscriptionOverrideCongested(int, boolean, long);
|
method public void setSubscriptionOverrideCongested(int, boolean, long);
|
||||||
method public void setSubscriptionOverrideUnmetered(int, boolean, long);
|
method public void setSubscriptionOverrideUnmetered(int, boolean, long);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package android.telephony;
|
|||||||
import static android.net.NetworkPolicyManager.OVERRIDE_CONGESTED;
|
import static android.net.NetworkPolicyManager.OVERRIDE_CONGESTED;
|
||||||
import static android.net.NetworkPolicyManager.OVERRIDE_UNMETERED;
|
import static android.net.NetworkPolicyManager.OVERRIDE_UNMETERED;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.CallbackExecutor;
|
import android.annotation.CallbackExecutor;
|
||||||
import android.annotation.DurationMillisLong;
|
import android.annotation.DurationMillisLong;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -2389,16 +2390,21 @@ public class SubscriptionManager {
|
|||||||
* together, some of them may be invisible to the users, etc.
|
* together, some of them may be invisible to the users, etc.
|
||||||
*
|
*
|
||||||
* Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE}
|
* Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE}
|
||||||
* permission or can manage all subscriptions in the list, according to their
|
* permission or had carrier privilege permission on the subscriptions:
|
||||||
* acess rules.
|
* {@link TelephonyManager#hasCarrierPrivileges(int)} or
|
||||||
|
* {@link #canManageSubscription(SubscriptionInfo)}
|
||||||
|
*
|
||||||
|
* @throws SecurityException if the caller doesn't meet the requirements
|
||||||
|
* outlined above.
|
||||||
*
|
*
|
||||||
* @param subIdList list of subId that will be in the same group
|
* @param subIdList list of subId that will be in the same group
|
||||||
* @return groupUUID a UUID assigned to the subscription group. It returns
|
* @return groupUUID a UUID assigned to the subscription group. It returns
|
||||||
* null if fails.
|
* null if fails.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
public String setSubscriptionGroup(int[] subIdList) {
|
public @Nullable String setSubscriptionGroup(@NonNull int[] subIdList) {
|
||||||
String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
|
String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
logd("[setSubscriptionGroup]+ subIdList:" + Arrays.toString(subIdList));
|
logd("[setSubscriptionGroup]+ subIdList:" + Arrays.toString(subIdList));
|
||||||
@@ -2417,6 +2423,80 @@ public class SubscriptionManager {
|
|||||||
return groupUUID;
|
return groupUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a list of subscriptions from their subscription group.
|
||||||
|
* See {@link #setSubscriptionGroup(int[])} for more details.
|
||||||
|
*
|
||||||
|
* Caller will either have {@link android.Manifest.permission#MODIFY_PHONE_STATE}
|
||||||
|
* permission or had carrier privilege permission on the subscriptions:
|
||||||
|
* {@link TelephonyManager#hasCarrierPrivileges(int)} or
|
||||||
|
* {@link #canManageSubscription(SubscriptionInfo)}
|
||||||
|
*
|
||||||
|
* @throws SecurityException if the caller doesn't meet the requirements
|
||||||
|
* outlined above.
|
||||||
|
*
|
||||||
|
* @param subIdList list of subId that need removing from their groups.
|
||||||
|
* @return whether the operation succeeds.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||||
|
@RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
|
public boolean removeSubscriptionsFromGroup(@NonNull int[] subIdList) {
|
||||||
|
String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
|
||||||
|
if (VDBG) {
|
||||||
|
logd("[removeSubscriptionsFromGroup]+ subIdList:" + Arrays.toString(subIdList));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
|
||||||
|
if (iSub != null) {
|
||||||
|
return iSub.removeSubscriptionsFromGroup(subIdList, pkgForDebug);
|
||||||
|
}
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
// ignore it
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get subscriptionInfo list of subscriptions that are in the same group of given subId.
|
||||||
|
* See {@link #setSubscriptionGroup(int[])} for more details.
|
||||||
|
*
|
||||||
|
* Caller will either have {@link android.Manifest.permission#READ_PHONE_STATE}
|
||||||
|
* permission or had carrier privilege permission on the subscription.
|
||||||
|
* {@link TelephonyManager#hasCarrierPrivileges(int)}
|
||||||
|
*
|
||||||
|
* @throws SecurityException if the caller doesn't meet the requirements
|
||||||
|
* outlined above.
|
||||||
|
*
|
||||||
|
* @param subId of which list of subInfo from the same group will be returned.
|
||||||
|
* @return list of subscriptionInfo that belong to the same group, including the given
|
||||||
|
* subscription itself. It will return null if the subscription doesn't exist or it
|
||||||
|
* doesn't belong to any group.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||||
|
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
|
||||||
|
public @Nullable List<SubscriptionInfo> getSubscriptionsInGroup(int subId) {
|
||||||
|
String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
|
||||||
|
if (VDBG) {
|
||||||
|
logd("[getSubscriptionsInGroup]+ subId:" + subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SubscriptionInfo> result = null;
|
||||||
|
try {
|
||||||
|
ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
|
||||||
|
if (iSub != null) {
|
||||||
|
result = iSub.getSubscriptionsInGroup(subId, pkgForDebug);
|
||||||
|
}
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
// ignore it
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set metered by simInfo index
|
* Set metered by simInfo index
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6603,7 +6603,7 @@ public class TelephonyManager {
|
|||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
if (telephony != null) {
|
if (telephony != null) {
|
||||||
return telephony.getCarrierPrivilegeStatus(mSubId) ==
|
return telephony.getCarrierPrivilegeStatus(subId) ==
|
||||||
CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
|
CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
|
||||||
}
|
}
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ interface ISub {
|
|||||||
*/
|
*/
|
||||||
List<SubscriptionInfo> getOpportunisticSubscriptions(String callingPackage);
|
List<SubscriptionInfo> getOpportunisticSubscriptions(String callingPackage);
|
||||||
|
|
||||||
|
boolean removeSubscriptionsFromGroup(in int[] subIdList, String callingPackage);
|
||||||
|
|
||||||
|
List<SubscriptionInfo> getSubscriptionsInGroup(int subId, String callingPackage);
|
||||||
|
|
||||||
int getSlotIndex(int subId);
|
int getSlotIndex(int subId);
|
||||||
|
|
||||||
int[] getSubId(int slotIndex);
|
int[] getSubId(int slotIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user