How to change the Android Battery percentage
Mobile app developers must ensure that their applications function properly in low battery conditions. But how can you test app behavior when you don't have a low battery on hand?
Sometimes , we need to check the low battery scenario over our Android Phones under certain conditions. Either you can put the low battery into your phone for which you need to have a battery of same phone or you can reduce the battery by keeping the WIFI, GPS, BT to On, keeping the brightness level to 100% and then keeping the camera for recording a video with Flash light in On state. Doing this will easily consume more time and everyone hates it.
In this guide, we'll show you how to simulate low battery conditions on an Android phone using ADB commands.
Install ADB on your PC/Laptop. There are easy tutorial available all over the internet.
From command prompt / terminal type below set of commands.
To find the current battery level
Steps to follow for mocking the Battery level
So, here is a simple solution to change level as per need.Install ADB on your PC/Laptop. There are easy tutorial available all over the internet.
From command prompt / terminal type below set of commands.
To find the current battery level
C:\>adb shell dumpsys battery
Next run,
C:\>adb shell dumpsys battery set usb 0
C:\>adb shell dumpsys battery unplug
C:\>adb shell dumpsys battery set usb 0
C:\>adb shell dumpsys battery unplug
OR you can run
C:\>adb shell dumpsys battery set status 3
Above command would set the battery to discharging status even though USB cable is connected to the mobile device.
And then run the below command to set the battery percentage as required.
x indicates the percentage of battery to be set
For Example,
C:\>adb shell dumpsys battery set level 55
To Reset the Battery status back, you can use:
adb shell dumpsys battery reset
With Above steps will help in mocking the Low Battery scenario, in-case you want to test an android app behaviour with low battery.
If you could not reset the battery, just reboot the mobile phone and battery level would get reset to actual value.
No comments:
Post a Comment