Sha256: 7d258b9217dfcce3475d85f76b98e2935f45eedfe3f64f20db118e8ae7db168f

Contents?: true

Size: 1.03 KB

Versions: 28

Compression:

Stored size: 1.03 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::Base::Device::BatteryStatus::ANDROID[response['state']]
                          else
                            ::Appium::Logger.warn("The state is unknown or undefined: #{response['state']}")
                            ::Appium::Core::Base::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

28 entries across 28 versions & 1 rubygems

Version Path
appium_lib_core-3.0.2 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-3.0.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-3.0.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.3.4 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.3.3 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.3.2 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.3.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.3.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.2.2 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.2.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.2.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.1.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.1.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.6 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.5 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.4 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.3 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.2 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.1 lib/appium_lib_core/android/uiautomator2/device/battery.rb
appium_lib_core-2.0.0 lib/appium_lib_core/android/uiautomator2/device/battery.rb