1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Android 8/9高通平台客制化虚拟导航按键隐藏

Android 8/9高通平台客制化虚拟导航按键隐藏

时间:2024-05-14 19:45:52

相关推荐

Android 8/9高通平台客制化虚拟导航按键隐藏

高通平台源代码更改

diff --git a/frameworks/base/packages/SystemUI/res/values/config.xml b/frameworks/base/packages/SystemUI/res/values/config.xml

index 22180dc..7e6c813 100644

--- a/frameworks/base/packages/SystemUI/res/values/config.xml

+++ b/frameworks/base/packages/SystemUI/res/values/config.xml

@@ -381,7 +381,7 @@

</string-array>

<!-- Nav bar button default ordering/layout -->

- <string name="config_navBarLayout" translatable="false">left[.5W],back[1WC];home;recent[1WC],right[.5W]</string>

+ <string name="config_navBarLayout" translatable="false">left[.5W],back[1WC];home,recent;hide[1WC],right[.5W]</string>

<string name="config_navBarLayoutQuickstep" translatable="false">back[1.7WC];home;contextual[1.7WC]</string>

<bool name="quick_settings_show_full_alarm">false</bool>

diff --git a/frameworks/base/packages/SystemUI/res/values/strings.xml b/frameworks/base/packages/SystemUI/res/values/strings.xml

index 79eeaac..bad63a4 100644

--- a/frameworks/base/packages/SystemUI/res/values/strings.xml

+++ b/frameworks/base/packages/SystemUI/res/values/strings.xml

@@ -220,6 +220,7 @@

<string name="accessibility_home">Home</string>

<!-- Content description of the menu button for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->

<string name="accessibility_menu">Menu</string>

+ <string name="accessibility_hide">Hide</string>

<!-- Content description of the accessibility button in the navigation bar (not shown on the screen). [CHAR LIMIT=NONE] -->

<string name="accessibility_accessibility_button">Accessibility</string>

<!-- Content description of the rotate button in the navigation bar (not shown on the screen). [CHAR LIMIT=NONE] -->

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java

index e6f2c33..74c7ada 100644

--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java

+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java

@@ -69,6 +69,7 @@ public class NavigationBarInflaterView extends FrameLayout

public static final String LEFT = "left";

public static final String RIGHT = "right";

public static final String CONTEXTUAL = "contextual";

+ public static final String HIDE = "hide";

public static final String GRAVITY_SEPARATOR = ";";

public static final String BUTTON_SEPARATOR = ",";

@@ -256,7 +257,7 @@ public class NavigationBarInflaterView extends FrameLayout

if (newLayout == null) {

newLayout = getDefaultLayout();

}

- String[] sets = newLayout.split(GRAVITY_SEPARATOR, 3);

+ String[] sets = newLayout.split(GRAVITY_SEPARATOR, 3);

if (sets.length != 3) {

Log.d(TAG, "Invalid layout.");

newLayout = getDefaultLayout();

@@ -269,16 +270,17 @@ public class NavigationBarInflaterView extends FrameLayout

inflateButtons(start, mRot0.findViewById(R.id.ends_group), isRot0Landscape, true);

inflateButtons(start, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, true);

- inflateButtons(center, mRot0.findViewById(R.id.center_group), isRot0Landscape, false);

- inflateButtons(center, mRot90.findViewById(R.id.center_group), !isRot0Landscape, false);

+ inflateButtons(center, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);

+ inflateButtons(center, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);

- addGravitySpacer(mRot0.findViewById(R.id.ends_group));

- addGravitySpacer(mRot90.findViewById(R.id.ends_group));

+ //addGravitySpacer(mRot0.findViewById(R.id.ends_group));

+ //addGravitySpacer(mRot90.findViewById(R.id.ends_group));

inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);

inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);

updateButtonDispatchersCurrentView();

+

}

