Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97fc7b7d authored by Shuo Qian's avatar Shuo Qian Committed by Automerger Merge Worker
Browse files

Check emergency dialing result in DSDS or TSTS only if slot is in service or...

Check emergency dialing result in DSDS or TSTS only if slot is in service or emergency only. am: 721fecba am: 9ab2f003

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1412188

Change-Id: I852b71606b11aca58f6fff073c4dcc45761d84f7
parents 04d7e84c 9ab2f003
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include <vts_test_util.h>
#include <iostream>
#include "VtsCoreUtil.h"

int GetRandomSerialNumber() {
    return rand();
@@ -79,3 +80,23 @@ bool deviceSupportsFeature(const char* feature) {
                        hasFeature ? "" : "not ");
    return hasFeature;
}

bool isDsDsEnabled() {
    return testing::checkSubstringInCommandOutput("getprop persist.radio.multisim.config", "dsds");
}

bool isTsTsEnabled() {
    return testing::checkSubstringInCommandOutput("getprop persist.radio.multisim.config", "tsts");
}

bool isVoiceInService(RegState state) {
    return ::android::hardware::radio::V1_0::RegState::REG_HOME == state ||
           ::android::hardware::radio::V1_0::RegState::REG_ROAMING == state;
}

bool isVoiceEmergencyOnly(RegState state) {
    return ::android::hardware::radio::V1_0::RegState::NOT_REG_MT_NOT_SEARCHING_OP_EM == state ||
           ::android::hardware::radio::V1_0::RegState::NOT_REG_MT_SEARCHING_OP_EM == state ||
           ::android::hardware::radio::V1_0::RegState::REG_DENIED_EM == state ||
           ::android::hardware::radio::V1_0::RegState::UNKNOWN_EM == state;
}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <gtest/gtest.h>

using ::android::hardware::radio::V1_0::RadioError;
using ::android::hardware::radio::V1_0::RegState;
using ::android::hardware::radio::V1_0::SapResultCode;
using namespace std;

@@ -55,3 +56,23 @@ int GetRandomSerialNumber();
 * Check if device supports feature.
 */
bool deviceSupportsFeature(const char* feature);

/*
 * Check if device is in DSDS.
 */
bool isDsDsEnabled();

/*
 * Check if device is in TSTS.
 */
bool isTsTsEnabled();

/*
 * Check if voice status is in emergency only.
 */
bool isVoiceEmergencyOnly(RegState state);

/*
 * Check if voice status is in service.
 */
bool isVoiceInService(RegState state);
 No newline at end of file
+44 −3
Original line number Diff line number Diff line
@@ -56,7 +56,21 @@ TEST_P(RadioHidlTest_v1_4, emergencyDial) {
    EXPECT_EQ(serial, radioRsp_v1_4->rspInfo.serial);

    ALOGI("emergencyDial, rspInfo.error = %s\n", toString(radioRsp_v1_4->rspInfo.error).c_str());
    EXPECT_EQ(RadioError::NONE, radioRsp_v1_4->rspInfo.error);

    ::android::hardware::radio::V1_0::RadioError rspEmergencyDial = radioRsp_v1_4->rspInfo.error;
    // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
    // or Emergency_Only.
    if (isDsDsEnabled() || isTsTsEnabled()) {
        serial = GetRandomSerialNumber();
        radio_v1_4->getVoiceRegistrationState(serial);
        EXPECT_EQ(std::cv_status::no_timeout, wait());
        if (isVoiceEmergencyOnly(radioRsp_v1_4->voiceRegResp.regState) ||
            isVoiceInService(radioRsp_v1_4->voiceRegResp.regState)) {
            EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
        }
    } else {
        EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
    }

    // Give some time for modem to establish the emergency call channel.
    sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
@@ -95,8 +109,21 @@ TEST_P(RadioHidlTest_v1_4, emergencyDial_withServices) {

    ALOGI("emergencyDial_withServices, rspInfo.error = %s\n",
          toString(radioRsp_v1_4->rspInfo.error).c_str());
    EXPECT_EQ(RadioError::NONE, radioRsp_v1_4->rspInfo.error);
    ::android::hardware::radio::V1_0::RadioError rspEmergencyDial = radioRsp_v1_4->rspInfo.error;

    // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
    // or Emergency_Only.
    if (isDsDsEnabled() || isTsTsEnabled()) {
        serial = GetRandomSerialNumber();
        radio_v1_4->getVoiceRegistrationState(serial);
        EXPECT_EQ(std::cv_status::no_timeout, wait());
        if (isVoiceEmergencyOnly(radioRsp_v1_4->voiceRegResp.regState) ||
            isVoiceInService(radioRsp_v1_4->voiceRegResp.regState)) {
            EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
        }
    } else {
        EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
    }
    // Give some time for modem to establish the emergency call channel.
    sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);

@@ -134,7 +161,21 @@ TEST_P(RadioHidlTest_v1_4, emergencyDial_withEmergencyRouting) {

    ALOGI("emergencyDial_withEmergencyRouting, rspInfo.error = %s\n",
          toString(radioRsp_v1_4->rspInfo.error).c_str());
    EXPECT_EQ(RadioError::NONE, radioRsp_v1_4->rspInfo.error);
    ::android::hardware::radio::V1_0::RadioError rspEmergencyDial = radioRsp_v1_4->rspInfo.error;

    // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
    // or Emergency_Only.
    if (isDsDsEnabled() || isTsTsEnabled()) {
        serial = GetRandomSerialNumber();
        radio_v1_4->getVoiceRegistrationState(serial);
        EXPECT_EQ(std::cv_status::no_timeout, wait());
        if (isVoiceEmergencyOnly(radioRsp_v1_4->voiceRegResp.regState) ||
            isVoiceInService(radioRsp_v1_4->voiceRegResp.regState)) {
            EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
        }
    } else {
        EXPECT_EQ(RadioError::NONE, rspEmergencyDial);
    }

    // Give some time for modem to establish the emergency call channel.
    sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ class RadioResponse_v1_4 : public ::android::hardware::radio::V1_4::IRadioRespon

    // Call
    hidl_vec<::android::hardware::radio::V1_2::Call> currentCalls;
    ::android::hardware::radio::V1_2::VoiceRegStateResult voiceRegResp;

    // Modem
    bool isModemEnabled;
+2 −1
Original line number Diff line number Diff line
@@ -762,8 +762,9 @@ Return<void> RadioResponse_v1_4::getCellInfoListResponse_1_2(

Return<void> RadioResponse_v1_4::getVoiceRegistrationStateResponse_1_2(
        const RadioResponseInfo& info,
        const ::android::hardware::radio::V1_2::VoiceRegStateResult& /*voiceRegResponse*/) {
        const ::android::hardware::radio::V1_2::VoiceRegStateResult& voiceRegResponse) {
    rspInfo = info;
    voiceRegResp = voiceRegResponse;
    parent_v1_4.notify(info.serial);
    return Void();
}