Loading radio/1.0/vts/functional/vts_test_util.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "RadioTest" #include <vts_test_util.h> #include <iostream> Loading Loading @@ -54,3 +56,26 @@ int GetRandomSerialNumber() { } return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned"; } // Runs "pm list features" and attempts to find the specified feature in its output. bool deviceSupportsFeature(const char* feature) { bool hasFeature = false; FILE* p = popen("/system/bin/pm list features", "re"); if (p) { char* line = NULL; size_t len = 0; while (getline(&line, &len, p) > 0) { if (strstr(line, feature)) { hasFeature = true; break; } } pclose(p); } else { __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, "popen failed: %d", errno); _exit(EXIT_FAILURE); } __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Feature %s: %ssupported", feature, hasFeature ? "" : "not "); return hasFeature; } No newline at end of file radio/1.0/vts/functional/vts_test_util.h +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <VtsHalHidlTargetTestBase.h> #include <android/hardware/radio/1.0/types.h> #include <android/log.h> #include <gtest/gtest.h> using ::android::hardware::radio::V1_0::RadioError; using ::android::hardware::radio::V1_0::SapResultCode; Loading @@ -32,6 +34,8 @@ enum CheckFlag { CHECK_SAP_ERROR = 4, }; static constexpr const char* FEATURE_VOICE_CALL = "android.software.connectionservice"; /* * Generate random serial number for radio test */ Loading @@ -48,3 +52,8 @@ int GetRandomSerialNumber(); * vendor/devices implementations. */ ::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors); /* * Check if device supports feature. */ bool deviceSupportsFeature(const char* feature); radio/1.4/vts/functional/radio_hidl_hal_api.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,13 @@ * Test IRadio.emergencyDial() for the response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading Loading @@ -53,6 +60,13 @@ TEST_F(RadioHidlTest_v1_4, emergencyDial) { * Test IRadio.emergencyDial() with specified service and its response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial_withServices) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading Loading @@ -85,6 +99,13 @@ TEST_F(RadioHidlTest_v1_4, emergencyDial_withServices) { * Test IRadio.emergencyDial() with known emergency call routing and its response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial_withEmergencyRouting) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading Loading
radio/1.0/vts/functional/vts_test_util.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "RadioTest" #include <vts_test_util.h> #include <iostream> Loading Loading @@ -54,3 +56,26 @@ int GetRandomSerialNumber() { } return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned"; } // Runs "pm list features" and attempts to find the specified feature in its output. bool deviceSupportsFeature(const char* feature) { bool hasFeature = false; FILE* p = popen("/system/bin/pm list features", "re"); if (p) { char* line = NULL; size_t len = 0; while (getline(&line, &len, p) > 0) { if (strstr(line, feature)) { hasFeature = true; break; } } pclose(p); } else { __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, "popen failed: %d", errno); _exit(EXIT_FAILURE); } __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Feature %s: %ssupported", feature, hasFeature ? "" : "not "); return hasFeature; } No newline at end of file
radio/1.0/vts/functional/vts_test_util.h +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <VtsHalHidlTargetTestBase.h> #include <android/hardware/radio/1.0/types.h> #include <android/log.h> #include <gtest/gtest.h> using ::android::hardware::radio::V1_0::RadioError; using ::android::hardware::radio::V1_0::SapResultCode; Loading @@ -32,6 +34,8 @@ enum CheckFlag { CHECK_SAP_ERROR = 4, }; static constexpr const char* FEATURE_VOICE_CALL = "android.software.connectionservice"; /* * Generate random serial number for radio test */ Loading @@ -48,3 +52,8 @@ int GetRandomSerialNumber(); * vendor/devices implementations. */ ::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors); /* * Check if device supports feature. */ bool deviceSupportsFeature(const char* feature);
radio/1.4/vts/functional/radio_hidl_hal_api.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,13 @@ * Test IRadio.emergencyDial() for the response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading Loading @@ -53,6 +60,13 @@ TEST_F(RadioHidlTest_v1_4, emergencyDial) { * Test IRadio.emergencyDial() with specified service and its response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial_withServices) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading Loading @@ -85,6 +99,13 @@ TEST_F(RadioHidlTest_v1_4, emergencyDial_withServices) { * Test IRadio.emergencyDial() with known emergency call routing and its response returned. */ TEST_F(RadioHidlTest_v1_4, emergencyDial_withEmergencyRouting) { if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) { ALOGI("Skipping emergencyDial because voice call is not supported in device"); return; } else { ALOGI("Running emergencyDial because voice call is supported in device"); } serial = GetRandomSerialNumber(); ::android::hardware::radio::V1_0::Dial dialInfo; Loading