How to automatically power on an Android COSU device when plugged in?

2k Views Asked by At

I want to setup some tablets in a way that they automatically turn on and open my application when connected in a power source. Those tablets will be all COSU devices and my application is a single app. I have read the docs and the closest policy that I have found was stayOnPluggedModes in this page, and the description is not very clear (at least to me).

Unfortunately, at the moment, I am unable to test if this policy works. So, is the stayOnPluggedModes policy the right one for what I need? If not, what are my options (excluding everything bellow, because it voids the device warrant)?

And also this one doesn't work because it requires the device to be asleep.

2

There are 2 best solutions below

2
Sudhu On

You can use Kiosk Mode, any apps defined in the policy will be launched automatically when a device boots. They run in full-screen mode and are typically pinned to the home screen in a way that prevents users from leaving the app.

"kioskCustomLauncherEnabled": true

Or Lock task mode which hides the Home and Recents buttons on a device, preventing users from escaping the app. To create a policy that supports an app with lock task mode.

"applications": [
  {
    "packageName": "com.example.app",
    "installType": "FORCE_INSTALLED",
    "lockTaskAllowed": true,
    "defaultPermissionPolicy": "GRANT"
  }
],

Note: Lock task mode is only compatible with Android 6.0+ devices.

--- Edit ---

Here's what you can try.

  1. Enable "powerManagementEventsEnabled" available in the "StatusReportingSettings" of the policy. This will log events related to power source such as charger connected, disconnected etc.
  2. If the device is connected to the power source, an event will be created for the same. Try and fetch the event by adding a listening event using Pub/Sub.
  3. Once the event returns as Plugged In or Power Source Connected then open the apps maybe.
0
LucasRT On

for some devices this works:

  • boot device in fastboot mode
  • open adb shell
  • type: fastboot devices (check your device exists)
  • then use fastboot command: fastboot oem-off-mode charge 0
  • finally "fastboot reboot"

hope it helps.