Airplane mode On status is Always True

301 views Asked by At

I am Using adb command to get the status of airlane_mode_on in appium using python. But its always returning 'True' even when it is off. Below is the code snippet.

def getGlobalSettingsOperation(self):
    self.__log.info('AndroidDevice.getGlobalSettingsOperation() [{}]: Performing get operation on global setting "{}"'.format(self.name(), flag))
    try:
        status = self.__adb.shell(['settings', 'get', 'global', 'airplane_mode_on'])
        self.__log.info('AndroidDevice.getGlobalSettingsOperation(): value of getGlobalSettingsOperation with flag [{}] is:  "{}"'.format(flag, status))
        return status
    except:
        self.__log.exception('AndroidDevice.getGlobalSettingsOperation() [{}]: exception'.format(self.name()))
        return False

The value of status is always True. But the same command when i am using for put operation, it is working fine.I tried in many android devices. Kindly help.

1

There are 1 answers

0
dmle On

Try to use it with appium client function:

nc = self.driver.network_connection

where

NO_CONNECTION = 0
AIRPLANE_MODE = 1
WIFI_ONLY = 2
DATA_ONLY = 4
ALL_NETWORK_ON = 6