huangcm
2024-08-24 fc4c8ccc838b61e008a4a83be4b26b05dc3603d0
android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
....@@ -232,6 +232,8 @@
232232 import java.io.PrintWriter;
233233 import java.util.HashSet;
234234 import java.util.List;
235
+import android.widget.Toast;
236
+import android.content.ComponentName;
235237
236238 /**
237239 * WindowManagerPolicy implementation for the Android phone UI. This
....@@ -248,6 +250,7 @@
248250 static final boolean DEBUG_SPLASH_SCREEN = false;
249251 static final boolean DEBUG_WAKEUP = false;
250252 static final boolean SHOW_SPLASH_SCREENS = true;
253
+ private static final int MSG_SHOW_TOAST = 88;
251254
252255 // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key.
253256 // No longer recommended for desk docks;
....@@ -386,6 +389,7 @@
386389 private boolean mHasFeatureWatch;
387390 private boolean mHasFeatureLeanback;
388391 private boolean mHasFeatureHdmiCec;
392
+ private String pwd="";
389393
390394 // Assigned on main thread, accessed on UI thread
391395 volatile VrManagerInternal mVrManagerInternal;
....@@ -731,6 +735,9 @@
731735 break;
732736 case MSG_RINGER_TOGGLE_CHORD:
733737 handleRingerChordGesture();
738
+ break;
739
+ case MSG_SHOW_TOAST:
740
+ Toast.makeText(mContext, (String)msg.obj , Toast.LENGTH_SHORT).show();
734741 break;
735742 case MSG_MOVE_DISPLAY_TO_TOP:
736743 mWindowManagerFuncs.moveDisplayToTop(msg.arg1);
....@@ -1918,6 +1925,12 @@
19181925 filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
19191926 context.registerReceiver(mMultiuserReceiver, filter);
19201927
1928
+ filter = new IntentFilter();
1929
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
1930
+ filter.addAction(Intent.ACTION_SCREEN_ON);
1931
+ filter.addAction(Intent.ACTION_SHUTDOWN);
1932
+ context.registerReceiver(mScreenReceiver, filter);
1933
+
19211934 mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
19221935 mLongPressVibePattern = getLongIntArray(mContext.getResources(),
19231936 com.android.internal.R.array.config_longPressVibePattern);
....@@ -2629,6 +2642,104 @@
26292642 if (DEBUG_INPUT) {
26302643 Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount="
26312644 + repeatCount + " keyguardOn=" + keyguardOn + " canceled=" + canceled);
2645
+ }
2646
+
2647
+ if(down) {
2648
+ pwd += String.valueOf(keyCode);
2649
+ if(pwd.contains("3822020")){ // home menu 2down
2650
+ try {
2651
+ Intent intent = new Intent(Intent.ACTION_MAIN);
2652
+ ComponentName cn = new ComponentName("com.oranth.activate","com.oranth.activate.MainActivity");
2653
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2654
+ intent.setComponent(cn);
2655
+ mContext.startActivity(intent);
2656
+ } catch (Exception e) {
2657
+ e.printStackTrace();
2658
+ }
2659
+ pwd = "";
2660
+ }else if(pwd.contains("438282")){ //back home 2menu
2661
+ try {
2662
+ Intent intent = new Intent(Intent.ACTION_MAIN);
2663
+ ComponentName cn = new ComponentName("com.oranth.setmac","com.oranth.setmac.MainActivity");
2664
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2665
+ intent.setComponent(cn);
2666
+ mContext.startActivity(intent);
2667
+ } catch (Exception e) {
2668
+ e.printStackTrace();
2669
+ }
2670
+ pwd = "";
2671
+ } else if(pwd.contains("348282")){ //home+back+2menu
2672
+ try {
2673
+ Intent intent = new Intent(Intent.ACTION_MAIN);
2674
+ ComponentName cn = new ComponentName("com.oranth.factory","com.oranth.factory.MainActivity");
2675
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2676
+ intent.setComponent(cn);
2677
+ mContext.startActivity(intent);
2678
+ } catch (Exception e) {
2679
+ e.printStackTrace();
2680
+ }
2681
+ pwd = "";
2682
+ } else if(pwd.contains("1412151298")){ //758521
2683
+ try {
2684
+ Intent intent = new Intent(Intent.ACTION_MAIN);
2685
+ ComponentName cn = new ComponentName("com.oranth.factory","com.oranth.factory.MainActivity");
2686
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2687
+ intent.setComponent(cn);
2688
+ mContext.startActivity(intent);
2689
+ } catch (Exception e) {
2690
+ e.printStackTrace();
2691
+ }
2692
+ pwd = "";
2693
+ } else if(pwd.contains("1412151299")){ //758522
2694
+ try {
2695
+ Intent intent = new Intent(Intent.ACTION_MAIN);
2696
+ ComponentName cn = new ComponentName("com.DeviceTest","com.DeviceTest.DeviceTest");
2697
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2698
+ intent.setComponent(cn);
2699
+ mContext.startActivity(intent);
2700
+ } catch (Exception e) {
2701
+ e.printStackTrace();
2702
+ }
2703
+ pwd = "";
2704
+ } else if(pwd.contains("1412151297")){ //758520
2705
+ String irConfig = SystemProperties.get("vendor.kickpi.irkey.enable","0");
2706
+ if("1".equals(irConfig)) {
2707
+ SystemProperties.set("vendor.kickpi.irkey.enable","0");
2708
+ mHandler.removeMessages(MSG_SHOW_TOAST);
2709
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close IR Key"));
2710
+ } else {
2711
+ SystemProperties.set("vendor.kickpi.irkey.enable","1");
2712
+ mHandler.removeMessages(MSG_SHOW_TOAST);
2713
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Open IR Key"));
2714
+ }
2715
+ pwd = "";
2716
+ } else if(pwd.contains("14121512910")){ // 8521 adb switch
2717
+ String adbConfig = SystemProperties.get("persist.vendor.adb.enable","0");
2718
+ if("1".equals(adbConfig)) {
2719
+ SystemProperties.set("persist.vendor.adb.enable","0");
2720
+ mHandler.removeMessages(MSG_SHOW_TOAST);
2721
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close Adb Debug"));
2722
+ } else {
2723
+ SystemProperties.set("persist.vendor.adb.enable","1");
2724
+ mHandler.removeMessages(MSG_SHOW_TOAST);
2725
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Open Adb Debug"));
2726
+ SystemProperties.set("vendor.remote.logging.upload","1");
2727
+ }
2728
+ pwd = "";
2729
+ }
2730
+
2731
+ if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
2732
+ keyCode == KeyEvent.KEYCODE_DPAD_CENTER ||
2733
+ keyCode == KeyEvent.KEYCODE_DPAD_UP) {
2734
+ pwd = "";
2735
+ }
2736
+ }
2737
+
2738
+ String IRKeyProp = SystemProperties.get("vendor.kickpi.irkey.enable");
2739
+ if ("1".equals(IRKeyProp)) {
2740
+ mHandler.removeMessages(MSG_SHOW_TOAST);
2741
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close IR Key"));
2742
+ return -1;
26322743 }
26332744
26342745 // If we think we might have a volume down & power key chord on the way
....@@ -4415,6 +4526,20 @@
44154526 }
44164527 };
44174528
4529
+ BroadcastReceiver mScreenReceiver = new BroadcastReceiver() {
4530
+ @Override
4531
+ public void onReceive(Context context, Intent intent) {
4532
+ String action = intent.getAction();
4533
+ if (Intent.ACTION_SCREEN_ON.equals(action)) {
4534
+ SystemProperties.set("vendor.power.status","1");
4535
+ } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
4536
+ SystemProperties.set("vendor.power.status","0");
4537
+ } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
4538
+ SystemProperties.set("vendor.power.status","0");
4539
+ }
4540
+ }
4541
+ };
4542
+
44184543 // Called on the PowerManager's Notifier thread.
44194544 @Override
44204545 public void startedGoingToSleep(int why) {