Android "Pin Screen" feature fails when resume Solar2D app after toggle power button

Android has a “pin screen” feature, allowing users to ‘lock’ a specific app to the screen.

When an app is pinned the system menu is disabled and you need to press the “back” and “overview” buttons simultaneously to exit the app, and optionally enter the device passcode.

For apps made for young kids (think 3 - 5 years old) this is a great feature for parents. They can start a game, pin the screen and hand the device to a child. The child won’t be able to accidentally swipe down the system menu or exit the app.

Unfortunately on my Android 12 device it does not work for Solar2D apps. Steps:

  1. Launch a Solar2D app.

  2. Open the Android Overview (“Taskswitcher”, i.e. square system button). Pin the screen by tapping the icon over the app window in the overview. Confirm the pinning.


  3. Press the power button to turn off the screen

  4. Press the power button to turn on the screen

Result: The screen is black, showing only the three system buttons on my device, but it should return to the app. I have had users reporting that there were no buttons shown at all so they had to wait for the battery to discharge fully. (Sidenote: The screen is not completely black, it is the slight gradient that Il Sui mentions in this GitHub issue)

It works on my Android 8.1 and 9 devices.

I often get requests about how to ‘lock’ the app so my users’ kids won’t exit the apps while playing on the parents devices, and would love to be able to recommend screen pinning.

Some potential clues from log, for package se.appfamily.balloonpopfree:
Android 12 wakes from dozing:

05-18 09:22:19.780 1716 2261 I PowerManagerService: Powering on display group fromDozing (groupId=0, uid=1000, reason=WAKE_REASON_POWER_BUTTON, details=android.policy:POWER)…
05-18 09:22:19.781 1716 2261 I PowerManagerService: Waking up from Dozing (uid=1000, reason=WAKE_REASON_POWER_BUTTON, details=android.policy:POWER)…

Then there is just one mention of the package:

05-18 09:22:20.328 3780 3780 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1885 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=se.appfamily.balloonpopfree fieldId=-1 fieldName=null extras=null}, false)

Android 8.1 wakes from sleeping:

05-18 09:25:33.937 929 998 I PowerManagerService: Waking up from sleep (uid=1000 reason=android.policy:POWER)…

And proceeds with some more mentions of the package:
05-18 09:25:33.943 4129 4129 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1885 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=se.appfamily.balloonpopfree fieldId=-1 fieldName=null extras=null}, false)
05-18 09:25:33.945 4129 4129 I GoogleInputMethodService: GoogleInputMethodService.updateDeviceLockedStatus():2077 checkRepeatedly = true, unlocked = true
05-18 09:25:33.945 190 190 D SurfaceFlinger: duplicate layer name: changing SurfaceView - se.appfamily.balloonpopfree/com.ansca.corona.CoronaActivity to SurfaceView - se.appfamily.balloonpopfree/com.ansca.corona.CoronaActivity#1
05-18 09:25:33.946 190 190 D SurfaceFlinger: duplicate layer name: changing Background for - SurfaceView - se.appfamily.balloonpopfree/com.ansca.corona.CoronaActivity to Background for - SurfaceView - se.appfamily.balloonpopfree/com.ansca.corona.CoronaActivity#1

After reading up on doze vs sleep it doesn’t seem like it should matter, the issue persists even when the Android 12 device is connected to a charger (which disables doze, apparently)

2 Likes