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 
17 package com.android.internal.telephony;
18 
19 import android.hardware.radio.deprecated.V1_0.IOemHookResponse;
20 import android.hardware.radio.V1_0.RadioError;
21 import android.hardware.radio.V1_0.RadioResponseInfo;
22 
23 import java.util.ArrayList;
24 
25 /**
26  * Class containing oem hook response callbacks
27  */
28 public class OemHookResponse extends IOemHookResponse.Stub {
29     RIL mRil;
30 
OemHookResponse(RIL ril)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      */
sendRequestRawResponse(RadioResponseInfo responseInfo, ArrayList<Byte> data)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      */
sendRequestStringsResponse(RadioResponseInfo responseInfo, ArrayList<String> data)56     public void sendRequestStringsResponse(RadioResponseInfo responseInfo, ArrayList<String> data) {
57         RadioResponse.responseStringArrayList(mRil, responseInfo, data);
58     }
59 }
60