# Request voice service state updates

This sample application demonstrates how to request voice service state corresponding to a SIM
in the device.

1. Implement ResponseCallback interface to receive subsystem initialization status

std::promise<telux::common::ServiceStatus> cbProm = std::promise<telux::common::ServiceStatus>();
    void initResponseCb(telux::common::ServiceStatus status) {
       if(subSystemsStatus == SERVICE_AVAILABLE) {
          std::cout << Phone Manager subsystem is ready << std::endl;
       } else if(subSystemsStatus == SERVICE_FAILED) {
          std::cout << Phone Manager subsystem initialization failed << std::endl;
       }
       cbProm.set_value(status);
    }
    Copy to clipboard

2. Get the PhoneFactory and PhoneManager instance

auto &phoneFactory = PhoneFactory::getInstance();
    auto phoneManager = phoneFactory.getPhoneManager(initResponseCb);
    if(phoneManager == NULL) {
       std::cout << " Failed to get Phone Manager instance" << std::endl;
       return -1;
    }
    Copy to clipboard

3. Wait for Phone Manager subsystem to be ready

telux::common::ServiceStatus status = cbProm.get_future().get();
    if(status != SERVICE_AVAILABLE) {
       std::cout << Unable to initialize Phone Manager subsystem << std::endl;
       return -1;
    }
    Copy to clipboard

4. Get the phone object corresponding to a phone ID

auto phone = phoneManager->getPhone(DEFAULT_PHONE_ID);
    Copy to clipboard

5. Implement IOperatingModeCallback interface and instantiate MyOperatingModeCallback

std::promise<bool> callbackPromise;
    telux::tel::OperatingMode operatingMode;
    class MyOperatingModeCallback : public telux::tel::IOperatingModeCallback {
    public:
       void operatingModeResponse(telux::tel::OperatingMode mode, telux::common::ErrorCode error) {
         if(error == telux::common::ErrorCode::SUCCESS) {
             std::cout << "Operating Mode is : " << static_cast<int>(mode)
                 << std::endl;
             operatingMode = static_cast<telux::tel::OperatingMode>(mode);
         } else {
             std::cout << "Operating Mode is : Unknown, errorCode: " << static_cast<int>(error)
             << std::endl;
         }
         callbackPromise.set_value(true);
       }
    };
    
    auto myOperatingModeCallback = std::make_shared<MyOperatingModeCallback>();
    
    void setOperatingModeResponse(telux::common::ErrorCode error) {
         std::cout << "Set Operating Mode is :, errorCode: " << static_cast<int>(error)
             << std::endl;
    }
    Copy to clipboard

6. Request the operating mode of device and set the operating mode to ONLINE, if the operating mode is OFFLINE to perform any operations on the phone

phoneManager->requestOperatingMode(myOperatingModeCallback);
    if((callbackPromise.get_future().get()) &&
       (telux::tel::operatingMode == telux::tel::OperatingMode::OFFLINE )) {
       phoneManager->setOperatingMode(telux::tel::OperatingMode::ONLINE, &setOperatingModeResponse);
    }
    Copy to clipboard

7. Implement IVoiceServiceStateCallback interface

class MyVoiceServiceStateCallback : public telux::tel::IVoiceServiceStateCallback {
    public:
       void voiceServiceStateResponse(const std::shared_ptr<telux::tel::VoiceServiceInfo> &serviceInfo, telux::common::ErrorCode error) override;
    };
    Copy to clipboard

8. Instantiate MyVoiceServiceStateCallback

auto myVoiceServiceStateCallback = std::make_shared<MyVoiceServiceStateCallback>();
    Copy to clipboard

9. Send voice service state request

phone->requestVoiceServiceState(myVoiceServiceStateCallback);
    Copy to clipboard

After receiving voiceServiceStateResponse in MyVoiceServiceStateCallback, the status of voice registration can be accessed by using the VoiceServiceInfo.

Last Published: May 20, 2026

[Previous Topic
Make Third Party Service (TPS) eCall over IMS](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/make_tps_eCall_over_Ims.md) [Next Topic
Request and set operating mode](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/request_set_operating_mode.md)