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 #include <android-base/logging.h> 18 19 #include <android/hardware/radio/1.0/types.h> 20 #include <android/log.h> 21 #include <gtest/gtest.h> 22 23 using ::android::hardware::radio::V1_0::RadioError; 24 using ::android::hardware::radio::V1_0::RegState; 25 using ::android::hardware::radio::V1_0::SapResultCode; 26 using namespace std; 27 28 enum CheckFlag { 29 CHECK_DEFAULT = 0, 30 CHECK_GENERAL_ERROR = 1, 31 CHECK_OEM_ERROR = 2, 32 CHECK_OEM_AND_GENERAL_ERROR = 3, 33 CHECK_SAP_ERROR = 4, 34 }; 35 36 static constexpr const char* FEATURE_VOICE_CALL = "android.software.connectionservice"; 37 38 /* 39 * Generate random serial number for radio test 40 */ 41 int GetRandomSerialNumber(); 42 43 /* 44 * Check multiple radio error codes which are possibly returned because of the different 45 * vendor/devices implementations. It allows optional checks for general errors or/and oem errors. 46 */ 47 ::testing::AssertionResult CheckAnyOfErrors(RadioError err, std::vector<RadioError> generalError, 48 CheckFlag flag = CHECK_DEFAULT); 49 /* 50 * Check multiple sap error codes which are possibly returned because of the different 51 * vendor/devices implementations. 52 */ 53 ::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors); 54 55 /* 56 * Check if device supports feature. 57 */ 58 bool deviceSupportsFeature(const char* feature); 59 60 /* 61 * Check if device is in DSDS. 62 */ 63 bool isDsDsEnabled(); 64 65 /* 66 * Check if device is in TSTS. 67 */ 68 bool isTsTsEnabled(); 69 70 /* 71 * Check if voice status is in emergency only. 72 */ 73 bool isVoiceEmergencyOnly(RegState state); 74 75 /* 76 * Check if voice status is in service. 77 */ 78 bool isVoiceInService(RegState state);