Android 一键唤醒应用
最近收到客户需求,需要设备实现一键唤醒应用功能,本次以录音机为例,一键唤醒应用功能具体修改参照如下:
/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
...
// Handle special keys.
switch (keyCode) {
+ case KeyEvent.KEYCODE: {//uKEYCODE
+
+ String uPackageName = "com.android.soundrecorder";
+ String uClassName = "com.android.soundrecorder.SoundRecorder";
+
+ KeyguardManager mKeyguardManager = (KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE);
+ boolean flag = mKeyguardManager.inKeyguardRestrictedInputMode();
+ if(down){
+ if(uPackageName != null && uClassName != null && !flag){
+ Intent intent = new Intent();
+ intent.setClassName(uPackageName,uClassName);
+ if("com.android.soundrecorder".equals(uPackageName))
+ mContext.startActivity(intent);
+ }
+ }
+ break;
+ }
重新编译验证,修改生效,设备已实现一键唤醒应用功能