Where are Android screen lock classes and preferences stored? - android

I want to write a simple convenience app that allows me to have two locking modes on my phone. By default the phone would just go to the slide lock after a minute or two, but after a longer time or if I activate my app, it should engage a more stringent lock, such as the face unlocking. Basically when I have the phone on me, anything but the slide lock is overkill.
To do this I would have to read/write the preferences for the screen lock or find a list of available locking/unlocking mechanisms so I can select and invoke one of them. Does anybody know where this information can be found/is stored?
I expected the preference keys to be found in the (System.Secure class), but could not immediately find anything related except the LOCK_PATTERN_ENABLED setting, which would not be enough.
I tried searching for references to the FaceDetector class, but none are returned in my Eclipse.
The Device Administration API Sample looks like it might give some leads if I could look at the source code. Unfortunately the page omits the detail of which of the several folders of each of the sample directories for the approx. 10 API levels supporting I need to download and look in, as far as I can see.

You can change lock modes in your app only if it is a device admin. These API are located in class DevicePolicyManager and methods setMaximumTimeToLock() and lockNow() etc. It is only accessible only if your app is a device admin. If you are interested in crating a custom lockscreen app, you can try this.

Related

Android: How to make device run only one app?

I have an customer project where I have to make single task android device. Customer isn't able to escape the application which my company have developed. Also customer isn't able to start any other application and our application is started when the device is booted. Overall all the customer is able to do with the device is run our application.
Is there any other way to make this work than rooting the device, disabling all system buttons and making our application the launcher. I have something like 400 devices for this purpose so rooting all those would cost lot of time.
I also read Google's tutorial about COSU devices but found it very confucing https://developer.android.com/work/cosu.html#testing-plan
Androids own screen pinning is not good enough because customer can escape the app. Some may suggest to use some kiosk application like SureLock but my company's goal is to find clear solution for this without using any third party apps. Also running our app via some kiosk application is not our goal.
I found some posts on the Stack Overflow with similar question, but not the answer I'm looking for.
If someone has some tips for this question I would be very grateful.
Single purpose devices built on top of Android can get difficult to implement. There are a few different options, but each have trade-offs.
As you mentioned, rooting devices will functionally get you what you want - however it will be time consuming with hundreds of devices to root, difficult to maintain, and you will (potentially) introduce security issues to your devices and app.
Another option is using Google's Lock Task Mode for COSU devices[1]. The link there has a nice graphic showing the features of lock task mode:
1 app pinned to the home screen
only apps white-listed by the DPC (device policy controller) can be locked
Home and Recent buttons hidden
exit by calling stopLockTask()
There are some downsides to using Google's solution for this. First Google recommends creating (and therefor maintaining) an entirely separate DPC app to run as a device owner and set policies[2]. You'll also be dependent on Google Play to manage application updates and be required to have Play accounts associated with each device which "are used to identify a single device that is not tied to a single user for simplified, per-device app distribution rules in COSU-style scenarios"[3]. To automatically get your DPC app on devices your "DPC must be publicly availble on Google Play, and the end user can install the DPC from the device setup wizard by entering the DPC-specific identifier."[3] You'll also need to upload the user application to Google Play[4], which may be an issue for some who don't want their apps on Play. Going this route gives you features you need, but can be complicated and also ties you and your customer pretty tightly with Google/Play services and their workflow.
You can also look at enterprise mobile deployment platforms like Mason[5]. In your case, you can create a custom Android OS in a few minutes with your app locked in kiosk mode (+ other features like disable camera/sms, remove apps and hide settings, etc.) and then deploy it to all of your devices remotely. Mason also supports OS and app updates controlled by you if your requirements change.
DISCLAIMER: I work for Mason
[1] https://developer.android.com/work/cosu.html
[2] https://developer.android.com/work/cosu.html#create-dpc
[3] https://developers.google.com/android/work/requirements/cosu
[4] https://developers.google.com/android/work/play/emm-api/samples#push_install_an_app_on_a_device
[5] https://bymason.com/
I went to the same problem before. I spent at least 3 days doing research. I tried to find many solutions but I found zero.
How I solve is
1. Up To JellyBean
- Use System Alert Dialog (And make it transparent and small size like 2 * 2 And display in some corner(User can't see it)). User can't press home button If there is system Alert dialog
2. After JellyBean, This method doesn't work. The user can press the home button even though there is System Alert Dialog.
so what I did is, start the service on stop and start the same activity again and again(within sec). So user can't see any difference.Don't forget to make activity as single task so that even though you start same activity from service, again and again, new activity will not create (So Ugly way )
- You can simple make screen full screen. make sure in kiosk mode try to check if the screen is in full-screen mode. if not make it full-screen mode(its not hard to do)
- other way is to make launcher app but when ever you pressed home button it always asked to choose launcher app. if user mistakenly choose default/ other launcher app, this solution doesnt work
Good luck
Make your application as a launcher application by defining in manifest file.
After that go to setting of your mobile device and change default launcher application to your application.

Make an app show up as an Android lock screen?

I haven't found a definite answer to this yet. Lots of apps let you build/install custom lock screens without root, etc. It's just like installing an app. I found this in the dev guide: http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED
I assume that while this is running it would run just like any other app. But how would I "release" it to let the user get to their home screen? And do I need to handle things like incoming phone calls?
You can't (at least if you follow the rules) replace the secure lock screen. You can have a lock-screen like activity that will show up when the phone is locked. Use FLAG_SHOW_WHEN_LOCKED, but notice that your activity cannot be transparent - i.e. it cannot be a dialog.

Android non-root lock replacement

Let me begin by saying that, yes, I know that the stock Android lock screen can not be programatically replaced without rooting.
Now that that's over with, I want to make an app that contains a custom 'lock' mechanism. There are apps out there that emulate this functionality, namely LockGo. This allows a user to view information from widgets on a 'lock screen' and emulates the slide-to-unlock functionality (or whack-a-mole if the user wants to install that plugin).
Does anyone know what mechanism or Android API functionality they may have used to do this? Is it as simple as hooking into the power button to launch an activity, such as in the link below?
How to hook into the Power button in Android?
Any insight to this would be appreciated.
I've found out while researching this that, while there is currently no way to replace the stock security or keyguard lock (which I knew), it is possible to show an Activity on top of the lock using the following code in the setup for that Activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
This can be used with any logic needed to create a faux lock to show screens on top of the system lock(s), though the lock will still be in tact and the user will need to enter the lock to get into the device.

Android lock screen

Is there a way to display text on lock screen? Like the information about unread SMS messages or like that Music Player on lock screen with Play/Pause buttons.
Thanks
Yes and no. Their is no public API to create or modify the lock screen. Whoever built the OS version on your device created your lock screen. Some of the manufacturers or carriers have added additional things to the lock screen. I've seen some that tie in to the music app, HTC sense has a somewhat customizable lock screen. So if you were willing to create your own rom and flash it to your device you could write your own lockscreen. Short of that the best you can do is write an app that the system thinks is an alternate home screen that has some kind of lock mechanism before the actual home is displayed. Then you set your device not to use a lock screen(so that it won't show both) This is not a great solution however, there are bound to be more ways to access the device if you use a "fake" lock screen like that so if security is an issue I wouldn't mess with it at all.
You might be able to find one of these "fake" lock screens on the market that suites your needs or you could create one that is exactly what you want. You could also search around on XDA for a rom that works with your device, 3rd party roms may be more likely to have the features your looking for on the lock screen.
If you end up making a pretend lock screen by using the home replacement method I strongly suggest you do not distribute something like that on the market. It is insecure and the users are unlikely to realize that there is a difference between that and a legit lock screen. Plus there is no guarantee that this method doesn't get broken at some point.

how to keep track of which applications used most in android phone

HI ,
I need to keep track of installed applications which are used most and least in android device... can anyone help me how to do this programmatically in android...??
My question some thing like , I need to capture the event/Intent which will/may happen when the apllication is launched every time...(like BOOT_COMPLETED will be brodcasted when device booted).
This does not seem possible (unless the launcher/home screen or applications cooperate, e.g. through instrumentation: but that would be strange in production code!). See also this related question.
Edited to add: indiscriminate capture of application launch intents is not AFAIK permitted. Were Android to add such functionality, the security implications would be significant (particularly if interception or modification were allowed!). What you are describing could be (partially) achieved by replacing the home screen.
Some degree of usage information is collected already - from the launcher go to settings - about phone - battery use.
I think this resets every time you go on a charger, and don't know if its visible to ordinary apps.

Categories

Resources