Is it possible to make my application work in safe mode? - android

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.
Is it possible to make my application work in 'Safe mode' also?
Is there any way to prevent the device from going to 'safe mode' while running my application like using a RECEIVE_BOOT_COMPLETED broadcastreceiver?
What is device admin applications? Is it helpfull in this situation?
Is it possible to detect safe mode programmatically?
Thanks in advance

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.

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.

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
download lucky patcher and enable root access
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
click on the app, click on tools, then press move to /system/app
after the process is complete the device will have to be restarted
the user app is now able to be accessed in safe mode

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.

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!

Related

can we able to lock all applications in android device through android-management-api?

While applying lock command through android-management-api in the device, the device will be locked. But if users know the password, they can able to unlock the device and use the applications in the device.
My requirement is to disable all applications for a specific amount of time. Is there any possibility to achieve this functionality through android-management-api?
If you want to lock the device and prevent user access entirely, you can reset the device’s password and then lock the device using issueCommand: RESET_PASSWORD and LOCK.
You can also use Devices.patch() and set state to “DISABLED” to disable all the applications (for fully managed devices) or work apps (when enrolled in work profile) from the device.
If perhaps you want to achieve this because of compliance issues, then the IT admin can wipe the device (for fully managed), remove any corporate apps from the device, or remove the work profile. This can also be automated by using compliance rules.
use disable key word and set as true in application policy to disable the app.
Try this link.
And also vote me if it works fine.
https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#applicationpolicy

Does uninstalling the application removes the device owner settings the application has utilized?

I'm trying to create an application that can disable or hide other applications. After going through some online resources i found out that i have to make my application the device owner to do so.
I would like to know, if i make my application the device owner, will that permission be removed when i uninstall the application?
You can't uninstall the device owner. You also can't become the device owner if you're a Play Store app. Device ownership really is only possible if its a device you physically own and can set up.

Screen pinning as device owner not working

I'm trying to build a kiosk app using android 5's screen pinning feature. It seems that all I need to do in the app was to call startLockTask(), but this still allows the user to leave the app by pressing the recent and back buttons.
To pin the app in a way that does not allow the user to leave it requires the app to be a device owner. Based on sites such as this one, one needs to run
adb shell dpm set-device-owner my.package.name/.MyAdminReceiver
in order to set the device owner. However, that command failed with
java.lang.IllegalStateException: Trying to set device owner but device is already provisioned.
which, I heard, is caused by the file /data/system/device_owner.xml already being present on the device.
Since the device had just been freshly factory-reset, I suspect that it had come with an app already provisioned by the manufacturer, so I rooted the device. I would rather do it without rooting (since there will be some 70 devices I have to run the procedure on) but for research purposes, it can't be helped.
After rooting the device, I tried to find the device_owner.xml file but it wasn't there. I tried creating one anyway based on this answer, but the app still shows the pinning message and the recent+back buttons still unpinned the app.
So why can't I set the device owner? is there any way around it?
While it's true that I tried dpm provisioning on a newly reset device, #basilisk's comment hinted me at the answer. The device comes loaded with bloatware that provides default accounts. Disabling these apps finally allowed me to provision the device with dpm.

How to make an android mobile only running an application from startup?

Well, today in my workplace i have been given a task. Boss handed me an android mobile, which only runs a application and nothing else. Whenever the mobile starts, it starts the application and users cant nvaigate anywhere from that application. which means the mobile is only dedicated for that application. An ex-employee did this thing.
I need to bring it to normal condition. Then do the same for another application, which is only my application will run in the mobile, as its doing for another app.
How to solve it? Can anyone please help me?
If you do not care about the data stored on that mobile then you should perform the factory reset. This will bring your mobile to the fresh state with only OEM apps installed.
To do it you need to enter the recovery mode. If your device has USB debugging mode enabled then simply connect it to the computer and type adb reboot recovery. If debugging is not enabled then you have to force the recovery mode then you should do a research on the internet how to put your device in recovery mode. For example for Samsung devices you have to turn off the device and then hold Home+VolumeUp+Power buttons.
Once you enter the recovery mode you will see few options. One of them is "wipe data/factory mode" (see example here). Use volume buttons to navigate through options and power button to accept the option (note that touchscreen is not operable in this mode). Remember that this will erase all your data and you will not be able to restore it. No turning back beyond this point.
After the reset you will have no custom apps installed so you can install whatever you want.
If you cannot do the factory reset because you do not want to lose your data then there is other, more difficult option, that requires some Android programming. You can simply write an application that would:
run at startup
get information about installed packages
find the application that has been blocking the device
send an intent that would ask the user if he wants to uninstall the app:
Uri packageURI = Uri.parse("package:"+"some.package.to.remove");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);

perform a task when any application installed on device is opened?

I wish to filter the applications installed on the device so that the person, using that device can't open any app rather than few basic apps... or i wish when he/she opens any application password will be asked......
That somewhat of a more low level task. I guess you will have to either root the device, or build your own System image and install that on your device.
By reading 'Logcat' logs in the background we can detect other applications launch; as working of any lock application.

Categories

Resources