Unplugging the device via ADB: “can't find service”

早过忘川 提交于 2019-12-04 16:43:22

There is no battery service as the log points out (this may be device specific).

Enter the following command to find existing battery related services:

$ adb shell service list | grep battery

it will result in something like this

$ adb shell service list | grep battery
88      batterymanager: [android.app.IBatteryService]
107     batterystats: [com.android.internal.app.IBatteryStats]
114     batteryproperties: [android.os.IBatteryPropertiesRegistrar]

It makes sense that to manage the battery, you should use the batterymanager.

$ adb shell dumpsys batterymanager

outputs (in case the usb charged is plugged)

Current Battery Service state:
  (UPDATES STOPPED -- use 'reset' to restart)
  AC powered: false
  USB powered: true

then, when you type

$ adb shell dumpsys batterymanager unplug

and run the previous command again, it outputs

Current Battery Service state:
  (UPDATES STOPPED -- use 'reset' to restart)
  AC powered: false
  USB powered: false

Which validates that you should use the batterymanager service instead of battery.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!