Skip to content

durka/HallMonitor

Repository files navigation

Hall Monitor

About

This is an Android app that reimplements some of the behaviors specific to the Samsung Galaxy S4, so that they can be used with alternative ROMs, such as CyanogenMod, where the proprietary Samsung components are not available. At this time, these behaviors are:

  1. Support the S View Cover. There is a magnet in the cover, and a hall effect sensor built in to the S4, so that when you close the cover, we can automatically display the lock screen for a few seconds before putting the phone to sleep, and when you open the cover the phone wakes up.

Why use Hall Monitor instead of one of the other apps that locks the screen when you close the cover? As far as I can tell, they all use the proximity sensor to detect when the cover closes. Well, the S4 has a hall effect sensor, which is a much more accurate way to detect when the cover closes, and is what this app uses (but see below).

This app is a "clean room" implementation. I'm not extracting Samsung's binaries from the stock ROM, or anything like that, just attempting to reimplement the functionality that I like.

Screenshots:

Configuration screen (okay, it's the only screen) GIF of opening and closing the cover

Important: The preponderance of the evidence so far indicates that there should be no problem running this app on any Galaxy S4, and even on the S4 mini/mega. However, I have only personally tested it under the following configuration(s):

  • Samsung Galaxy S4 T-Mobile (jfltetmo / SGH-M919), CyanogenMod 10.1.3 (based on Android 4.2.2)
  • Samsung Galaxy S4 T-Mobile (jfltetmo / SGH-M919), CyanogenMod 10.2 (based on Android 4.3)

Others have tested this under the following configuration(s):

  • Samsung Galaxy S4 Sprint (jfltespr / SPH-L720), CyanogenMod 10.2
  • Samsung Galaxy S4 international (jfltexx / GT-I9505), CyanogenMod 10.2
  • [Mostly working] S4 Exynos octacore international (GT-I9500), unofficial CyanogenMod 10.2 and 11
  • [Mostly working] S4 mini international (serranoltexx / GT-I9195), CyanogenMod 10.2
  • S4 mega, CyanogenMod (unknown carrier/version)
  • Note 3 (SM-N9005), CyanogenMod 11

If you test this on something other than the above (including another carrier's S4) and it works, please let me know! You can contact me at [email protected]. If it doesn't work, please file an issue here. But no promises, because I can't really do tech support for devices I don't own.

Installation / Usage

The current release is: 0.4.1 (see changelog)

  • The easiest way to install the latest stable version is through F-Droid, an "app store" for open source. Here is Hall Monitor's entry.
  • You can download bin/HallMonitor-debug.apk from one of the tagged versions, and install it on your phone assuming you have sideloading turned on.
  • You can clone the repository at a tagged version and build from source. It's configured as an Eclipse project, but I haven't even used any external libraries yet, so it "should" be "simple" to build with another system such as Android Studio or ant.

Limitations / Known Issues

  • Little Things
    • The feature that receives phone calls doesn't work all the time. It uses a timer to jump on top of the regular call answering screen, which is a huge hack. I'd like to find a better way.
    • You can accidentally escape from Hall Monitor while the cover is closed by long-pressing the menu button. I managed to disable the back button, but if you have an action set up for long-press-menu (e.g. for me it opens Google Now) then an app cannot override this through normal means. I'd be happy to find some abnormal means, though.

Future Plans

  1. Comment the code more
  2. Remove the above limitations
  3. Enhance the view cover lockscreen:
    • (done) Either modify cLock, or make a new lockscreen widget, that crams more information into the space you can see through the view cover
    • (done) Make the lockscreen, or just a fullscreen activity, come up immediately when you close the cover instead of turning the screen off and back on (this could supersede the previous point)
    • (in progress) More enhancements to the fullscreen activity; see the issues/wiki for a roadmap
  4. Add options to support other S4-specific things:
    • Keep the screen on while the camera can see your eyes
    • Air gestures? I never used them myself and don't know exactly how they work, but maybe people want them?
    • Smart scroll/pause? (see above point)
    • Other cool features that Samsung HASN'T thought of! If you have a good idea, file a feature request or, better yet, a pull request.

Hacking

This should serve as quick guide if you're trying to find your way around my code.

  • All the real functionality is in Functions.java. The various activities and intent receivers forward everything to functions in there, along with whatever references to Contexts or Activities are necessary. I am experimenting this design, as it seems cleaner to not have the logic scattered among all the Android and Java boilerplate.
  • Activities:
  • Intent receivers:
    • BootReceiver: the service needs to be started at boot; this is implemented by BootReceiver.java (though again, that just delegates to a function in Functions.java).
    • DeviceAdminReceiver: the service needs device admin permissions in order to lock the screen, and we can't really start the service until that happens, so we need a receiver for the event. This is implemented in AdminReceiver.java and configured in device_admin.xml.
  • Services:
    • ViewCoverService: the most important file, really, outside of Functions.java, is ViewCoverService.java. This is the service that runs all the time and receives events from the proximity sensor, so it can check the hall effect sensor state, and react to view cover events.

Happy hacking! File an issue or contact me at [email protected] with any questions.

About

clean room Galaxy S4 View Cover driver

Resources

License

Stars

Watchers

Forks

Packages

No packages published