Loading src/java/com/android/internal/telephony/CommandsInterface.java +4 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.net.LinkProperties; import android.os.Handler; import android.os.Message; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; import android.telephony.NetworkScanRequest; Loading Loading @@ -2067,11 +2067,11 @@ public interface CommandsInterface { * Set allowed carriers * * @param carriers Allowed carriers * @param result Callback message contains the number of carriers set successfully * @param result Callback message contains the result of the operation * @param workSource calling WorkSource */ default void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) {} default void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) {} /** * Get allowed carriers Loading src/java/com/android/internal/telephony/Phone.java +4 −4 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ import android.os.SystemProperties; import android.os.WorkSource; import android.preference.PreferenceManager; import android.provider.Settings; import android.service.carrier.CarrierIdentifier; import android.telecom.VideoProfile; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.ClientRequestStats; Loading Loading @@ -3665,9 +3665,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { /** * Set allowed carriers */ public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message response, WorkSource workSource) { mCi.setAllowedCarriers(carriers, response, workSource); public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message response, WorkSource workSource) { mCi.setAllowedCarriers(carrierRestrictionRules, response, workSource); } /** Sets the SignalStrength reporting criteria. */ Loading src/java/com/android/internal/telephony/RIL.java +131 −52 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ import android.hardware.radio.V1_0.SimApdu; import android.hardware.radio.V1_0.SmsWriteArgs; import android.hardware.radio.V1_0.UusInfo; import android.hardware.radio.V1_2.AccessNetwork; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.hardware.radio.deprecated.V1_0.IOemHook; import android.net.ConnectivityManager; import android.net.KeepalivePacketData; Loading @@ -65,6 +67,7 @@ import android.os.SystemProperties; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; Loading Loading @@ -612,7 +615,7 @@ public class RIL extends BaseCommands implements CommandsInterface { resetProxyAndRequestList(); } private String convertNullToEmptyString(String string) { private static String convertNullToEmptyString(String string) { return string != null ? string : ""; } Loading Loading @@ -3843,35 +3846,16 @@ public class RIL extends BaseCommands implements CommandsInterface { } @Override public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) { checkNotNull(carriers, "Allowed carriers list cannot be null."); workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource); if (RILJ_LOGD) { String logStr = ""; for (int i = 0; i < carriers.size(); i++) { logStr = logStr + carriers.get(i) + " "; } riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " carriers = " + logStr); } boolean allAllowed; if (carriers.size() == 0) { allAllowed = true; } else { allAllowed = false; } CarrierRestrictions carrierList = new CarrierRestrictions(); for (CarrierIdentifier ci : carriers) { /* allowed carriers */ /** * Convert a list of CarrierIdentifier into a list of Carrier defined in 1.0/types.hal. * @param carriers List of CarrierIdentifier * @return List of converted objects */ @VisibleForTesting public static ArrayList<Carrier> createCarrierRestrictionList( List<CarrierIdentifier> carriers) { ArrayList<Carrier> result = new ArrayList<>(); for (CarrierIdentifier ci : carriers) { Carrier c = new Carrier(); c.mcc = convertNullToEmptyString(ci.getMcc()); c.mnc = convertNullToEmptyString(ci.getMnc()); Loading @@ -3892,13 +3876,91 @@ public class RIL extends BaseCommands implements CommandsInterface { } c.matchType = matchType; c.matchData = convertNullToEmptyString(matchData); carrierList.allowedCarriers.add(c); result.add(c); } return result; } /* TODO: add excluded carriers */ @Override public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) { riljLog("RIL.java - setAllowedCarriers"); checkNotNull(carrierRestrictionRules, "Carrier restriction cannot be null."); workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy == null) { return; } RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " params: " + carrierRestrictionRules); } // Extract multisim policy int policy = SimLockMultiSimPolicy.NO_MULTISIM_POLICY; switch (carrierRestrictionRules.getMultiSimPolicy()) { case CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT: policy = SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT; break; } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { riljLog("RIL.java - Using IRadio 1.4 or greater"); android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy; // Prepare structure with allowed list, excluded list and priority CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority(); carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); carrierRestrictions.excludedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getExcludedCarriers()); carrierRestrictions.allowedCarriersPrioritized = (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED); try { radioProxy14.setAllowedCarriers_1_4(rr.mSerial, carrierRestrictions, policy); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setAllowedCarriers_1_4", e); } } else { boolean isAllCarriersAllowed = carrierRestrictionRules.isAllCarriersAllowed(); boolean supported = (isAllCarriersAllowed || (carrierRestrictionRules.getExcludedCarriers().isEmpty() && (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED))); supported = supported && (policy == SimLockMultiSimPolicy.NO_MULTISIM_POLICY); if (!supported) { // Feature is not supported by IRadio interface riljLoge("setAllowedCarriers does not support excluded list on IRadio version" + " less than 1.4"); if (result != null) { AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); result.sendToTarget(); } return; } riljLog("RIL.java - Using IRadio 1.3 or lower"); // Prepare structure with allowed list CarrierRestrictions carrierRestrictions = new CarrierRestrictions(); carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); try { radioProxy.setAllowedCarriers(rr.mSerial, allAllowed, carrierList); radioProxy.setAllowedCarriers(rr.mSerial, isAllCarriersAllowed, carrierRestrictions); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setAllowedCarriers", e); } Loading @@ -3910,7 +3972,10 @@ public class RIL extends BaseCommands implements CommandsInterface { workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { if (radioProxy == null) { return; } RILRequest rr = obtainRequest(RIL_REQUEST_GET_ALLOWED_CARRIERS, result, workSource); Loading @@ -3918,6 +3983,20 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { riljLog("RIL.java - Using IRadio 1.4 or greater"); android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy; try { radioProxy14.getAllowedCarriers_1_4(rr.mSerial); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "getAllowedCarriers_1_4", e); } } else { riljLog("RIL.java - Using IRadio 1.3 or lower"); try { radioProxy.getAllowedCarriers(rr.mSerial); } catch (RemoteException | RuntimeException e) { Loading src/java/com/android/internal/telephony/RadioResponse.java +115 −27 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.radio.V1_0.ActivityStatsInfo; import android.hardware.radio.V1_0.AppStatus; import android.hardware.radio.V1_0.CardStatus; import android.hardware.radio.V1_0.Carrier; import android.hardware.radio.V1_0.CarrierRestrictions; import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo; import android.hardware.radio.V1_0.DataRegStateResult; Loading @@ -34,10 +35,13 @@ import android.hardware.radio.V1_0.SendSmsResult; import android.hardware.radio.V1_0.SetupDataCallResult; import android.hardware.radio.V1_0.VoiceRegStateResult; import android.hardware.radio.V1_2.IRadioResponse; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.os.AsyncResult; import android.os.Message; import android.os.SystemClock; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.ModemActivityInfo; import android.telephony.NeighboringCellInfo; Loading Loading @@ -1299,11 +1303,47 @@ public class RadioResponse extends IRadioResponse.Stub { * if Length of allowed carriers list is 0, numAllowed = 0. */ public void setAllowedCarriersResponse(RadioResponseInfo responseInfo, int numAllowed) { responseInts(responseInfo, numAllowed); // The number of allowed carriers set correctly is not really useful. Even if one is // missing, the operation has failed, as the list should be treated as a single // configuration item. So, ignoring the value of numAllowed and considering only the // value of the responseInfo.error. int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR; RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { mRil.riljLog("setAllowedCarriersResponse - error = " + responseInfo.error); if (responseInfo.error == RadioError.NONE) { ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS; sendMessageResponse(rr.mResult, ret); } else if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED) { // Handle the case REQUEST_NOT_SUPPORTED as a valid response responseInfo.error = RadioError.NONE; ret = TelephonyManager.SET_CARRIER_RESTRICTION_NOT_SUPPORTED; sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } /** * * @param responseInfo Response info struct containing response type, serial no. and error */ public void setAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo) { int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR; RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { mRil.riljLog("setAllowedCarriersResponse_1_4 - error = " + responseInfo.error); if (responseInfo.error == RadioError.NONE) { ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS; sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param allAllowed true only when all carriers are allowed. Ignore "carriers" struct. * If false, consider "carriers" struct Loading @@ -1311,7 +1351,26 @@ public class RadioResponse extends IRadioResponse.Stub { */ public void getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) { responseCarrierIdentifiers(responseInfo, allAllowed, carriers); CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority(); carrierRestrictions.allowedCarriers = carriers.allowedCarriers; carrierRestrictions.excludedCarriers = carriers.excludedCarriers; carrierRestrictions.allowedCarriersPrioritized = true; responseCarrierRestrictions(responseInfo, allAllowed, carrierRestrictions, SimLockMultiSimPolicy.NO_MULTISIM_POLICY); } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param carrierRestrictions Carrier restriction information. * @param multiSimPolicy Policy for multi-sim devices. */ public void getAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo, CarrierRestrictionsWithPriority carrierRestrictions, int multiSimPolicy) { // The API in IRadio 1.4 does not support the flag allAllowed, so setting it to false, so // that values in carrierRestrictions are used. responseCarrierRestrictions(responseInfo, false, carrierRestrictions, multiSimPolicy); } /** Loading Loading @@ -2151,18 +2210,14 @@ public class RadioResponse extends IRadioResponse.Stub { } } private void responseCarrierIdentifiers(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) { RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { List<CarrierIdentifier> ret = new ArrayList<CarrierIdentifier>(); for (int i = 0; i < carriers.allowedCarriers.size(); i++) { String mcc = carriers.allowedCarriers.get(i).mcc; String mnc = carriers.allowedCarriers.get(i).mnc; private static List<CarrierIdentifier> convertCarrierList(List<Carrier> carrierList) { List<CarrierIdentifier> ret = new ArrayList<>(); for (int i = 0; i < carrierList.size(); i++) { String mcc = carrierList.get(i).mcc; String mnc = carrierList.get(i).mnc; String spn = null, imsi = null, gid1 = null, gid2 = null; int matchType = carriers.allowedCarriers.get(i).matchType; String matchData = carriers.allowedCarriers.get(i).matchData; int matchType = carrierList.get(i).matchType; String matchData = carrierList.get(i).matchData; if (matchType == CarrierIdentifier.MatchType.SPN) { spn = matchData; } else if (matchType == CarrierIdentifier.MatchType.IMSI_PREFIX) { Loading @@ -2174,11 +2229,44 @@ public class RadioResponse extends IRadioResponse.Stub { } ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2)); } return ret; } private void responseCarrierRestrictions(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictionsWithPriority carriers, int multiSimPolicy) { RILRequest rr = mRil.processResponse(responseInfo); if (rr == null) { return; } CarrierRestrictionRules ret; if (allAllowed) { ret = CarrierRestrictionRules.newBuilder().setAllCarriersAllowed().build(); } else { int policy = CarrierRestrictionRules.MULTISIM_POLICY_NONE; if (multiSimPolicy == SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT) { policy = CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT; } int carrierRestrictionDefault = CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED; if (!carriers.allowedCarriersPrioritized) { carrierRestrictionDefault = CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED; } ret = CarrierRestrictionRules.newBuilder() .setAllowedCarriers(convertCarrierList(carriers.allowedCarriers)) .setExcludedCarriers(convertCarrierList(carriers.excludedCarriers)) .setDefaultCarrierRestriction(carrierRestrictionDefault) .setMultiSimPolicy(policy) .build(); } if (responseInfo.error == RadioError.NONE) { /* TODO: Handle excluded carriers */ sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } } src/java/com/android/internal/telephony/test/SimulatedCommands.java +3 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import android.os.Message; import android.os.Parcel; import android.os.SystemClock; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; import android.telephony.CellSignalStrengthCdma; Loading Loading @@ -2063,8 +2063,8 @@ public class SimulatedCommands extends BaseCommands } @Override public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) { public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) { unimplemented(result); } Loading Loading
src/java/com/android/internal/telephony/CommandsInterface.java +4 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import android.net.LinkProperties; import android.os.Handler; import android.os.Message; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; import android.telephony.NetworkScanRequest; Loading Loading @@ -2067,11 +2067,11 @@ public interface CommandsInterface { * Set allowed carriers * * @param carriers Allowed carriers * @param result Callback message contains the number of carriers set successfully * @param result Callback message contains the result of the operation * @param workSource calling WorkSource */ default void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) {} default void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) {} /** * Get allowed carriers Loading
src/java/com/android/internal/telephony/Phone.java +4 −4 Original line number Diff line number Diff line Loading @@ -39,10 +39,10 @@ import android.os.SystemProperties; import android.os.WorkSource; import android.preference.PreferenceManager; import android.provider.Settings; import android.service.carrier.CarrierIdentifier; import android.telecom.VideoProfile; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.CarrierConfigManager; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.ClientRequestStats; Loading Loading @@ -3665,9 +3665,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { /** * Set allowed carriers */ public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message response, WorkSource workSource) { mCi.setAllowedCarriers(carriers, response, workSource); public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message response, WorkSource workSource) { mCi.setAllowedCarriers(carrierRestrictionRules, response, workSource); } /** Sets the SignalStrength reporting criteria. */ Loading
src/java/com/android/internal/telephony/RIL.java +131 −52 Original line number Diff line number Diff line Loading @@ -48,6 +48,8 @@ import android.hardware.radio.V1_0.SimApdu; import android.hardware.radio.V1_0.SmsWriteArgs; import android.hardware.radio.V1_0.UusInfo; import android.hardware.radio.V1_2.AccessNetwork; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.hardware.radio.deprecated.V1_0.IOemHook; import android.net.ConnectivityManager; import android.net.KeepalivePacketData; Loading @@ -65,6 +67,7 @@ import android.os.SystemProperties; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.ClientRequestStats; import android.telephony.ImsiEncryptionInfo; Loading Loading @@ -612,7 +615,7 @@ public class RIL extends BaseCommands implements CommandsInterface { resetProxyAndRequestList(); } private String convertNullToEmptyString(String string) { private static String convertNullToEmptyString(String string) { return string != null ? string : ""; } Loading Loading @@ -3843,35 +3846,16 @@ public class RIL extends BaseCommands implements CommandsInterface { } @Override public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) { checkNotNull(carriers, "Allowed carriers list cannot be null."); workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource); if (RILJ_LOGD) { String logStr = ""; for (int i = 0; i < carriers.size(); i++) { logStr = logStr + carriers.get(i) + " "; } riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " carriers = " + logStr); } boolean allAllowed; if (carriers.size() == 0) { allAllowed = true; } else { allAllowed = false; } CarrierRestrictions carrierList = new CarrierRestrictions(); for (CarrierIdentifier ci : carriers) { /* allowed carriers */ /** * Convert a list of CarrierIdentifier into a list of Carrier defined in 1.0/types.hal. * @param carriers List of CarrierIdentifier * @return List of converted objects */ @VisibleForTesting public static ArrayList<Carrier> createCarrierRestrictionList( List<CarrierIdentifier> carriers) { ArrayList<Carrier> result = new ArrayList<>(); for (CarrierIdentifier ci : carriers) { Carrier c = new Carrier(); c.mcc = convertNullToEmptyString(ci.getMcc()); c.mnc = convertNullToEmptyString(ci.getMnc()); Loading @@ -3892,13 +3876,91 @@ public class RIL extends BaseCommands implements CommandsInterface { } c.matchType = matchType; c.matchData = convertNullToEmptyString(matchData); carrierList.allowedCarriers.add(c); result.add(c); } return result; } /* TODO: add excluded carriers */ @Override public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) { riljLog("RIL.java - setAllowedCarriers"); checkNotNull(carrierRestrictionRules, "Carrier restriction cannot be null."); workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy == null) { return; } RILRequest rr = obtainRequest(RIL_REQUEST_SET_ALLOWED_CARRIERS, result, workSource); if (RILJ_LOGD) { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " params: " + carrierRestrictionRules); } // Extract multisim policy int policy = SimLockMultiSimPolicy.NO_MULTISIM_POLICY; switch (carrierRestrictionRules.getMultiSimPolicy()) { case CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT: policy = SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT; break; } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { riljLog("RIL.java - Using IRadio 1.4 or greater"); android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy; // Prepare structure with allowed list, excluded list and priority CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority(); carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); carrierRestrictions.excludedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getExcludedCarriers()); carrierRestrictions.allowedCarriersPrioritized = (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED); try { radioProxy14.setAllowedCarriers_1_4(rr.mSerial, carrierRestrictions, policy); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setAllowedCarriers_1_4", e); } } else { boolean isAllCarriersAllowed = carrierRestrictionRules.isAllCarriersAllowed(); boolean supported = (isAllCarriersAllowed || (carrierRestrictionRules.getExcludedCarriers().isEmpty() && (carrierRestrictionRules.getDefaultCarrierRestriction() == CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED))); supported = supported && (policy == SimLockMultiSimPolicy.NO_MULTISIM_POLICY); if (!supported) { // Feature is not supported by IRadio interface riljLoge("setAllowedCarriers does not support excluded list on IRadio version" + " less than 1.4"); if (result != null) { AsyncResult.forMessage(result, null, CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED)); result.sendToTarget(); } return; } riljLog("RIL.java - Using IRadio 1.3 or lower"); // Prepare structure with allowed list CarrierRestrictions carrierRestrictions = new CarrierRestrictions(); carrierRestrictions.allowedCarriers = createCarrierRestrictionList(carrierRestrictionRules.getAllowedCarriers()); try { radioProxy.setAllowedCarriers(rr.mSerial, allAllowed, carrierList); radioProxy.setAllowedCarriers(rr.mSerial, isAllCarriersAllowed, carrierRestrictions); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setAllowedCarriers", e); } Loading @@ -3910,7 +3972,10 @@ public class RIL extends BaseCommands implements CommandsInterface { workSource = getDeafultWorkSourceIfInvalid(workSource); IRadio radioProxy = getRadioProxy(result); if (radioProxy != null) { if (radioProxy == null) { return; } RILRequest rr = obtainRequest(RIL_REQUEST_GET_ALLOWED_CARRIERS, result, workSource); Loading @@ -3918,6 +3983,20 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_4)) { riljLog("RIL.java - Using IRadio 1.4 or greater"); android.hardware.radio.V1_4.IRadio radioProxy14 = (android.hardware.radio.V1_4.IRadio) radioProxy; try { radioProxy14.getAllowedCarriers_1_4(rr.mSerial); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "getAllowedCarriers_1_4", e); } } else { riljLog("RIL.java - Using IRadio 1.3 or lower"); try { radioProxy.getAllowedCarriers(rr.mSerial); } catch (RemoteException | RuntimeException e) { Loading
src/java/com/android/internal/telephony/RadioResponse.java +115 −27 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.radio.V1_0.ActivityStatsInfo; import android.hardware.radio.V1_0.AppStatus; import android.hardware.radio.V1_0.CardStatus; import android.hardware.radio.V1_0.Carrier; import android.hardware.radio.V1_0.CarrierRestrictions; import android.hardware.radio.V1_0.CdmaBroadcastSmsConfigInfo; import android.hardware.radio.V1_0.DataRegStateResult; Loading @@ -34,10 +35,13 @@ import android.hardware.radio.V1_0.SendSmsResult; import android.hardware.radio.V1_0.SetupDataCallResult; import android.hardware.radio.V1_0.VoiceRegStateResult; import android.hardware.radio.V1_2.IRadioResponse; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.os.AsyncResult; import android.os.Message; import android.os.SystemClock; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.ModemActivityInfo; import android.telephony.NeighboringCellInfo; Loading Loading @@ -1299,11 +1303,47 @@ public class RadioResponse extends IRadioResponse.Stub { * if Length of allowed carriers list is 0, numAllowed = 0. */ public void setAllowedCarriersResponse(RadioResponseInfo responseInfo, int numAllowed) { responseInts(responseInfo, numAllowed); // The number of allowed carriers set correctly is not really useful. Even if one is // missing, the operation has failed, as the list should be treated as a single // configuration item. So, ignoring the value of numAllowed and considering only the // value of the responseInfo.error. int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR; RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { mRil.riljLog("setAllowedCarriersResponse - error = " + responseInfo.error); if (responseInfo.error == RadioError.NONE) { ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS; sendMessageResponse(rr.mResult, ret); } else if (responseInfo.error == RadioError.REQUEST_NOT_SUPPORTED) { // Handle the case REQUEST_NOT_SUPPORTED as a valid response responseInfo.error = RadioError.NONE; ret = TelephonyManager.SET_CARRIER_RESTRICTION_NOT_SUPPORTED; sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } /** * * @param responseInfo Response info struct containing response type, serial no. and error */ public void setAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo) { int ret = TelephonyManager.SET_CARRIER_RESTRICTION_ERROR; RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { mRil.riljLog("setAllowedCarriersResponse_1_4 - error = " + responseInfo.error); if (responseInfo.error == RadioError.NONE) { ret = TelephonyManager.SET_CARRIER_RESTRICTION_SUCCESS; sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param allAllowed true only when all carriers are allowed. Ignore "carriers" struct. * If false, consider "carriers" struct Loading @@ -1311,7 +1351,26 @@ public class RadioResponse extends IRadioResponse.Stub { */ public void getAllowedCarriersResponse(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) { responseCarrierIdentifiers(responseInfo, allAllowed, carriers); CarrierRestrictionsWithPriority carrierRestrictions = new CarrierRestrictionsWithPriority(); carrierRestrictions.allowedCarriers = carriers.allowedCarriers; carrierRestrictions.excludedCarriers = carriers.excludedCarriers; carrierRestrictions.allowedCarriersPrioritized = true; responseCarrierRestrictions(responseInfo, allAllowed, carrierRestrictions, SimLockMultiSimPolicy.NO_MULTISIM_POLICY); } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param carrierRestrictions Carrier restriction information. * @param multiSimPolicy Policy for multi-sim devices. */ public void getAllowedCarriersResponse_1_4(RadioResponseInfo responseInfo, CarrierRestrictionsWithPriority carrierRestrictions, int multiSimPolicy) { // The API in IRadio 1.4 does not support the flag allAllowed, so setting it to false, so // that values in carrierRestrictions are used. responseCarrierRestrictions(responseInfo, false, carrierRestrictions, multiSimPolicy); } /** Loading Loading @@ -2151,18 +2210,14 @@ public class RadioResponse extends IRadioResponse.Stub { } } private void responseCarrierIdentifiers(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictions carriers) { RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { List<CarrierIdentifier> ret = new ArrayList<CarrierIdentifier>(); for (int i = 0; i < carriers.allowedCarriers.size(); i++) { String mcc = carriers.allowedCarriers.get(i).mcc; String mnc = carriers.allowedCarriers.get(i).mnc; private static List<CarrierIdentifier> convertCarrierList(List<Carrier> carrierList) { List<CarrierIdentifier> ret = new ArrayList<>(); for (int i = 0; i < carrierList.size(); i++) { String mcc = carrierList.get(i).mcc; String mnc = carrierList.get(i).mnc; String spn = null, imsi = null, gid1 = null, gid2 = null; int matchType = carriers.allowedCarriers.get(i).matchType; String matchData = carriers.allowedCarriers.get(i).matchData; int matchType = carrierList.get(i).matchType; String matchData = carrierList.get(i).matchData; if (matchType == CarrierIdentifier.MatchType.SPN) { spn = matchData; } else if (matchType == CarrierIdentifier.MatchType.IMSI_PREFIX) { Loading @@ -2174,11 +2229,44 @@ public class RadioResponse extends IRadioResponse.Stub { } ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2)); } return ret; } private void responseCarrierRestrictions(RadioResponseInfo responseInfo, boolean allAllowed, CarrierRestrictionsWithPriority carriers, int multiSimPolicy) { RILRequest rr = mRil.processResponse(responseInfo); if (rr == null) { return; } CarrierRestrictionRules ret; if (allAllowed) { ret = CarrierRestrictionRules.newBuilder().setAllCarriersAllowed().build(); } else { int policy = CarrierRestrictionRules.MULTISIM_POLICY_NONE; if (multiSimPolicy == SimLockMultiSimPolicy.ONE_VALID_SIM_MUST_BE_PRESENT) { policy = CarrierRestrictionRules.MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT; } int carrierRestrictionDefault = CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED; if (!carriers.allowedCarriersPrioritized) { carrierRestrictionDefault = CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED; } ret = CarrierRestrictionRules.newBuilder() .setAllowedCarriers(convertCarrierList(carriers.allowedCarriers)) .setExcludedCarriers(convertCarrierList(carriers.excludedCarriers)) .setDefaultCarrierRestriction(carrierRestrictionDefault) .setMultiSimPolicy(policy) .build(); } if (responseInfo.error == RadioError.NONE) { /* TODO: Handle excluded carriers */ sendMessageResponse(rr.mResult, ret); } mRil.processResponseDone(rr, responseInfo, ret); } } }
src/java/com/android/internal/telephony/test/SimulatedCommands.java +3 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import android.os.Message; import android.os.Parcel; import android.os.SystemClock; import android.os.WorkSource; import android.service.carrier.CarrierIdentifier; import android.telephony.CarrierRestrictionRules; import android.telephony.CellInfo; import android.telephony.CellInfoGsm; import android.telephony.CellSignalStrengthCdma; Loading Loading @@ -2063,8 +2063,8 @@ public class SimulatedCommands extends BaseCommands } @Override public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message result, WorkSource workSource) { public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message result, WorkSource workSource) { unimplemented(result); } Loading