BatteryManager.getLongProperty

Please refer to the Intent.createFromParcel/battery hook documentation.

CollectionFif
GroupRead battery
NameBatteryManager.getLongProperty
AuthorFif
Version1
Updated (UTC)2018-10-10 01:34:33
Created (UTC)2018-10-10 01:34:33
Downloads862
Class nameandroid.os.BatteryManager
Method namegetLongProperty
Parameter typesint
Return typelong
Min SDK21
Max SDK999
Min APK0
Max APK2147483647
Excluded packages-
EnabledYes
OptionalNo
UsageYes
NotifyNo
Settings-
-- BatteryManager.* is a set of Lua hook definition designed to work                     
-- with XPrivacyLua.

-- BatteryManager.* is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.

-- BatteryManager.* is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.

function after(hook, param)
  local result = param:getResult()
  if result == nil then
    return false
  end

  local batteryManager = param:getThis()
  local property = param:getArgument(0)
  local fake = nil
  local propName

  if property == batteryManager.BATTERY_PROPERTY_CHARGE_COUNTER and result ~= 0 then
    propName = 'Charge counter'
    fake = 0
  elseif property == batteryManager.BATTERY_PROPERTY_ENERGY_COUNTER then
    propName = 'Energy counter'
    fake = 150000
  elseif property == batteryManager.BATTERY_PROPERTY_STATUS and result ~= batteryManager.BATTERY_STATUS_DISCHARGING then
    propName = 'Status'
    fake = batteryManager.BATTERY_STATUS_DISCHARGING
  end

  if fake ~= nil then
    param:setResult(fake)
    return true, propName .. '=' .. tostring(result), propName .. '=' .. tostring(fake)
  else
    return false
  end
end