1/**
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.telephony;
18
19import android.hardware.radio.deprecated.V1_0.IOemHookResponse;
20import android.hardware.radio.V1_0.RadioError;
21import android.hardware.radio.V1_0.RadioResponseInfo;
22
23import java.util.ArrayList;
24
25/**
26 * Class containing oem hook response callbacks
27 */
28public class OemHookResponse extends IOemHookResponse.Stub {
29    RIL mRil;
30
31    public OemHookResponse(RIL ril) {
32        mRil = ril;
33    }
34
35    /**
36     * @param responseInfo Response info struct containing response type, serial no. and error
37     * @param data Data returned by oem
38     */
39    public void sendRequestRawResponse(RadioResponseInfo responseInfo, ArrayList<Byte> data) {
40        RILRequest rr = mRil.processResponse(responseInfo);
41
42        if (rr != null) {
43            byte[] ret = null;
44            if (responseInfo.error == RadioError.NONE) {
45                ret = RIL.arrayListToPrimitiveArray(data);
46                RadioResponse.sendMessageResponse(rr.mResult, ret);
47            }
48            mRil.processResponseDone(rr, responseInfo, ret);
49        }
50    }
51
52    /**
53     * @param responseInfo Response info struct containing response type, serial no. and error
54     * @param data Data returned by oem
55     */
56    public void sendRequestStringsResponse(RadioResponseInfo responseInfo, ArrayList<String> data) {
57        RadioResponse.responseStringArrayList(mRil, responseInfo, data);
58    }
59}
60