Is it possible to make my application work in safe mode?
Asked Answered
H

5

21

I have an android application which lists installed and system applications separately. When the user tries to reboot the device from my application it will open my application instead of default home launcher.

But when the device is rebooted to 'safe mode' all logic crashes .ie, the device rebooted to my application in safe mode but it does not list any installed applications and stops its working.

  1. Is it possible to make my application work in 'Safe mode' also?

  2. Is there any way to prevent the device from going to 'safe mode' while running my application like using a RECEIVE_BOOT_COMPLETED broadcastreceiver?

  3. What is device admin applications? Is it helpfull in this situation?

  4. Is it possible to detect safe mode programmatically?

Thanks in advance

Hildie answered 24/5, 2013 at 6:50 Comment(7)
In safe mode, all user apps are supposed to be disabled (that's the whole point), so you probably won't be able to do anything with your app then unless you have root access and install it as a system app.Farahfarand
Are you sure it does not work if i make my application as a device admin app?Hildie
What do you mean by a device admin app? AFAIK, there's really no such thing, there's just three different kinds of app: rooted apps, system apps, and normal user apps.Farahfarand
Device administration enabled applications developer.android.com/guide/topics/admin/device-admin.html and marakana.com/s/post/1291/…Hildie
Ah, right, I'd forgotten about that - However, I don't think an app using that API will automatically be enabled in Safe Mode; like I said, that's kinda the entire point of Safe Mode, to sort of emulate a factory reset without actually uninstalling anything.Farahfarand
Ok.I understand.Is the Broadcastreceivers like ACTION_BOOT_COMPLETED of 3rd party application works in safe mode which is registered in manifest file?Hildie
I believe not - but, not totally sure. If you want to check, you could put some log message in the BroadcastReceiver and check yourself.Farahfarand
T
6

I know this question is old, but perhaps this will help someone. If your application is Device Owner or Profile Owner on the primary user, you can disable safe mode completely (it works without root):

DevicePolicyManager manager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName admin = new ComponentName(getApplicationContext(), DeviceAdminReceiver.class);
// To disable safe boot
manager.addUserRestriction(admin, UserManager.DISALLOW_SAFE_BOOT);
// To enable safe boot again
// manager.clearUserRestriction(admin, UserManager.DISALLOW_SAFE_BOOT);

EDIT: You can set Device Owner or Profile Owner simply via ADB: https://developer.android.com/studio/command-line/adb#dpm

adb shell dpm set-device-owner com.example.deviceownerapp/.DeviceAdminReceiver

Note that you must have no accounts added when activating device owner (you don't have to do system reset though, just remove all account from settings). After device owner is set, you can add any accounts again.

Thingumabob answered 20/7, 2017 at 19:23 Comment(2)
Thanks that helped me. Here is an explanation about how to become a Device Owner or Profile Owner: developers.google.com/android/work/play/emm-api/prov-devicesErythrocyte
I updated answer with explanation how to enable Device Owner simply via ADB.Thingumabob
C
1

If you create a shortcut of that particular app that you want to launch in safe mode, you can do so while in safe mode. But you should be in normal mode when creating the shortcut.

Conjuncture answered 17/8, 2016 at 21:34 Comment(0)
B
1

The only way to do this is to make the user app a system app on /system/app

But if your device is rooted there is an easy way to do this

  1. download lucky patcher and enable root access

  2. use the search option to find the app you want to be able to use in safe mode or just find it in the scrolling menu

  3. click on the app, click on tools, then press move to /system/app

  4. after the process is complete the device will have to be restarted

  5. the user app is now able to be accessed in safe mode

Beaudoin answered 31/5, 2018 at 20:6 Comment(0)
A
0

Device admin apps as well dont run.

To run your app in safe mode, you need to copy your app to /system/app, for which you need root access.

So only on rooted device it is possible.

Allegro answered 16/12, 2014 at 14:11 Comment(0)
P
-5

Out of safe mode,Put an installed app on Home screen. Reboot into safe mode,and the app will be on Home screen, and the app will work in safe mode!

Prolix answered 23/6, 2015 at 22:57 Comment(2)
Has anyone verified this answer?Elsi
It does not work. A Toast is shown which says - Download app disabled in Safe modeRenault

© 2022 - 2024 — McMap. All rights reserved.