MTK平台导航栏按键修改-Android13

一、背景

        MTK平台相对比较少用于台式机研发上面,由于移动终端和平板都有物理按键,所以很少有添加虚拟按键的需求,但是对于一些台式机,可能没有物理的音量键,而且大屏操作时也希望导航栏上能有快捷关机键,因此有了这样的需求。网上其他的方案均存在问题,可以参考此方案快速导入。

二、流程

由于13上默认导航栏不居中,因此首先修改导航栏居中显示,然后在添加按键,涉及修改的文件有

.../android/server/policy/PhoneWindowManager.java  |   5 +++
 .../android/launcher3/taskbar/TaskbarManager.java  |   5 ++-
 .../apps/SystemUI/res/drawable-xxhdpi/ic_power.png | Bin 0 -> 2112 bytes
 .../SystemUI/res/drawable-xxhdpi/ic_volume.png     | Bin 0 -> 1957 bytes
 .../SystemUI/res/drawable-xxxhdpi/ic_power.png     | Bin 0 -> 2112 bytes
 .../SystemUI/res/drawable-xxxhdpi/ic_volume.png    | Bin 0 -> 1957 bytes
 .../packages/apps/SystemUI/res/layout/power.xml    |  28 +++++++++++++++
 .../packages/apps/SystemUI/res/layout/volume.xml   |  27 +++++++++++++++
 .../apps/SystemUI/res/values-sw400dp/config.xml    |   3 ++
 .../apps/SystemUI/res/values-sw600dp/config.xml    |   2 +-
 .../apps/SystemUI/res/values-sw900dp/config.xml    |   2 +-
 .../packages/apps/SystemUI/res/values/dimens.xml   |   2 ++
 .../packages/apps/SystemUI/res/values/strings.xml  |   2 ++
 .../shared/recents/utilities/Utilities.java        |   4 +++
 .../systemui/navigationbar/NavigationBar.java      |  38 ++++++++++++++++++++-
 .../navigationbar/NavigationBarInflaterView.java   |   6 ++++
 .../systemui/navigationbar/NavigationBarView.java  |  25 +++++++++++++-

1.居中显示

diff --git a/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 7433669..fb200e5 100644
--- a/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -52,6 +52,7 @@ import com.android.systemui.unfold.UnfoldTransitionProgressProvider;
 import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
 
 import java.io.PrintWriter;
