Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

KioskPlugin.exitKiosk() does not seem to work #46

Open
wiserweb opened this issue May 1, 2018 · 16 comments
Open

KioskPlugin.exitKiosk() does not seem to work #46

wiserweb opened this issue May 1, 2018 · 16 comments

Comments

@wiserweb
Copy link

wiserweb commented May 1, 2018

This issue is occurring using Genymotion v2.12.0 Android emulator with S7 Android 6.0.0 API 23 image.

The app has a button, 'Exit Kiosk Mode' when it is clicked I can see the KioskPlugin.exitKiosk(); firing but still cannot switch app or access settings to change default launcher.

If the command KioskPlugin.exitKiosk(); is run directly in the console it returns undefined.

Any suggestions?

Thanks.

@thaarok
Copy link
Owner

thaarok commented May 2, 2018

Does KioskPlugin.isInKiosk(function(isInKiosk){ alert(isInKiosk); }); returns true for you? (=is activity from this plugin running?)
Does KioskPlugin.isSetAsLauncher(function(isLauncher){ alert(isLauncher); }); returns true for you? (=is that activity set as launcher?)

@wiserweb
Copy link
Author

wiserweb commented May 2, 2018

Hi, yes they are both returning true. The app is definitely in Kiosk mode.

I'm not sure what the normal behavior of exitKiosk should be.

Would it simply allow me to switch apps or display a menu to choose a new Launcher?

@thaarok
Copy link
Owner

thaarok commented May 2, 2018

exitKiosk shows menu to choose launcher to start - typically to go into standard launcher of the phone.
Is some menu like that shown? If yes, just choose your usual launcher to get into phone menu.
Just note that it allows to go into phone menu to set something (change default launcher in phone settings), but when press Home button, you will be returned back into the kiosk app - if you will not change launcher in settings manually.

@wiserweb
Copy link
Author

wiserweb commented May 2, 2018

Thanks for clarification.

I went into that menu to manually set the launcher to the app initially. When exitKiosk is fired though there is no menu displayed to choose a launcher.

The Android image mentioned above provide the choice of two launchers by default, Pixel Launcher and Google Launcher.

After setting the app as default launcher I cannot get back into settings or anything so I have to delete the image.

Have you tried it with Genymotion? Perhaps the root cause of this issue has to do with the android image that is supplied by the emulator. Just speculation at this point.

If you test with Genymotion, probably a good idea to clone the test image you use to test the plugin to avoid having to recreate the image from scratch.

@wiserweb
Copy link
Author

wiserweb commented May 6, 2018

Hi, we can rule out that this issue is caused by using a Genymotion android image.

I have tried with POP7 Alcatel Tablet and able to reproduce the issue. I can confirm no launch selector menu is displayed when using this function on this device.

KioskPlugin.exitKiosk();

@thaarok
Copy link
Owner

thaarok commented May 6, 2018

Can you obtain list of installed launchers (activities for using in intent) on your testing device/emulator?

@wiserweb
Copy link
Author

wiserweb commented May 7, 2018

Yes, launchers on Genymotion Android S7 image are 'Google Now Launcher' and 'Pixel Launcher'.

I did some more testing today and was able to get the Select launcher dialog to display using this plugin (https://github.com/guatedude2/cordova-plugin-kiosk-launcher) which is a based on your plugin.

In your codebase the function is exitKiosk and guatedude2 it is switchLauncher.

Comparing the two native Android calls they seem nearly identical except for one line.

KioskActivity.kioskModeEnabled = false;

guatedude2

       } else if (SWITCH_LAUNCHER.equals(action)) {
                KioskActivity.kioskModeEnabled = false;
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                Intent chooser = Intent.createChooser(intent, "Select destination...");
                if (intent.resolveActivity(cordova.getActivity().getPackageManager()) != null) {
                    cordova.getActivity().startActivity(chooser);
                }

                callbackContext.success();
                return true;
            }

hkalina

           } else if (EXIT_KIOSK.equals(action)) {
                
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                
                Intent chooser = Intent.createChooser(intent, "Select destination...");
                if (intent.resolveActivity(cordova.getActivity().getPackageManager()) != null) {
                    cordova.getActivity().startActivity(chooser);
                }
                
                callbackContext.success();
                return true;               

@thaarok
Copy link
Owner

thaarok commented May 7, 2018

That is weird - both projects use identical code for existKiosk...
Can you record and provide log from adb logcat ?
If you can, try to add following additional debug output into the plugin code and re-add plugin:

                if (intent.resolveActivity(cordova.getActivity().getPackageManager()) != null) {
                    cordova.getActivity().startActivity(chooser);
                    System.out.println("Kiosk: activity chooser started"); // this
                } else {
                    System.out.println("Kiosk: unable to resolve launcher activity"); // and this
                }

@thaarok
Copy link
Owner

thaarok commented May 8, 2018

Please retest with latest version. I just tested on Windows 10 + latest Genymotion + Android you mention and kiosk exiting works ok:
https://ctrlv.cz/E3a9
If problem persists, test with demo application:
https://github.com/hkalina/cordova-kiosk-demo

@thaarok
Copy link
Owner

thaarok commented May 8, 2018

Unable to reproduce - closing - feel free to reopen if will find steps to reproduce the issue.

@thaarok thaarok closed this as completed May 8, 2018
@wiserweb
Copy link
Author

wiserweb commented May 8, 2018

Haven't had a chance to test yet. I will test again with screen recording and share results here. Thanks.

@thaarok
Copy link
Owner

thaarok commented May 8, 2018

No screen recording needed - I need way to reproduce the issue on my machine or more info at least.
Please, try to compile and run the demo app: https://github.com/hkalina/cordova-kiosk-demo
If there WILL be the same problem, check your build environment/downloaded Android image - it is working for me on image you mentioned.
If there WILL NOT be the same problem, try to find what is different in your project - send source of minimal failing project here.

@wiserweb
Copy link
Author

wiserweb commented May 9, 2018

I will be using Meteor sample Todo application (https://github.com/meteor/todos) to replicate. Actual project which would not display Launch screen is also Meteor-based application. I'll commit code to a new repo so that it can be reproduced on your end.

The Meteor app is built with same HTML/CSS/Javascript so very similar the sample kiosk-demo you created for this plugin.

I'm as puzzled as your are as to why this issue is occurring. I'll do a screen record just so we're completely on the same page as to what might be the root cause.

@LucaColombi
Copy link

Hello, similar proplem, exitKiosk does nothing.

But if I read correctly, in my case I wuld need a real exit kiosk: Some way to disable kiosk, or prevent it from starting, actually I can only exit the application and no send it in background, how could I achieve it?

@thaarok
Copy link
Owner

thaarok commented Jul 21, 2018

@LucaColombi the exitKiosk() should show launcher selection - which allows to switch to regular lanuncher and the current task is sent to background. Can you provide steps to reproducing?

@thaarok thaarok reopened this Jul 21, 2018
@posipunk
Copy link

@hkalina @LucaColombi I'm developing an Ionic application and had the same issue where the exitKiosk does nothing (isInKiosk returns true, isSetAsLauncher returns true).
Tested on a Samsung Note 8
My workaround for now is this.platform.exitApp(); which closes the application and gives me the opportunity to switch launchers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants