<s> from jnius import autoclass , cast <EOL> from plyer . platforms . android import activity <EOL> from plyer . facades import Battery <EOL> Intent = autoclass ( '<STR_LIT>' ) <EOL> BatteryManager = autoclass ( '<STR_LIT>' ) <EOL> IntentFilter = autoclass ( '<STR_LIT>' ) <EOL> class AndroidBattery ( Battery ) : <EOL> def _get_state ( self ) : <EOL> status = { "<STR_LIT>" : None , "<STR_LIT>" : None } <EOL> ifilter = IntentFilter ( Intent . ACTION_BATTERY_CHANGED ) <EOL> batteryStatus = cast ( '<STR_LIT>' , <EOL> activity . registerReceiver ( None , ifilter ) ) <EOL> query = batteryStatus . getIntExtra ( BatteryManager . EXTRA_STATUS , - <NUM_LIT:1> ) <EOL> isCharging = ( query == BatteryManager . BATTERY_STATUS_CHARGING or <EOL> query == BatteryManager . BATTERY_STATUS_FULL ) <EOL> level = batteryStatus . getIntExtra ( BatteryManager . EXTRA_LEVEL , - <NUM_LIT:1> ) <EOL> scale = batteryStatus . getIntExtra ( BatteryManager . EXTRA_SCALE , - <NUM_LIT:1> ) <EOL> percentage = ( level / float ( scale ) ) * <NUM_LIT:100> <EOL> status [ '<STR_LIT>' ] = isCharging <EOL> status [ '<STR_LIT>' ] = percentage <EOL> return status <EOL> def instance ( ) : <EOL> return AndroidBattery ( ) </s>
