Merge "add setMetered in SubscriptionManager"
This commit is contained in:
@@ -149,6 +149,11 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private String mGroupUUID;
|
private String mGroupUUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property in opportunistic subscription to indicate whether it is metered or not.
|
||||||
|
*/
|
||||||
|
private boolean mIsMetered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -158,7 +163,7 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
@Nullable UiccAccessRule[] accessRules, String cardId) {
|
@Nullable UiccAccessRule[] accessRules, String cardId) {
|
||||||
this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
|
this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
|
||||||
roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardId,
|
roaming, icon, mcc, mnc, countryIso, isEmbedded, accessRules, cardId,
|
||||||
false, null);
|
false, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +173,7 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
|
CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
|
||||||
Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
|
Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
|
||||||
@Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic,
|
@Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic,
|
||||||
@Nullable String groupUUID) {
|
@Nullable String groupUUID, boolean isMetered) {
|
||||||
this.mId = id;
|
this.mId = id;
|
||||||
this.mIccId = iccId;
|
this.mIccId = iccId;
|
||||||
this.mSimSlotIndex = simSlotIndex;
|
this.mSimSlotIndex = simSlotIndex;
|
||||||
@@ -187,8 +192,10 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
this.mCardId = cardId;
|
this.mCardId = cardId;
|
||||||
this.mIsOpportunistic = isOpportunistic;
|
this.mIsOpportunistic = isOpportunistic;
|
||||||
this.mGroupUUID = groupUUID;
|
this.mGroupUUID = groupUUID;
|
||||||
|
this.mIsMetered = isMetered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the subscription ID.
|
* @return the subscription ID.
|
||||||
*/
|
*/
|
||||||
@@ -402,6 +409,18 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
return mGroupUUID;
|
return mGroupUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in opportunistic subscription ({@link #isOpportunistic()}) to indicate whether it's
|
||||||
|
* metered or not.This is one of the factors when deciding to switch to the subscription.
|
||||||
|
* (a non-metered subscription, for example, would likely be preferred over a metered one).
|
||||||
|
*
|
||||||
|
* @return whether subscription is metered.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean isMetered() {
|
||||||
|
return mIsMetered;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the app with the given context is authorized to manage this subscription
|
* Checks whether the app with the given context is authorized to manage this subscription
|
||||||
* according to its metadata. Only supported for embedded subscriptions (if {@link #isEmbedded}
|
* according to its metadata. Only supported for embedded subscriptions (if {@link #isEmbedded}
|
||||||
@@ -496,10 +515,11 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
String cardId = source.readString();
|
String cardId = source.readString();
|
||||||
boolean isOpportunistic = source.readBoolean();
|
boolean isOpportunistic = source.readBoolean();
|
||||||
String groupUUID = source.readString();
|
String groupUUID = source.readString();
|
||||||
|
boolean isMetered = source.readBoolean();
|
||||||
|
|
||||||
return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
|
return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
|
||||||
nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
|
nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
|
||||||
isEmbedded, accessRules, cardId, isOpportunistic, groupUUID);
|
isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -528,6 +548,7 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
dest.writeString(mCardId);
|
dest.writeString(mCardId);
|
||||||
dest.writeBoolean(mIsOpportunistic);
|
dest.writeBoolean(mIsOpportunistic);
|
||||||
dest.writeString(mGroupUUID);
|
dest.writeString(mGroupUUID);
|
||||||
|
dest.writeBoolean(mIsMetered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -561,14 +582,14 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
+ " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
|
+ " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
|
||||||
+ " accessRules " + Arrays.toString(mAccessRules)
|
+ " accessRules " + Arrays.toString(mAccessRules)
|
||||||
+ " cardId=" + cardIdToPrint + " isOpportunistic " + mIsOpportunistic
|
+ " cardId=" + cardIdToPrint + " isOpportunistic " + mIsOpportunistic
|
||||||
+ " mGroupUUID=" + mGroupUUID + "}";
|
+ " mGroupUUID=" + mGroupUUID + " isMetered=" + mIsMetered + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
|
return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
|
||||||
mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc, mCountryIso,
|
mIsOpportunistic, mGroupUUID, mIsMetered, mIccId, mNumber, mMcc, mMnc,
|
||||||
mCardId, mDisplayName, mCarrierName, mAccessRules);
|
mCountryIso, mCardId, mDisplayName, mCarrierName, mAccessRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -591,6 +612,7 @@ public class SubscriptionInfo implements Parcelable {
|
|||||||
&& mIsEmbedded == toCompare.mIsEmbedded
|
&& mIsEmbedded == toCompare.mIsEmbedded
|
||||||
&& mIsOpportunistic == toCompare.mIsOpportunistic
|
&& mIsOpportunistic == toCompare.mIsOpportunistic
|
||||||
&& Objects.equals(mGroupUUID, toCompare.mGroupUUID)
|
&& Objects.equals(mGroupUUID, toCompare.mGroupUUID)
|
||||||
|
&& mIsMetered == toCompare.mIsMetered
|
||||||
&& Objects.equals(mIccId, toCompare.mIccId)
|
&& Objects.equals(mIccId, toCompare.mIccId)
|
||||||
&& Objects.equals(mNumber, toCompare.mNumber)
|
&& Objects.equals(mNumber, toCompare.mNumber)
|
||||||
&& Objects.equals(mMcc, toCompare.mMcc)
|
&& Objects.equals(mMcc, toCompare.mMcc)
|
||||||
|
|||||||
@@ -567,7 +567,6 @@ public class SubscriptionManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String IS_OPPORTUNISTIC = "is_opportunistic";
|
public static final String IS_OPPORTUNISTIC = "is_opportunistic";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TelephonyProvider column name for subId of parent subscription of an opportunistic
|
* TelephonyProvider column name for subId of parent subscription of an opportunistic
|
||||||
* subscription.
|
* subscription.
|
||||||
@@ -575,7 +574,6 @@ public class SubscriptionManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String PARENT_SUB_ID = "parent_sub_id";
|
public static final String PARENT_SUB_ID = "parent_sub_id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TelephonyProvider column name for group ID. Subscriptions with same group ID
|
* TelephonyProvider column name for group ID. Subscriptions with same group ID
|
||||||
* are considered bundled together, and should behave as a single subscription at
|
* are considered bundled together, and should behave as a single subscription at
|
||||||
@@ -584,7 +582,12 @@ public class SubscriptionManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String GROUP_UUID = "group_uuid";
|
public static final String GROUP_UUID = "group_uuid";
|
||||||
|
/**
|
||||||
|
* TelephonyProvider column name for whether a subscription is metered or not, that is, whether
|
||||||
|
* the network it connects to charges for subscription or not. For example, paid CBRS or unpaid.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String IS_METERED = "is_metered";
|
||||||
/**
|
/**
|
||||||
* Broadcast Action: The user has changed one of the default subs related to
|
* Broadcast Action: The user has changed one of the default subs related to
|
||||||
* data, phone calls, or sms</p>
|
* data, phone calls, or sms</p>
|
||||||
@@ -2411,6 +2414,21 @@ public class SubscriptionManager {
|
|||||||
return groupUUID;
|
return groupUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set metered by simInfo index
|
||||||
|
*
|
||||||
|
* @param isMetered whether it’s a metered subscription.
|
||||||
|
* @param subId the unique SubscriptionInfo index in database
|
||||||
|
* @return the number of records updated
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
|
public int setMetered(boolean isMetered, int subId) {
|
||||||
|
if (VDBG) logd("[setIsMetered]+ isMetered:" + isMetered + " subId:" + subId);
|
||||||
|
return setSubscriptionPropertyHelper(subId, "setIsMetered",
|
||||||
|
(iSub)-> iSub.setMetered(isMetered, subId));
|
||||||
|
}
|
||||||
|
|
||||||
private interface CallISubMethodHelper {
|
private interface CallISubMethodHelper {
|
||||||
int callMethod(ISub iSub) throws RemoteException;
|
int callMethod(ISub iSub) throws RemoteException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,15 @@ interface ISub {
|
|||||||
*/
|
*/
|
||||||
String setSubscriptionGroup(in int[] subIdList, String callingPackage);
|
String setSubscriptionGroup(in int[] subIdList, String callingPackage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether a subscription is metered
|
||||||
|
*
|
||||||
|
* @param isMetered whether it’s a metered subscription.
|
||||||
|
* @param subId the unique SubscriptionInfo index in database
|
||||||
|
* @return the number of records updated
|
||||||
|
*/
|
||||||
|
int setMetered(boolean isMetered, int subId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set which subscription is preferred for cellular data. It's
|
* Set which subscription is preferred for cellular data. It's
|
||||||
* designed to overwrite default data subscription temporarily.
|
* designed to overwrite default data subscription temporarily.
|
||||||
|
|||||||
Reference in New Issue
Block a user