Question

I am developing a Policy Manager for Android. Depending on a given set of rules and the current state of the device, it is supposed to restrict (allow/disallow) the user from starting certain applications.

I am thinking it should be a service running in the background, maybe intercepting all attempts to start applications, checking whether it is OK or not, and then starting them if they are allowed to run. It might also start and stop certain applications by itself, if the state of the device indicates this should be done.

Is there a way to do this programmatically? To control which applications are allowed to start at a certain time and which aren't? And also to stop applications that are already running?

In conclusion, is there a way to programmatically "intercept" attempts to start applications, and possibly deny these?

Était-ce utile?

La solution 2

Found a solution to prevent apps from being enabled/visible.

Simply copy your application apk from /data/app to /sdcard/ then uninstall the app, and then copy the apk from /sdcard/ to system/app/ Finally reboot you device. This will give your app system priviligies.

Now you can use the following code to enable/disable your app (making it completely invisible, even from the settings menu):

PackageManager pm=this.getPackageManager(); pm.setApplicationEnabledSetting("com.gueei.applocker",PackageManager.COMPONENT_ENABLED_STATE_DISABLED,0);

Only thing is you have to know the package name of the app you'd like to show/hide. If you don't copy your apk to /system/app/ you will get a permission denial error.

Autres conseils

I found the following open-source project called AppLocker:

http://code.google.com/p/applocker/source/checkout

It works by checking every 100ms if any other non-allowed activity tries to come to the foreground. If it does, then AppLocker quickly starts its own blocking password request activity before the other app's activity has had time to get to the OnCreate() method (depending on how often the foreground activity state is checked of course).

This app, however, seems not to work on Android 4.1 upwards because permission READ_LOGS has been removed. :-(

However, it seems on a rooted device, the permission may be acquired anyway. See this post: READ_LOGS permission on Jelly Bean (api 16)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top