Is there a certain way to disable the home key? (related to modding stock apps)
I was just searching for it, and it seems like most people say that it is impossible to disable the home key without making your app an alternate launcher. I'm curious if there is some special way that companies like Samsung are allowed to use to disable it.
For example, I have a Samsung Infuse and when I open the Camera app and press the power button, it locks all of the hardware buttons. The home key, back key, everything. When you press them after they are locked, they don't do anything at all. You can press the power button again to unlock them, and you are free to lock them again later whenever you want.
I'm curious because I'm trying to mod the camera app on my phone to use the power button to take pictures. I've decompiled the app using apk manager and modified Camera.smali to take pictures with the power button, however it is still locking the home key and all the others. I tried searching in there for anything related to locking any buttons, but I couldn't find anything.
Does anyone know how they would be able to lock/disable the home key? Based on what I've found from searching, it's not possible 开发者_StackOverflow中文版to disable it unless you use your app as an alternate launcher, but clearly Samsung(or Google? I'm not sure if this is a Samsung/TouchWiz app or a stock Android one) was able to do it in their Camera app without making the app act as a launcher.
Companies like Samsung modify the stock platform to do all kinds of questionable things. :) Stock Android does not allow applications to disable the home key. Hopefully in whatever modifications the manufacturers do, they only allow built-in apps to disable the home key. It is a significant behavioral and possibly security issue for third party apps to be able to do this.
There is a method that works (sometimes) but it's not 100% reliable so I would not depend on it in production application for anything that is critical unless you can constrain/test the hardware and this may also produce unintended consequences.
For instance it has been reported that on Samsung devices the method results in the device bringing up the lock screen, so please if you try this let me know if you get any kind if similar results, it does nothing, or works :-)
I can say that it works on all of the HTC phones with hard home buttons that I have tested ( about 6 ) with Android 2.2/2.3 have not checked any other OS/Phone combinations.
Anyway in your activity ...
@Override
public void onAttachedToWindow()
{
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
Yeah seems trivial and it is, basically it's just saying hey I am a key guard application so ignore the home key, again different phones behave differently.
LONG WINDED NOTES ABOUT SHOULD vs. CAN
Some users are going to be really p/off if the homekey stops working and they want to use it. The only valid reason I have found to use this is on a data collection app that was built for an agency that did not want an accidental stop (app pushed to the back) when they were using it.
I realize that some people don't think this should be allowed at all from a UX perspective ( I disregard the security concerns, if your a decent malware writer there are better ways to mess with the user without alerting them )
While I tend to agree that it would be really annoying for most applications there are some cases where it's beneficial as stated above. In the end the designer and their users will decide on right and wrong via not paying or never using it again)
Personally I think Google should re-think this whole home key thing, even phone designers (as mentioned by the poster) are finding times when taking control of all of the keys to be beneficial and not "nefarious" or bad UX.
Would it be abused? Sure, so what, market forces will take care of that believe me.
Making it a nasty top level in your face scary permission would also apply the right amount of pressure if Google still felt it was needed.
Ok Rant Off ...
精彩评论