0

I am creating an activity which seeks to change the state of LEDs on a device. The LED behavior is handled through an embedded controller with no APIs exposed, so I cannot directly change the state of the LEDs. The state changes based on the charging and battery percentage state of the device. Is there any way for me to simulate a different battery level/charging state via Android Studio to accomplish this?

jjo
  • 154
  • 2
  • 14

2 Answers2

1

With your emulator opened, just click on this button:

enter image description here

Shermano
  • 1,100
  • 8
  • 31
1

You can adjust the battery level on an emulator in the settings.

android emulator settings

Garrett Manley
  • 337
  • 3
  • 11
  • Thank you for the response, can I do this with a physical device I am debugging on? I seek to do it programatically to create test code with it – jjo Jul 01 '19 at 16:52
  • You're not going to be able to do this on a physical device short of hacking your own kernel together. If you're looking to write test code, you should mock the responses from sensors anyway. Just implement a mock service to serve up the battery status to your tests. – Garrett Manley Jul 02 '19 at 00:00