private void addGravitySpacer(LinearLayout layout) {

@@ -393,7 +395,9 @@ public class NavigationBarInflaterView extends FrameLayout

v = inflater.inflate(R.layout.clipboard, parent, false);

} else if (CONTEXTUAL.equals(button)) {

v = inflater.inflate(R.layout.contextual, parent, false);

- } else if (button.startsWith(KEY)) {

+ }else if (HIDE.equals(button)) {

+ v = inflater.inflate(R.layout.hide, parent, false);

+ } else if (button.startsWith(KEY)) {

String uri = extractImage(button);

int code = extractKeycode(button);

v = inflater.inflate(R.layout.custom_key, parent, false);

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

index 2a1f92f..e7928f5 100644

--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

@@ -124,6 +124,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

private KeyButtonDrawable mBackAltCarModeIcon, mBackAltLandCarModeIcon;

private KeyButtonDrawable mHomeDefaultIcon, mHomeCarModeIcon;

private KeyButtonDrawable mRecentIcon;

+ private KeyButtonDrawable mHideIcon;

private KeyButtonDrawable mDockedIcon;

private KeyButtonDrawable mImeIcon;

private KeyButtonDrawable mMenuIcon;

@@ -215,6 +216,14 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

.showInputMethodPicker(true /* showAuxiliarySubtypes */);

}

};

+

+ private final OnClickListener mHideClickListener = new OnClickListener() {

+ @Override

+ public void onClick(View view) {

+ //

+ }

+ };

+

private class H extends Handler {

public void handleMessage(Message m) {

@@ -291,6 +300,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

mButtonDispatchers.put(R.id.back, new ButtonDispatcher(R.id.back));

mButtonDispatchers.put(R.id.home, new ButtonDispatcher(R.id.home));

mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps));

+ mButtonDispatchers.put(R.id.hide,new ButtonDispatcher(R.id.hide));

mButtonDispatchers.put(R.id.menu, new ButtonDispatcher(R.id.menu));

mButtonDispatchers.put(R.id.ime_switcher, new ButtonDispatcher(R.id.ime_switcher));

mButtonDispatchers.put(R.id.accessibility_button,

@@ -419,6 +429,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

public ButtonDispatcher getImeSwitchButton() {

return mButtonDispatchers.get(R.id.ime_switcher);

}

+

+ public ButtonDispatcher getHideButton() {

+ return mButtonDispatchers.get(R.id.hide);

+ }

public ButtonDispatcher getAccessibilityButton() {

return mButtonDispatchers.get(R.id.accessibility_button);

@@ -485,6 +499,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

|| oldConfig.getLayoutDirection() != newConfig.getLayoutDirection()) {

mBackIcon = getBackDrawable(lightContext, darkContext);

mRecentIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_recent);

+ mHideIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_hide);

mMenuIcon = getDrawable(lightContext, darkContext, R.drawable.ic_sysbar_menu);

mAccessibilityIcon = getDrawable(lightContext, darkContext,

@@ -636,6 +651,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);

getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);

getImeSwitchButton().setImageDrawable(mImeIcon);

+ getHideButton().setImageDrawable(mHideIcon);

// Update menu button, visibility logic in method

setMenuVisibility(mShowMenu, true);

@@ -903,6 +919,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);

getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);

+ getHideButton().setOnClickListener(mHideClickListener);

DockedStackExistsListener.register(mDockedListener);

updateRotatedViews();

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

index 7bdeab0..4fe256f 100644

--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

@@ -525,6 +525,22 @@ public class StatusBar extends SystemUI implements DemoMode,

mScrimController.setWallpaperSupportsAmbientMode(supportsAmbientMode);

}

};

+

+ private BroadcastReceiver mOemHideNavigationReceiver = new BroadcastReceiver() {

+ @Override

+ public void onReceive(Context context, Intent intent) {

+ //int requested = mSystemUiVisibility | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

+ // | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

+ //if (mSystemUiVisibility != requested) {

+ // notifyUiVisibilityChanged(requested);

+ //}

+ if (mNavigationBarView != null) {

+ removeNavigationBar();

+ }else{

+ createNavigationBar();

+ }

+ }

+ };

