NOTE: THIS APPLICATION USES AT LEAST ACCELEROMETER AND GRAVITY SENSORS.
Also, it uses the DevicePolicyAdmin permission in order to lock the screen. You must grant the app permission to use the functionality of this app. It is required for a "hard" screen lock.
This application uses sensors to automatically lock the phone based on certain scenarios like a phone entering a pocket or bag. I built this as a semester-long project in an Operating Systems class at University of Memphis in Fall 2013. It took me about a week and a half to come up with the idea for this application and get it approved by my professor.
Below are some of the things that I said in my proposal.
Problem addressed: I am attempting to address the problem in Android OS where unanticipated key presses can happen if one does not lock their phone before putting their phone in their pocket or bag. Android OS assumes that you are still using the phone and does not go into lock mode until sleep mode is activated. For example, if you have sleep mode set to enable after 1 minute of inactivity, then your phone will stay in your pocket/bag open to key presses for 1 minute. Simply setting the sleep mode to a lower time interval may not be a convenient solution to solve this problem because when using the phone, one might have to constantly "wake" the phone up if they are doing things like long e-book or internet reading which easily qualify as inactivity according to the phone. If this application were implemented, it would add new functionality to the Android OS relying on certain available sensors.
Related Work: In other Android applications, setting buttons or timers performs automatic screen locking, but this application is novel in that uses multiple sensors to determine if a screen lock is necessary. There are also similar apps that use proximity sensors to detect if a phone cover has been placed on the device. They are similar in that they would use many of the same sensors as my application. Unfortunately, there is not much open source code dealing with these kinds of issues that I can reference I believe.
I am strongly considering making this application open source, but it depends on developer/user interest.
Note: Because the Android system designers don't want applications to lock your phone whenever they want, this application must have your permission to lock the phone. The application should ask you for permission when you check "on." Also, the classifier is more accurate if you have proximity sensor, so it works best with phones. You must have at least the gravity and accelerometer sensors in order for this application to work.
Usage: Set the switch to "on" if you want to start the service and "off" if you want to stop it. Note that it will stay "on" until you switch to "off" because it is made to run even without the AutoScreenLock running in the background.
The UI is pretty simple because the application's purpose is system-level and does only one thing. The algorithm is more important than the UI in this case.
Please review the application. Feedback will improve me as a developer.
Keywords: automatic, screen, lock, automatic screen lock, sensor, sensor programming, system design