Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b827a37 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "add setMetered in SubscriptionManager"

parents ea6dcec9 19900848
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -149,6 +149,11 @@ public class SubscriptionInfo implements Parcelable {
    @Nullable
    private String mGroupUUID;

    /**
     *  A property in opportunistic subscription to indicate whether it is metered or not.
     */
    private boolean mIsMetered;

    /**
     * @hide
     */
@@ -158,7 +163,7 @@ public class SubscriptionInfo implements Parcelable {
            @Nullable UiccAccessRule[] accessRules, String cardId) {
        this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
                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,
            Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
            @Nullable UiccAccessRule[] accessRules, String cardId, boolean isOpportunistic,
            @Nullable String groupUUID) {
            @Nullable String groupUUID, boolean isMetered) {
        this.mId = id;
        this.mIccId = iccId;
        this.mSimSlotIndex = simSlotIndex;
@@ -187,8 +192,10 @@ public class SubscriptionInfo implements Parcelable {
        this.mCardId = cardId;
        this.mIsOpportunistic = isOpportunistic;
        this.mGroupUUID = groupUUID;
        this.mIsMetered = isMetered;
    }


    /**
     * @return the subscription ID.
     */
@@ -402,6 +409,18 @@ public class SubscriptionInfo implements Parcelable {
        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
     * 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();
            boolean isOpportunistic = source.readBoolean();
            String groupUUID = source.readString();
            boolean isMetered = source.readBoolean();

            return new SubscriptionInfo(id, iccId, simSlotIndex, displayName, carrierName,
                    nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc, countryIso,
                    isEmbedded, accessRules, cardId, isOpportunistic, groupUUID);
                    isEmbedded, accessRules, cardId, isOpportunistic, groupUUID, isMetered);
        }

        @Override
@@ -528,6 +548,7 @@ public class SubscriptionInfo implements Parcelable {
        dest.writeString(mCardId);
        dest.writeBoolean(mIsOpportunistic);
        dest.writeString(mGroupUUID);
        dest.writeBoolean(mIsMetered);
    }

    @Override
@@ -561,14 +582,14 @@ public class SubscriptionInfo implements Parcelable {
                + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
                + " accessRules " + Arrays.toString(mAccessRules)
                + " cardId=" + cardIdToPrint + " isOpportunistic " + mIsOpportunistic
                + " mGroupUUID=" + mGroupUUID + "}";
                + " mGroupUUID=" + mGroupUUID + " isMetered=" + mIsMetered + "}";
    }

    @Override
    public int hashCode() {
        return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
                mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc, mCountryIso,
                mCardId, mDisplayName, mCarrierName, mAccessRules);
                mIsOpportunistic, mGroupUUID, mIsMetered, mIccId, mNumber, mMcc, mMnc,
                mCountryIso, mCardId, mDisplayName, mCarrierName, mAccessRules);
    }

    @Override
@@ -591,6 +612,7 @@ public class SubscriptionInfo implements Parcelable {
                && mIsEmbedded == toCompare.mIsEmbedded
                && mIsOpportunistic == toCompare.mIsOpportunistic
                && Objects.equals(mGroupUUID, toCompare.mGroupUUID)
                && mIsMetered == toCompare.mIsMetered
                && Objects.equals(mIccId, toCompare.mIccId)
                && Objects.equals(mNumber, toCompare.mNumber)
                && Objects.equals(mMcc, toCompare.mMcc)
+21 −1
Original line number Diff line number Diff line
@@ -576,7 +576,12 @@ public class SubscriptionManager {
     * @hide
     */
    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
     * data, phone calls, or sms</p>
@@ -2403,6 +2408,21 @@ public class SubscriptionManager {
        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 {
        int callMethod(ISub iSub) throws RemoteException;
    }
+9 −0
Original line number Diff line number Diff line
@@ -183,6 +183,15 @@ interface ISub {
     */
    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
     * designed to overwrite default data subscription temporarily.