private Runnable mLaunchTransitionEndRunnable;

protected boolean mLaunchTransitionFadingAway;

@@ -713,6 +729,9 @@ public class StatusBar extends SystemUI implements DemoMode,

IntentFilter wallpaperChangedFilter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);

mContext.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter);

mWallpaperChangedReceiver.onReceive(mContext, null);

+

+ IntentFilter oemIntentFilter = new IntentFilter("com.oem.hide_navigation");

+ mContext.registerReceiver(mOemHideNavigationReceiver, oemIntentFilter);

mLockscreenUserManager.setUpWithPresenter(this, mEntryManager);

mCommandQueue.disable(switches[0], switches[6], false /* animate */);

@@ -1075,6 +1094,13 @@ public class StatusBar extends SystemUI implements DemoMode,

mNavigationBar.setCurrentSysuiVisibility(mSystemUiVisibility);

});

}

+

+ protected void removeNavigationBar() {

+ if (mNavigationBarView != null) {

+ mWindowManager.removeViewImmediate(mNavigationBarView);

+ mNavigationBarView = null;

+ }

+ }

/**

* Returns the {@link android.view.View.OnTouchListener} that will be invoked when the

diff --git a/frameworks/base/packages/SystemUI/tests/Android.mk b/frameworks/base/packages/SystemUI/tests/Android.mk

deleted file mode 100644

index 6868688..0000000

--- a/frameworks/base/packages/SystemUI/tests/Android.mk

+++ /dev/null

@@ -1,127 +0,0 @@

-# Copyright (C) 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

-#

-# /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.

-

-LOCAL_PATH := $(call my-dir)

-include $(CLEAR_VARS)

-

-LOCAL_USE_AAPT2 := true

-LOCAL_MODULE_TAGS := tests

-

-LOCAL_JACK_FLAGS := --multi-dex native

-LOCAL_DX_FLAGS := --multi-dex

-

-LOCAL_PROTOC_OPTIMIZE_TYPE := nano

-LOCAL_PROTOC_FLAGS := -I$(LOCAL_PATH)/..

-LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors

-

-LOCAL_PACKAGE_NAME := SystemUITests

-LOCAL_PRIVATE_PLATFORM_APIS := true

-LOCAL_COMPATIBILITY_SUITE := device-tests

-

-LOCAL_SRC_FILES := $(call all-java-files-under, src) \

- $(call all-Iaidl-files-under, src) \

- $(call all-java-files-under, ../src)

-

-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \

- frameworks/base/packages/SystemUI/res \

- frameworks/base/packages/SystemUI/res-keyguard \

-

-LOCAL_STATIC_ANDROID_LIBRARIES := \

- SystemUIPluginLib \

- SystemUISharedLib \

- android-support-car \

- android-support-v4 \

- android-support-v7-recyclerview \

- android-support-v7-preference \

- android-support-v7-appcompat \

- android-support-v7-mediarouter \

- android-support-v7-palette \

- android-support-v14-preference \

- android-support-v17-leanback \

- android-slices-core \

- android-slices-view \

- android-slices-builders \

- android-arch-core-runtime \

- android-arch-lifecycle-extensions \

-

-LOCAL_STATIC_JAVA_LIBRARIES := \

- metrics-helper-lib \

- android-support-test \

- mockito-target-inline-minus-junit4 \

- SystemUI-proto \

- SystemUI-tags \

- testables \

- truth-prebuilt \

-

-LOCAL_MULTILIB := both

-

-LOCAL_JNI_SHARED_LIBRARIES := \

- libdexmakerjvmtiagent \

- libmultiplejvmtiagentsinterferenceagent

-

-

-LOCAL_JAVA_LIBRARIES := \

- android.test.runner \

- telephony-common \

- android.test.base \

- android.car \

- ims-common

-

-LOCAL_AAPT_FLAGS := --extra-packages com.android.systemui:com.android.keyguard

-

-# sign this with platform cert, so this test is allowed to inject key events into

-# UI it doesn't own. This is necessary to allow screenshots to be taken

-LOCAL_CERTIFICATE := platform

-

-# Provide jack a list of classes to exclude from code coverage.

-# This is needed because the SystemUITests compile SystemUI source directly, rather than using

-# LOCAL_INSTRUMENTATION_FOR := SystemUI.

-#

-# We want to exclude the test classes from code coverage measurements, but they share the same

-# package as the rest of SystemUI so they can't be easily filtered by package name.

-#

-# Generate a comma separated list of patterns based on the test source files under src/

-# SystemUI classes are in ../src/ so they won't be excluded.

-# Example:

-# Input files: src/com/android/systemui/Test.java src/com/android/systemui/AnotherTest.java

-# Generated exclude list: com.android.systemui.Test*,com.android.systemui.AnotherTest*

-

-# Filter all src files under src/ to just java files

-local_java_files := $(filter %.java,$(call all-java-files-under, src))

-# Transform java file names into full class names.

-# This only works if the class name matches the file name and the directory structure

-# matches the package.

-local_classes := $(subst /,.,$(patsubst src/%.java,%,$(local_java_files)))

-local_comma := ,

-local_empty :=

-local_space := $(local_empty) $(local_empty)

-# Convert class name list to jacoco exclude list

-# This appends a * to all classes and replace the space separators with commas.

-jacoco_exclude := $(subst $(space),$(comma),$(patsubst %,%*,$(local_classes)))

-

-LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.systemui.*

-LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := com.android.systemui.tests.*,$(jacoco_exclude)

-

-include frameworks/base/packages/SettingsLib/common.mk

-

-ifeq ($(EXCLUDE_SYSTEMUI_TESTS),)

- include $(BUILD_PACKAGE)

-endif

-

-# Reset variables

-local_java_files :=

-local_classes :=

-local_comma :=

-local_space :=

-jacoco_exclude :=

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 a58c2c6..cc6f4dc 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

@@ -2244,9 +2244,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {

}

@Override

public void onSwipeFromBottom() {

- if (mNavigationBar != null && mNavigationBarPosition == NAV_BAR_BOTTOM) {

- requestTransientBars(mNavigationBar);

- }

+ if (mNavigationBar == null && mNavigationBarPosition == NAV_BAR_BOTTOM) {

+ //requestTransientBars(mNavigationBar);

+ Intent oemIntent = new Intent("com.oem.hide_navigation");

+ oemIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

+ oemIntent.setPackage("com.android.systemui");

+mContext.sendOrderedBroadcastAsUser(oemIntent, UserHandle.CURRENT_OR_SELF, null, null, null, Activity.RESULT_OK, null, null);

+}

}

@Override

public void onSwipeFromRight() {

@@ -3710,6 +3714,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {

return -1;

}

}

+

+ if (keyCode == KeyEvent.KEYCODE_F3) {

+ if(down){

+ Intent oemIntent = new Intent("com.oem.hide_navigation");

+ oemIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

+ oemIntent.setPackage("com.android.systemui");

+ mContext.sendOrderedBroadcastAsUser(oemIntent, UserHandle.CURRENT_OR_SELF, null, null, null, Activity.RESULT_OK, null, null);

+ }

+ }

if(keyCode == KeyEvent.KEYCODE_F11 || keyCode == KeyEvent.KEYCODE_F12){

删除/frameworks/base/packages/SystemUI/tests/Android.mk

编译指令:mmm frameworks/base/packages/SystemUI/

参考

/cuckoochun/article/details/84109895

/kuaiguixs/article/details/78291695

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。