Prevent hard switch off in smartphones using Kotlin - android

While most smartphones now require a PIN/password before we can switch it off, there are some ways to get around this.
For eg. I own a Samsung M30. If I'll press the Volume Down + Power button at the same time, the device will switch off.
I'm trying to develop an android app that lets the user temporarily disable the hard switch off. Is there a way to prevent this programmatically? Thanks!

No. This behaviour is enforced at a very low level. Even system apps can't modify this behaviour.

Related

Restrict Android Safe Mode on power button press

I'm in need to stop entering safe mode on my nexus 7 tablet, because I implemented an Kiosk based application simply overriding home screen. Once default home screen changed to my custom home screen, user not allowed to take reboot device for safe mode. Is there any possibility to implement these feature without changing firmware OS.
Thanks in advance!

Turn off device screen (without locking it)?

I'm making an app that uses the Proximity Sensor while a phone call is in progress. My main issue is that the device doesn't turn the screen off when I hold it up against my face (while talking on the phone). If anyone has a solution as to how to fix this, then my problem will be solved.
Right now though, I'm trying to manually switch the screen off to imitate the normal behavior of the phone app. I looked through a lot of other posts about this but most of them seem to have instructions on how to keep the screen turned ON. My case is the exact opposite... how do I programmatically set the device to turn it's screen off? I don't want it to lock itself or sleep (since the phone call will still be in progress), just turn the screen completely off.
Thanks!

How to hold android device in dim-wakelock with disabled touchscreen?

I want to write an app that needs accelerometer data while the user has the device in his pocket. However, at least on my phone (Motorola Defy with a nightly CM9 build), a dim-wakelock is needed because the accelerometer somehow turns off together with the screen. But if the screen stays turned on, the user might trigger random touch actions with his body movements. I could just display a black area, but that won't protect the menu keys. So, what should I do to protect the device from accidential user interaction? Things that come to my mind:
use root access to somehow hook deep into the system and require an unlock pattern or so - but I as a user would hesitate to give an app root just because it wants to block my input, and if I as coder make a mistake, I might lock out users -> might work, but probably the worst possible solution
somehow use the lock screen for this - but I don't know how I can safely, whatever the settings on the device may be, activate that lock screen without needing root
Gah, this all just looks bad to me. Is there any way to solve this that doesn't suck?

Disabling screen switch off

We have a large fleet of android devices (Archos 70, running android 2.2) that we develop apps for to be used in the live events market.
One big problem we encounter is users touching the power key and turning the screen off, which generally they cannot find the key to turn them back on.
Is there any way in our flash air app that we can capture this key press and discard it?
Any help would be greatly appreciated!
No, actually this is impossible. This functionality is a part of Android. If you press power button everything is disabled. Even if you have wakelocks in your application they are all released when a user presses the power button. And I think that Google do not want to add such type of wakelock to their system because buggy applications can in this case block the ability to disable screen.

Machine that can turn phone 90 degrees every few seconds?

I want to detect memory leaks in my Android application. Some leaks could be detected while rotating the phone physically so that the activities are constantly recreated.
I'm looking of some sort of physical device that could turn the phone 90 degrees every X seconds. I could build something using lego Mindstorm (that would actually be very cool), but I'm looking for something cheaper.
I also thought of using a clock, but I couldn't find one that has a clock second hand strong enough. Futhermore if the phone rotate 360 degrees after some time the USB cable would become too twisted. I think a device that goes back and forth between horizontal and vertical would be perfect.
My dream testing machine would also allow me to plug a USB cable so that I can run the Monkey tool while constantly rotating the phone.
Why don't you just force the orientation change or destroy and recreate the views every X seconds? I think it's more reliable than a mechanical approach. I can also recommend you this : http://developer.android.com/guide/developing/tools/monkey.html
You need to trigger configuration change somehow. This might be orientation change, hardware keyboard is opened or hidden, or any other change listed here: android:configChanges.
And there is one way to change configuration without using physical approach. You can use "Car Mode" or "Night Mode". Both only work in Android 8+ and can be turned on/off using UiModeManager.
So you can write your custom Service that will periodically call UiModeManager.enableCarMode(0) and UiModeManager.disableCarMode(0);, which in turn will force configuration changes in your Activity under test.
Perhaps http://mindstorms.lego.com/ Lego MindStorms? To be fair, it's about $250 so not really "throwaway cheap" but the advantage of being fully programmable might outweigh that.
As far as I know it's the cheapest robot kit out there which is why universities and schools use it.

Categories

Resources