1

I´m trying to configure a Android Single Use app. I´m using a Huawei P8 Lite with Android 6.0 and a Samsung Galaxy A3 2017 with Android 6.0. I´ve set the app to Device Owner and everything works well. I´ve deactivated Toast messages via adb and set the home button to the app. So everything works fine. When I start the app you can´t leave it anymore, even with a restart. But now there are 2 problems left. On the Samsung it works fine to deactivate Toast messages with the adb code

adb shell appops set android TOAST_WINDOW deny

but on the Huawei it does not work. It doesn´t show an error.

The second problem I got with the Samsung. When I restart the Huawei and press the "Home" Button I get directly into the app without having to swipe at the lockscreen. When I open the app at the Samsung it´s the same, but after a restart I always get into the lockscreen before entering the app. This is a little problem because it´s possible to open the dropdown menu with swiping down. The buttons there do not work but I want to get directly into the app when I press the Home or Power button.

So my Questions are: - How to deactivate the toast messages on the Huawei? - How to deactivate the whole lockscreen on the Samsung?

Anyone got an idea?

Thanks

J. Hock
  • 125
  • 1
  • 11

1 Answers1

1

To bypass the lockscreen on the Samsung, you can try wake up the device by launching an activity as soon as the device starts, with the following flags

this.getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

copied from how to wakeup android phone from sleep?. Just make sure that you have chosen "None" as a screen lock type or called setKeyguardDisabled, which has the same effect.

To deactivate toast you need root privilege, so your device needs to be rooted and you need to do

adb root & adb shell appops set android TOAST_WINDOW deny
Fred
  • 2,191
  • 1
  • 12
  • 14
  • thank you i think this helps a lot! can you explain why the toast deactivation works fine on the samsung but not on the huawei? – J. Hock Aug 16 '17 at 09:30
  • Maybe the Huawei is not rooted? Or you didn't call `adb root`? – Fred Aug 16 '17 at 11:39
  • The Samsung isn´t rooted too but adb shell appops set android TOAST_WINDOW deny works fine while it doesn´t on the huawei. – J. Hock Aug 16 '17 at 11:43
  • Then maybe the `android` package is not the one showing the toast. You can try disabling toast for other system packages, you can get the list with `adb shell cmd package list packages -s -e` (or `adb shell pm list packages -s -e` on old versions for adb). – Fred Aug 16 '17 at 11:56