Sha256: cc7db62951f4e13bf5c22e9d493c9eb4a078eafc322e49287535dc6209c862ae

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Appium
  module Core
    module Android
      module Uiautomator2
        module Device
          module Battery
            def self.add_methods
              ::Appium::Core::Device.add_endpoint_method(:battery_info) do
                def battery_info
                  response = execute_script 'mobile: batteryInfo', {}

                  state = case response['state']
                          when 2, 3, 4, 5
                            ::Appium::Core::Device::BatteryStatus::ANDROID[response['state']]
                          else
                            ::Appium::Logger.warn("The state is unknown or undefined: #{response['state']}")
                            ::Appium::Core::Device::BatteryStatus::ANDROID[1] # :unknown
                          end
                  { state: state, level: response['level'] }
                end
              end
            end
          end # module Battery
        end # module Device
      end # module Uiautomator2
    end # module Android
  end # module Core
end # module Appium

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appium_lib_core-1.7.2 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-1.7.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-1.7.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb