3

I have a few devices using the Android Management API and running in kiosk mode.

I have encountered a new issue regarding the NFC scanning after upgrading from Android 10 -> Android 12. After a device restart everything seems to be working fine and if I manually trigger a device sleep by pressing the power button and waking it all is well.

But as soon as the device's display times out and I press the power button to wake it the NFC stops working.

Here are some of the debug logs of the NfcService (the device is unlocked, left for a few seconds and locked again):

2022-09-01 21:12:16.245 2325-2325/? D/NfcService: BroadcastReceiver - SCREEN_STATE_ON_UNLOCKED
2022-09-01 21:12:16.271 2325-2325/? D/NfcService: NfcServiceHandler - handleMessage(MSG_APPLY_SCREEN_STATE) - state: ON_UNLOCKED
2022-09-01 21:12:16.273 2325-2325/? D/NfcService: Discovery configuration equal, not updating.
2022-09-01 21:12:16.442 2325-4028/? D/NfcService: Disabling default Beam behavior
2022-09-01 21:12:16.520 2325-2325/? D/NfcService: BroadcastReceiver - SCREEN_STATE_ON_LOCKED
2022-09-01 21:12:16.520 2325-2325/? D/NfcService: NfcServiceHandler - handleMessage(MSG_APPLY_SCREEN_STATE) - state: ON_LOCKED
2022-09-01 21:12:17.284 2325-2325/? D/NfcService: NfcServiceHandler - debounceRfField() - debouncing RF_FIELD: 0 (cur:0, pol:true)
2022-09-01 21:12:17.284 2325-2325/? D/NfcService: NfcServiceHandler - debounceRfField() - Ignoring, already the current state
2022-09-01 21:12:18.244 2325-2325/? D/NfcService: BroadcastReceiver - SCREEN_STATE_OFF_LOCKED
2022-09-01 21:12:18.244 2325-2325/? D/NfcService: NfcServiceHandler - handleMessage(MSG_APPLY_SCREEN_STATE) - state: OFF_LOCKED

As far as I can see the screen is unlocked but something is triggering the screen to get caught up in a locked state (SCREEN_STATE_ON_LOCKED).

I can confirm this because if I physically hover the device over a NFC tag and unlock it, it immediately scans the tag but after the first second it doesn't work at all.

I have also tried to disable the keyguard programmatically but without any success!

Here is the current active device policy:

{
    "factoryResetDisabled": true,
    "systemUpdate": {
        "type": "WINDOWED",
        "startMinutes": 0,
        "endMinutes": 240,
        "freezePeriods": [
            {
                "startDate": {"month": 8,"day": 1},
                "endDate": {"month": 9,"day": 30}
            }
        ]
    },
    "applications": [
        {
            "packageName": "com.xxx.yyy",
            "installType": "KIOSK",
            "defaultPermissionPolicy": "GRANT",
            "autoUpdateMode": "AUTO_UPDATE_DEFAULT"
        }
    ],
    "funDisabled": true,
    "appAutoUpdatePolicy": "WIFI_ONLY",
    "kioskCustomization": {
        "statusBar": "NOTIFICATIONS_AND_SYSTEM_INFO_ENABLED",
        "deviceSettings": "SETTINGS_ACCESS_ALLOWED",
        "systemNavigation": "HOME_BUTTON_ONLY"
    },
    "tetheringConfigDisabled": true,
    "mobileNetworksConfigDisabled": false,
    "advancedSecurityOverrides": {
        "developerSettings": "DEVELOPER_SETTINGS_ALLOWED"
    }   ,
    "maximumTimeToLock": 0,
    "keyguardDisabled": true,
    "keyguardDisabledFeatures": "ALL_FEATURES"
}

It seems that the issue is similar to these questions:

  1. Android 11 - Kiosk Mode Lock Screen NFC Issue
  2. Android 10 NFC App - Stops working when phone sleeps while in MS Intune Kiosk Mode

Unfortunately the solutions proposed aren't going to work for my application.

Can anyone recommend a solution or has anyone encountered the same issue?

Johan Ferreira
  • 515
  • 4
  • 15

2 Answers2

1

I bumped into the same issue on iGET BV5200 running Android 12. After provisioning the device, the screen lock is set to "Swipe" by default. Although my kiosk app sets Device Policy to disable keyguard and Android setting shows no screen lock is set, the swipe lock is under my app and blocks NFC reading after I wake the device from sleep. I have found the key to the resolution of this issue is to allow keyguard in Lock Task mode.

I found two solutions/workarounds:

  1. Allowing the keyguard in Device Policy and Lock Task mode, and setting manually screen lock to "None" in Android Settings.

    devicePolicyManager.setKeyguardDisabled(adminComponentName, false); devicePolicyManager.setLockTaskFeatures(adminComponentName, LOCK_TASK_FEATURE_KEYGUARD | LOCK_TASK_FEATURE_GLOBAL_ACTIONS);

  2. Disabling the keyguard in Device Policy but enabling the keyguard feature in lock task mode. I do not have to change screen lock in the Android settings in this case, but the keyguard gets disabled.

    this.devicePolicyManager.setKeyguardDisabled(this.adminComponentName, true); this.devicePolicyManager.setLockTaskFeatures(this.adminComponentName, LOCK_TASK_FEATURE_KEYGUARD | LOCK_TASK_FEATURE_GLOBAL_ACTIONS);

0

Thanks for raising the issue. Upon review, we identified an active internal investigation for your reported problem, which is currently under review with Google engineering. We passed along the details you provided as part of the investigation. Additionally, a public bug has been made to track this issue. Please follow that thread for updates.

Danica
  • 136
  • 5
  • Thanks for the update @Danica, unfortunately I'm unable to open that link without a google.com account. Is there a public link available? – Johan Ferreira Sep 06 '22 at 12:56
  • 1
    Found the public bug here: https://issuetracker.google.com/issues/195910688 – Kevin Sep 08 '22 at 15:53
  • Unfortunately it seems this bug has been around since Aug 2021 and there are no updates regarding if/when it's going to be fixed... – Johan Ferreira Sep 13 '22 at 12:11