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

Commit 64997623 authored by Meng Wang's avatar Meng Wang
Browse files

Add API setAllowedCarriers, getAllowedCarriers to TelephonyManager

Also:
   Add RIL constants RIL_REQUEST_SET_ALLOWED_CARRIERS, RIL_REQUEST_GET_ALLOWED_CARRIERS

Bug: 28564314
Change-Id: Iaf6c40de633e767309c4088249a5c13cb0988c5c
parent 5a2b96a8
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -126,4 +126,13 @@ public class CarrierIdentifier implements Parcelable {
        mGid1 = in.readString();
        mGid1 = in.readString();
        mGid2 = in.readString();
        mGid2 = in.readString();
    }
    }

    /** @hide */
    public interface MatchType {
        int ALL = 0;
        int SPN = 1;
        int IMSI_PREFIX = 2;
        int GID1 = 3;
        int GID2 = 4;
    }
}
}
+42 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyHistogram;
import android.telephony.TelephonyHistogram;
@@ -51,6 +52,7 @@ import com.android.internal.telephony.TelephonyProperties;


import java.io.FileInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.List;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Matcher;
@@ -5458,4 +5460,44 @@ public class TelephonyManager {
        }
        }
        return null;
        return null;
    }
    }

    /**
     * Set the allowed carrier list for slotId
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return The number of carriers set successfully. Should be length of
     * carrierList on success; -1 on error.
     * @hide
     */
    public int setAllowedCarriers(int slotId, List<CarrierIdentifier> carriers) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.setAllowedCarriers(slotId, carriers);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#setAllowedCarriers", e);
        }
        return -1;
    }

    /**
     * Get the allowed carrier list for slotId.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return List of {@link android.telephony.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     * @hide
     */
    public List<CarrierIdentifier> getAllowedCarriers(int slotId) {
        try {
            ITelephony service = getITelephony();
            if (service != null) {
                return service.getAllowedCarriers(slotId);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#getAllowedCarriers", e);
        }
        return new ArrayList<CarrierIdentifier>(0);
    }
}
}
+19 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.os.ResultReceiver;
import android.net.Uri;
import android.net.Uri;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telephony.CellInfo;
import android.telephony.CellInfo;
@@ -1118,4 +1119,22 @@ interface ITelephony {
     * Or the calling app has carrier privileges.
     * Or the calling app has carrier privileges.
     */
     */
    List<TelephonyHistogram> getTelephonyHistograms();
    List<TelephonyHistogram> getTelephonyHistograms();

    /**
     * Set the allowed carrier list for slotId
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return The number of carriers set successfully. Should match length of
     * carriers on success.
     */
    int setAllowedCarriers(int slotId, in List<CarrierIdentifier> carriers);

    /**
     * Get the allowed carrier list for slotId.
     * Require system privileges. In the future we may add this to carrier APIs.
     *
     * @return List of {@link android.service.carrier.CarrierIdentifier}; empty list
     * means all carriers are allowed.
     */
    List<CarrierIdentifier> getAllowedCarriers(int slotId);
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -409,6 +409,8 @@ cat include/telephony/ril.h | \
    int RIL_REQUEST_STOP_LCE = 133;
    int RIL_REQUEST_STOP_LCE = 133;
    int RIL_REQUEST_PULL_LCEDATA = 134;
    int RIL_REQUEST_PULL_LCEDATA = 134;
    int RIL_REQUEST_GET_ACTIVITY_INFO = 135;
    int RIL_REQUEST_GET_ACTIVITY_INFO = 135;
    int RIL_REQUEST_SET_ALLOWED_CARRIERS = 136;
    int RIL_REQUEST_GET_ALLOWED_CARRIERS = 137;


    int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;
    int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;