+import android.os.SystemProperties;
 
 /**
  * Class to manage taskbar lifecycle
@@ -262,7 +263,9 @@ public class TaskbarManager {
 
     private void recreateTaskbar() {
         destroyExistingTaskbar();
-
+        if (SystemProperties.get("persist.sys.taskbar.enable","0").equals("0")){
+            return ;
+        }
         DeviceProfile dp =
                 mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
index 56326e3..88201b4 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
@@ -31,6 +31,7 @@ import android.os.Message;
 import android.util.DisplayMetrics;
 import android.view.Surface;
 import android.view.WindowManager;
+import android.os.SystemProperties;
 
 /* Common code */
 public class Utilities {
@@ -128,6 +129,9 @@ public class Utilities {
     /** @return whether or not {@param context} represents that of a large screen device or not */
     @TargetApi(Build.VERSION_CODES.R)
     public static boolean isTablet(Context context) {
+        if (SystemProperties.get("persist.sys.taskbar.enable","0").equals("0")){
+            return false;
+        }
         final WindowManager windowManager = context.getSystemService(WindowManager.class);
         final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds();

2.首先添加布局文件和资源文件

布局文件:

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/power.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/power.xml
new file mode 100644
index 0000000..bcb177c
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/power.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<com.android.systemui.navigationbar.buttons.KeyButtonView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:systemui="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/power"
+    android:layout_width="@dimen/navigation_key_width"
+    android:layout_height="match_parent"
+    android:layout_weight="0"
+    android:scaleType="center"
+    android:contentDescription="@string/accessibility_power"
+    android:paddingStart="@dimen/navigation_key_padding"
+    android:paddingEnd="@dimen/navigation_key_padding"
+    />
+
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/volume.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/volume.xml
new file mode 100644
index 0000000..ed6c939
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/volume.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<com.android.systemui.navigationbar.buttons.KeyButtonView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:systemui="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/volume"
+    android:layout_width="@dimen/navigation_key_width"
+    android:layout_height="match_parent"
+    android:layout_weight="0"
+    android:scaleType="center"
+    android:contentDescription="@string/accessibility_volume"
+    android:paddingStart="@dimen/navigation_key_padding"
+    android:paddingEnd="@dimen/navigation_key_padding"
+    />

资源文件(根据自己分辨率放到指定路径就行了):

vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable-xxhdpi/ic_power.png

vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable-xxhdpi/ic_volume.png

3.修改导航栏的布局

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw400dp/config.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw400dp/config.xml
new file mode 100644
index 0000000..0cc515c
--- /dev/null
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw400dp/config.xml
@@ -0,0 +1,3 @@
+<resources>
+    <string name="config_navBarLayout" translatable="false">left;poweroff,back,home,recent,volume;right</string>
+</resources>
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw600dp/config.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw600dp/config.xml
index 36cc0ad..ba3a959 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw600dp/config.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw600dp/config.xml
@@ -27,7 +27,7 @@
     <bool name="config_quickSettingsMediaLandscapeCollapsed">false</bool>
 
     <!-- Nav bar button default ordering/layout -->
-    <string name="config_navBarLayout" translatable="false">left;back,home,recent;right</string>
+    <string name="config_navBarLayout" translatable="false">left;power,back,home,recent,volume;right</string>
 
     <!-- orientation of the dead zone when touches have recently occurred elsewhere on screen -->
     <integer name="navigation_bar_deadzone_orientation">0</integer>
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw900dp/config.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw900dp/config.xml
index 221b013..99f2d56 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw900dp/config.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-sw900dp/config.xml
@@ -19,6 +19,6 @@
 <resources>
 
     <!-- Nav bar button default ordering/layout -->
-    <string name="config_navBarLayout" translatable="false">back,home,left;space;right,recent</string>
+    <string name="config_navBarLayout" translatable="false">power,back,home,left;space;right,recent,volume</string>
 
 </resources>
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/dimens.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/dimens.xml
index b6a2815..3b09c06 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/dimens.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/dimens.xml
@@ -49,6 +49,8 @@
     <dimen name="navigation_edge_arrow_min_y">64dp</dimen>
     <!-- The amount by which the arrow is shifted to avoid the finger-->
     <dimen name="navigation_edge_finger_offset">48dp</dimen>
+    <dimen name="navigation_key_width_sw600dp_land">162dp</dimen>
+    <dimen name="navigation_key_padding_sw600dp_land">42dp</dimen>
 
     <!-- Height of notification icons in the status bar -->
     <dimen name="status_bar_icon_size">@*android:dimen/status_bar_icon_size</dimen>

4.定义对应的字符串

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
index e4607b3..b6c2866 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
@@ -2545,4 +2545,6 @@
     =1 {# notification}
     other {# notifications}
     }</string>
+    <string name="accessibility_power">Power</string>
+    <string name="accessibility_volume">Volume</string>
 </resources>

5.源码中添加按键布局,增加按键分发,修改触摸区域

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarInflaterView.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarInflaterView.java
index 59bb227..ed9e3fc 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarInflaterView.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarInflaterView.java
@@ -68,6 +68,8 @@ public class NavigationBarInflaterView extends FrameLayout
     public static final String RIGHT = "right";
     public static final String CONTEXTUAL = "contextual";
     public static final String IME_SWITCHER = "ime_switcher";
+    public static final String POWER = "power";
+    public static final String VOLUME = "volume";
 
     public static final String GRAVITY_SEPARATOR = ";";
     public static final String BUTTON_SEPARATOR = ",";
@@ -387,6 +389,10 @@ public class NavigationBarInflaterView extends FrameLayout
             v = inflater.inflate(R.layout.home_handle, parent, false);
         } else if (IME_SWITCHER.equals(button)) {
             v = inflater.inflate(R.layout.ime_switcher, parent, false);
+        } else if(POWER.equals(button)) {
+            v = inflater.inflate(R.layout.power, parent, false);
+        } else if(VOLUME.equals(button)) {
+            v = inflater.inflate(R.layout.volume, parent, false);
         } else if (button.startsWith(KEY)) {
             String uri = extractImage(button);
             int code = extractKeycode(button);
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
index 3fc9afe..11d9e7f 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
@@ -92,7 +92,7 @@ import java.util.function.Consumer;
 
 /** */
 public class NavigationBarView extends FrameLayout {
-    final static boolean DEBUG = false;
+    final static boolean DEBUG = true;
     final static String TAG = "NavBarView";
 
     final static boolean ALTERNATE_CAR_MODE_UI = false;
@@ -119,6 +119,9 @@ public class NavigationBarView extends FrameLayout {
     private Context mLightContext;
     private int mLightIconColor;
     private int mDarkIconColor;
+    private KeyButtonDrawable mPowerIcon;
+    private KeyButtonDrawable mVolumeIcon;
+
 
     private EdgeBackGestureHandler mEdgeBackGestureHandler;
     private final DeadZone mDeadZone;
@@ -316,6 +319,8 @@ public class NavigationBarView extends FrameLayout {
         mButtonDispatchers.put(R.id.ime_switcher, imeSwitcherButton);
         mButtonDispatchers.put(R.id.accessibility_button, accessibilityButton);
         mButtonDispatchers.put(R.id.menu_container, mContextualButtonGroup);
+        mButtonDispatchers.put(R.id.power, new ButtonDispatcher(R.id.power));
+        mButtonDispatchers.put(R.id.volume, new ButtonDispatcher(R.id.volume));
         mDeadZone = new DeadZone(this);
     }
 
@@ -412,6 +417,14 @@ public class NavigationBarView extends FrameLayout {
         return mButtonDispatchers.get(R.id.accessibility_button);
     }
 
+    public ButtonDispatcher getPowerButton() {
+        return mButtonDispatchers.get(R.id.power);
+    }
+
+    public ButtonDispatcher getVolumeButton() {
+        return mButtonDispatchers.get(R.id.volume);
+    }
+
     public RotationContextButton getRotateSuggestionButton() {
         return (RotationContextButton) mButtonDispatchers.get(R.id.rotate_suggestion);
     }
@@ -456,6 +469,8 @@ public class NavigationBarView extends FrameLayout {
         if (orientationChange || densityChange || dirChange) {
             mBackIcon = getBackDrawable();
         }
+            mPowerIcon = getDrawable(R.drawable.ic_power);
+            mVolumeIcon = getDrawable(R.drawable.ic_volume);
     }
 
     /**
@@ -594,11 +609,15 @@ public class NavigationBarView extends FrameLayout {
         KeyButtonDrawable backIcon = mBackIcon;
         orientBackButton(backIcon);
         KeyButtonDrawable homeIcon = mHomeDefaultIcon;
+        KeyButtonDrawable powerIcon = mPowerIcon;
+        KeyButtonDrawable volumeIcon = mVolumeIcon;
         if (!mUseCarModeUi) {
             orientHomeButton(homeIcon);
         }
         getHomeButton().setImageDrawable(homeIcon);
         getBackButton().setImageDrawable(backIcon);
+        getPowerButton().setImageDrawable(powerIcon);
+        getVolumeButton().setImageDrawable(volumeIcon);
 
         updateRecentsIcon();
 
@@ -652,6 +671,8 @@ public class NavigationBarView extends FrameLayout {
         getHomeButton().setVisibility(disableHome       ? View.INVISIBLE : View.VISIBLE);
         getRecentsButton().setVisibility(disableRecent  ? View.INVISIBLE : View.VISIBLE);
         getHomeHandle().setVisibility(disableHomeHandle ? View.INVISIBLE : View.VISIBLE);
+        getPowerButton().setVisibility(false       ? View.INVISIBLE : View.VISIBLE);
+        getVolumeButton().setVisibility(false       ? View.INVISIBLE : View.VISIBLE);
         notifyActiveTouchRegions();
     }
 
@@ -1122,6 +1143,8 @@ public class NavigationBarView extends FrameLayout {
 
         dumpButton(pw, "back", getBackButton());
         dumpButton(pw, "home", getHomeButton());
+        dumpButton(pw, "volume", getVolumeButton());
+        dumpButton(pw, "power", getPowerButton());
         dumpButton(pw, "handle", getHomeHandle());
         dumpButton(pw, "rcnt", getRecentsButton());
         dumpButton(pw, "rota", getRotateSuggestionButton());
diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/vendor/mediatek/proprietary/packages/apps/Syst
emUI/src/com/android/systemui/navigationbar/NavigationBar.java
index 91b01ef..9634cb0 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
@@ -1787,11 +1787,15 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
         Region region = new Region();
         Map<View, Rect> touchRegionCache = mView.getButtonTouchRegionCache();
         updateButtonLocation(
+                region, touchRegionCache, mView.getPowerButton(), inScreenSpace, useNearestRegion);
+        updateButtonLocation(
                 region, touchRegionCache, mView.getBackButton(), inScreenSpace, useNearestRegion);
         updateButtonLocation(
                 region, touchRegionCache, mView.getHomeButton(), inScreenSpace, useNearestRegion);
         updateButtonLocation(region, touchRegionCache, mView.getRecentsButton(), inScreenSpace,
                 useNearestRegion);
+        updateButtonLocation(
+                region, touchRegionCache, mView.getVolumeButton(), inScreenSpace, useNearestRegion);
         updateButtonLocation(region, touchRegionCache, mView.getImeSwitchButton(), inScreenSpace,
                 useNearestRegion);
         updateButtonLocation(

6.按键发送广播或调用相关服务

注:打叉的地方修改成自己喜欢的名字即可

diff --git a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
index aa38b78..91b01ef 100644
--- a/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
+++ b/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
@@ -158,6 +158,7 @@ import com.android.systemui.util.DeviceConfigProxy;
 import com.android.systemui.util.ViewController;
 import com.android.wm.shell.back.BackAnimation;
 import com.android.wm.shell.pip.Pip;
+import android.media.AudioManager;
 
 import java.io.PrintWriter;
 import java.util.Locale;
@@ -177,7 +178,7 @@ import dagger.Lazy;
 public class NavigationBar extends ViewController<NavigationBarView> implements Callbacks {
 
     public static final String TAG = "NavigationBar";
-    private static final boolean DEBUG = false;
+    private static final boolean DEBUG = true;
     private static final String EXTRA_DISABLE_STATE = "disabled_state";
     private static final String EXTRA_DISABLE2_STATE = "disabled2_state";
     private static final String EXTRA_APPEARANCE = "appearance";
@@ -1260,6 +1261,13 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
         accessibilityButton.setOnLongClickListener(this::onAccessibilityLongClick);
         updateAccessibilityStateFlags();
 
+        ButtonDispatcher powerButton = mView.getPowerButton();
+        powerButton.setOnClickListener(this::powerClick);
+        powerButton.setOnTouchListener(this::powerTouch);
+
+        ButtonDispatcher volumeButton = mView.getVolumeButton();
+        volumeButton.setOnClickListener(this::volumeClick);
+
         ButtonDispatcher imeSwitcherButton = mView.getImeSwitchButton();
         imeSwitcherButton.setOnClickListener(this::onImeSwitcherClick);
 
@@ -1450,6 +1458,30 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
         return false;
     }
 
+    private boolean powerTouch(View v, MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_UP) {
+            Log.i("xxxxx","powerTouch--sendBroadcast");
+            Intent intent=new Intent("com.xxxxx.systemui.power");
+            mContext.sendBroadcast(intent);
+        }
+        return false;
+    }
+
+    private void powerClick(View v) {
+        Log.i("xxxx","powerClick--sendBroadcast");
+        Intent intent=new Intent("com.xxxxx.systemui.power");
+        mContext.sendBroadcast(intent);
+    }
+
+    private void volumeClick(View v) {
+        Log.i("xxxxx","volumeClick--sendBroadcast");
+        AudioManager am = getContext().getSystemService(AudioManager.class);
+        am.adjustSuggestedStreamVolume(
+                AudioManager.ADJUST_SAME,
+                AudioManager.STREAM_MUSIC,
+                AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
+    }
+
     private void onAccessibilityClick(View v) {
         final Display display = v.getDisplay();
         mAccessibilityManager.notifyAccessibilityButtonClicked(

7.监听广播调出响应弹窗

注:打叉的地方修改成自己喜欢的名字即可

diff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 0b61a84..a3d9745 100644
--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -2071,6 +2071,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         filter = new IntentFilter();
         filter.addAction(Intent.ACTION_DREAMING_STARTED);
         filter.addAction(Intent.ACTION_DREAMING_STOPPED);
+        filter.addAction("com.xxxx.systemui.power");
         context.registerReceiver(mDreamReceiver, filter);
 
         // register for multiuser-relevant broadcasts
@@ -4449,6 +4450,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     BroadcastReceiver mDreamReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
+            Log.i("xxxx", "mDreamReceiver--onReceive");
             if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) {
                 if (mKeyguardDelegate != null) {
                     mKeyguardDelegate.onDreamingStarted();
@@ -4457,6 +4459,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 if (mKeyguardDelegate != null) {
                     mKeyguardDelegate.onDreamingStopped();
                 }
+            } else if("com.xxxx.systemui.power".equals(intent.getAction())) {
+                Log.i("xxxxx", "Receive a soft poweroff broadcast.");
+                showGlobalActionsInternal();
             }
         }
     };

三、验证

以上修改完成后,整体编译然后烧录即可实现虚拟按键添加及事件响应

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
制作 Android 13 MTK 平台的 OTA 差分包相对来说比较复杂,需要一定的开发经验和知识。以下是一般的步骤和流程: 1. 准备工作: - 确保你的开发环境已经配置好,并且可以编译和构建 Android 13 MTK 平台的源代码。 - 获取原始系统镜像和目标系统镜像,分别表示当前系统和要升级的目标系统。 2. 执行 AOSP 构建: - 使用 AOSP 源代码构建系统,生成目标系统镜像。可以参考 MTK 平台的开发文档来执行构建命令。 3. 生成差分文件: - 使用 Android 提供的工具 `imgdiff`,生成目标系统镜像与当前系统镜像之间的差分文件。具体使用方法可以参考 Android 官方文档。 4. 打包差分包: - 将生成的差分文件和一些必要的元数据文件(如版本号、设备信息等)打包成 OTA 差分包。可以使用 `build/tools/releasetools` 目录下的工具来完成打包操作。 5. 签名差分包: - 使用 Android 提供的 `signapk` 工具,对生成的差分包进行签名。签名是为了确保差分包的完整性和安全性。 6. 测试和发布: - 在真实设备上测试差分包的安装和升级过程,确保没有问题。 - 将签名后的差分包上传到合适的发布渠道,供用户下载和安装。 需要注意的是,以上步骤只是一个大致的流程,具体的操作和工具可能会因为不同的开发环境和配置而有所不同。建议在进行 OTA 差分包制作之前,先仔细阅读相关的官方文档和开发者指南,并确保你对 Android 平台开发有一定的了解和经验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zjuestcer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值