0

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.

gpedote
  • 38
  • 1
  • 8

2 Answers2

1

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.
Sudhu
  • 507
  • 5
  • 17
  • Thanks for your answer! I get that _apps defined in the policy will be launched automatically when a device boots_, but that is not my question. Sorry if I wasn't clear, but what I want is to boot the device automatically when plugged in on a power source. Currently, to overcome this problem, the devices are never shutdown, but for me this is not an ideal solution. Also, I can't provide access to the power button to the users. – gpedote May 17 '19 at 08:46
  • The question before the edit was very different. Anyways, I've updated my answer. But I'm not sure if it's currently possible to boot the device automatically when plugged in on a power source. – Sudhu May 20 '19 at 07:36
0

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.

LucasRT
  • 167
  • 2
  • 14