• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #pragma once
18 
19 #include <aidl/android/hardware/radio/RadioResponseInfo.h>
20 
21 namespace android::hardware::radio::minimal {
22 
23 aidl::android::hardware::radio::RadioResponseInfo noError(int32_t serial);
24 aidl::android::hardware::radio::RadioResponseInfo notSupported(int32_t serial);
25 aidl::android::hardware::radio::RadioResponseInfo errorResponse(
26         int32_t serial, aidl::android::hardware::radio::RadioError error);
27 
28 #define RESPOND_ERROR_IF_NOT_CONNECTED(responseMethod, ...) \
29     if (!mContext->isConnected()) RESPOND_NOT_CONNECTED(responseMethod, __VA_ARGS__);
30 
31 #define RESPOND_NOT_CONNECTED(responseMethod, ...)                                          \
32     {                                                                                       \
33         LOG(WARNING) << (RADIO_MODULE ".") << __func__ << " called before rilConnected";    \
34         const auto responseInfo = ::android::hardware::radio::minimal::errorResponse(       \
35                 serial, ::aidl::android::hardware::radio::RadioError::RADIO_NOT_AVAILABLE); \
36         respond()->responseMethod(responseInfo __VA_OPT__(, ) __VA_ARGS__);                 \
37         return ok();                                                                        \
38     }
39 
40 }  // namespace android::hardware::radio::minimal
41