From fc4c8ccc838b61e008a4a83be4b26b05dc3603d0 Mon Sep 17 00:00:00 2001 From: huangcm <null@gmail.com> Date: Sat, 24 Aug 2024 09:06:35 +0000 Subject: [PATCH] feat(test): add factory test app --- android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java | 125 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 125 insertions(+), 0 deletions(-) diff --git a/android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java index 8d37f09..03a4fa9 100644 --- a/android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -232,6 +232,8 @@ import java.io.PrintWriter; import java.util.HashSet; import java.util.List; +import android.widget.Toast; +import android.content.ComponentName; /** * WindowManagerPolicy implementation for the Android phone UI. This @@ -248,6 +250,7 @@ static final boolean DEBUG_SPLASH_SCREEN = false; static final boolean DEBUG_WAKEUP = false; static final boolean SHOW_SPLASH_SCREENS = true; + private static final int MSG_SHOW_TOAST = 88; // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. // No longer recommended for desk docks; @@ -386,6 +389,7 @@ private boolean mHasFeatureWatch; private boolean mHasFeatureLeanback; private boolean mHasFeatureHdmiCec; + private String pwd=""; // Assigned on main thread, accessed on UI thread volatile VrManagerInternal mVrManagerInternal; @@ -731,6 +735,9 @@ break; case MSG_RINGER_TOGGLE_CHORD: handleRingerChordGesture(); + break; + case MSG_SHOW_TOAST: + Toast.makeText(mContext, (String)msg.obj , Toast.LENGTH_SHORT).show(); break; case MSG_MOVE_DISPLAY_TO_TOP: mWindowManagerFuncs.moveDisplayToTop(msg.arg1); @@ -1918,6 +1925,12 @@ filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); context.registerReceiver(mMultiuserReceiver, filter); + filter = new IntentFilter(); + filter.addAction(Intent.ACTION_SCREEN_OFF); + filter.addAction(Intent.ACTION_SCREEN_ON); + filter.addAction(Intent.ACTION_SHUTDOWN); + context.registerReceiver(mScreenReceiver, filter); + mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); mLongPressVibePattern = getLongIntArray(mContext.getResources(), com.android.internal.R.array.config_longPressVibePattern); @@ -2629,6 +2642,104 @@ if (DEBUG_INPUT) { Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" + repeatCount + " keyguardOn=" + keyguardOn + " canceled=" + canceled); + } + + if(down) { + pwd += String.valueOf(keyCode); + if(pwd.contains("3822020")){ // home menu 2down + try { + Intent intent = new Intent(Intent.ACTION_MAIN); + ComponentName cn = new ComponentName("com.oranth.activate","com.oranth.activate.MainActivity"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(cn); + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + pwd = ""; + }else if(pwd.contains("438282")){ //back home 2menu + try { + Intent intent = new Intent(Intent.ACTION_MAIN); + ComponentName cn = new ComponentName("com.oranth.setmac","com.oranth.setmac.MainActivity"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(cn); + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + pwd = ""; + } else if(pwd.contains("348282")){ //home+back+2menu + try { + Intent intent = new Intent(Intent.ACTION_MAIN); + ComponentName cn = new ComponentName("com.oranth.factory","com.oranth.factory.MainActivity"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(cn); + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + pwd = ""; + } else if(pwd.contains("1412151298")){ //758521 + try { + Intent intent = new Intent(Intent.ACTION_MAIN); + ComponentName cn = new ComponentName("com.oranth.factory","com.oranth.factory.MainActivity"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(cn); + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + pwd = ""; + } else if(pwd.contains("1412151299")){ //758522 + try { + Intent intent = new Intent(Intent.ACTION_MAIN); + ComponentName cn = new ComponentName("com.DeviceTest","com.DeviceTest.DeviceTest"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setComponent(cn); + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + pwd = ""; + } else if(pwd.contains("1412151297")){ //758520 + String irConfig = SystemProperties.get("vendor.kickpi.irkey.enable","0"); + if("1".equals(irConfig)) { + SystemProperties.set("vendor.kickpi.irkey.enable","0"); + mHandler.removeMessages(MSG_SHOW_TOAST); + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close IR Key")); + } else { + SystemProperties.set("vendor.kickpi.irkey.enable","1"); + mHandler.removeMessages(MSG_SHOW_TOAST); + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Open IR Key")); + } + pwd = ""; + } else if(pwd.contains("14121512910")){ // 8521 adb switch + String adbConfig = SystemProperties.get("persist.vendor.adb.enable","0"); + if("1".equals(adbConfig)) { + SystemProperties.set("persist.vendor.adb.enable","0"); + mHandler.removeMessages(MSG_SHOW_TOAST); + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close Adb Debug")); + } else { + SystemProperties.set("persist.vendor.adb.enable","1"); + mHandler.removeMessages(MSG_SHOW_TOAST); + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Open Adb Debug")); + SystemProperties.set("vendor.remote.logging.upload","1"); + } + pwd = ""; + } + + if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || + keyCode == KeyEvent.KEYCODE_DPAD_CENTER || + keyCode == KeyEvent.KEYCODE_DPAD_UP) { + pwd = ""; + } + } + + String IRKeyProp = SystemProperties.get("vendor.kickpi.irkey.enable"); + if ("1".equals(IRKeyProp)) { + mHandler.removeMessages(MSG_SHOW_TOAST); + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_TOAST, "Close IR Key")); + return -1; } // If we think we might have a volume down & power key chord on the way @@ -4415,6 +4526,20 @@ } }; + BroadcastReceiver mScreenReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (Intent.ACTION_SCREEN_ON.equals(action)) { + SystemProperties.set("vendor.power.status","1"); + } else if (Intent.ACTION_SCREEN_OFF.equals(action)) { + SystemProperties.set("vendor.power.status","0"); + } else if (Intent.ACTION_SHUTDOWN.equals(action)) { + SystemProperties.set("vendor.power.status","0"); + } + } + }; + // Called on the PowerManager's Notifier thread. @Override public void startedGoingToSleep(int why) { -- Gitblit v1.6.2