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

Commit d3ccf2b1 authored by Rambo Wang's avatar Rambo Wang Committed by Android (Google) Code Review
Browse files

Merge "Support getBarringInfo in telephony framework"

parents 7e18a9fa 508fed91
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2496,4 +2496,12 @@ public interface CommandsInterface {
     */
    default void unregisterForBarringInfoChanged(Handler h) {};

    /**
     * Get all the barring info for the current camped cell applicable to the current user.
     *
     * AsyncResult.result is the object of {@link android.telephony.BarringInfo}.
     *
     * @param result Message will be sent back to handler and result.obj will be the AsycResult.
     */
    default void getBarringInfo(Message result) {};
}
+42 −0
Original line number Diff line number Diff line
@@ -5135,6 +5135,46 @@ public class RIL extends BaseCommands implements CommandsInterface {
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void getBarringInfo(Message result) {
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy == null) {
            Rlog.e(RIL.RILJ_LOG_TAG, "Radio Proxy object is null!");
            if (result != null) {
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(RADIO_NOT_AVAILABLE));
                result.sendToTarget();
            }
        }

        if (mRadioVersion.less(RADIO_HAL_VERSION_1_5)) {
            if (result != null) {
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
            return;
        }

        android.hardware.radio.V1_5.IRadio radioProxy15 =
                (android.hardware.radio.V1_5.IRadio) radioProxy;
        if (radioProxy15 != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_GET_BARRING_INFO, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

            try {
                radioProxy15.getBarringInfo(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getBarringInfo", e);
            }
        }
    }

    //***** Private Methods

    /**
@@ -6018,6 +6058,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
                return "RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS";
            case RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE:
                return "RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE";
            case RIL_REQUEST_GET_BARRING_INFO:
                return "RIL_REQUEST_GET_BARRING_INFO";
            default: return "<unknown request>";
        }
    }
+23 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.AsyncResult;
import android.os.Message;
import android.os.SystemClock;
import android.service.carrier.CarrierIdentifier;
import android.telephony.BarringInfo;
import android.telephony.CarrierRestrictionRules;
import android.telephony.CellInfo;
import android.telephony.ModemActivityInfo;
@@ -2399,4 +2400,26 @@ public class RadioResponse extends IRadioResponse.Stub {
    public void setSystemSelectionChannelsResponse_1_5(RadioResponseInfo info) {
        responseVoid(info);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error.
     * @param cellIdentity CellIdentity for the barringInfos.
     * @param barringInfos List of BarringInfo for all the barring service types.
     */
    public void getBarringInfoResponse(RadioResponseInfo responseInfo,
            android.hardware.radio.V1_5.CellIdentity cellIdentity,
            ArrayList<android.hardware.radio.V1_5.BarringInfo> barringInfos) {
        RILRequest rr = mRil.processResponse(responseInfo);

        if (rr != null) {
            BarringInfo bi = BarringInfo.create(cellIdentity, barringInfos);
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, bi);
                // notify all registrants for the possible barring info change
                mRil.mBarringInfoChangedRegistrants.notifyRegistrants(
                        new AsyncResult(null, bi, null));
            }
            mRil.processResponseDone(rr, responseInfo, bi);
        }
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ENTER_SIM_PUK2;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_ACTIVITY_INFO;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_BARRING_INFO;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_CELL_INFO_LIST;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_CURRENT_CALLS;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_HARDWARE_CONFIG;
@@ -1078,6 +1079,23 @@ public class RILTest extends TelephonyTest {
        assertFalse(mRILInstance.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
    }

    @Test
    public void testGetBarringInfo() throws Exception {
        // Not supported on Radio 1.0.
        mRILUnderTest.getBarringInfo(obtainMessage());
        verify(mRadioProxy, never()).getBarringInfo(anyInt());

        // Make radio version 1.5 to support the operation.
        try {
            replaceInstance(RIL.class, "mRadioVersion", mRILUnderTest, mRadioVersionV15);
        } catch (Exception e) {
        }
        mRILUnderTest.getBarringInfo(obtainMessage());
        verify(mRadioProxy).getBarringInfo(mSerialNumberCaptor.capture());
        verifyRILResponse(
                mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_GET_BARRING_INFO);
    }

    @Test
    public void testInvokeOemRilRequestStrings() throws Exception {
        String[] strings = new String[]{"a", "b", "c"};