赞
踩
在设置中增加状态栏和导航栏得显示隐藏控制
1.vendor/mediatek/proprietary/packages/apps/MtkSettings/设置中修改
- vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml下增加
-
- + <!-- navigation bar control -->
- + <string name="switch_navigation_title">Switch_BarView</string>
- + <string name="switch_navigation_summary">Display/Hide BarView</string>
-
- vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/display_settings.xml 下增加
-
- + <SwitchPreference
- + android:key="switch_navagation"
- + android:title="@string/switch_navigation_title"
- + android:summary="@string/switch_navigation_summary" />
- vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/DisplaySettings.java 增加
- +import com.android.settings.display.SwitchNavagationPreferenceController;
- +controllers.add(new SwitchNavagationPreferenceController(context));
- vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/SwitchNavagationPreferenceController.java
- +/*
- + * Copyright (C) 2017 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.
- + */
- +package com.android.settings.display;
- +
- +import android.content.Context;
- +import android.provider.Settings;
- +import android.os.SystemProperties;
- +import android.os.RemoteException;
- +import androidx.preference.Preference;
- +import androidx.preference.SwitchPreference;
- +import android.content.BroadcastReceiver;
- +import android.content.Intent;
- +import android.util.Log;
- +import com.android.settings.R;
- +import com.android.settings.core.PreferenceControllerMixin;
- +import com.android.settingslib.core.AbstractPreferenceController;
- +
- +public class SwitchNavagationPreferenceController extends AbstractPreferenceController
- + implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
- +
- + private static final String TAG = "SwitchNavagationPreferenceController";
- +
- + private static final String KEY_SWITCH_NAVAGATION = "switch_navagation";
- +
- + public SwitchNavagationPreferenceController(Context context) {
- + super(context);
- + }
- +
- + @Override
- + public boolean isAvailable() {
- + return true;
- + }
- +
- + @Override
- + public String getPreferenceKey() {
- + return KEY_SWITCH_NAVAGATION;
- + }
- +
- + @Override
- + public boolean onPreferenceChange(Preference preference, Object newValue) {
- + boolean value = (Boolean) newValue;
- + //Settings.Secure.putInt(mContext.getContentResolver(),
- + // KEY_SWITCH_NAVAGATION, value ? 1 : 0);
- + sendToReceiver(value);
- + return true;
- + }
- +
- + @Override
- + public void updateState(Preference preference) {
- + int value = 0;
- + //int value = Settings.Secure.getInt(mContext.getContentResolver(),
- + // KEY_SWITCH_NAVAGATION, 1);
- + try{
- + String nvbshow = SystemProperties.get("persist.sys.show_bar","1");
- + if(nvbshow.equals("1")){
- + value = 1;
- + }else{
- + value = 0;
- + }
- + } catch (Exception ex) {
- + Log.d(TAG,"tes get nvbshow failed");
- + }
- + ((SwitchPreference) preference).setChecked(value != 0);
- + }
- +
- + private void sendToReceiver(boolean enable) {
- + Intent intent;
- + if(enable){
- + intent = new Intent("com.tes.show_bar");
- + }else{
- + intent = new Intent("com.tes.hide_bar");
- + }
- + mContext.sendBroadcast(intent);
- + }
- +
- +}
2.vendor/mediatek/proprietary/packages/apps/SystemUI/ 中修改
- vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java 增加方法
-
- + //add by max.chen 20220602 start
- + public void removeTesNavigationBar(){
- + //removeNavigationBar(DEFAULT_DISPLAY);
- + Display[] displays = mDisplayManager.getDisplays();
- + for (Display display : displays) {
- + removeNavigationBar(display.getDisplayId());
- + }
- + }
- + //add by max.chen 202206-2 end
- vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java中增加
-
- + //add by max.chen 20220602 start
- + private static final String TES_SHOW_BAR = "com.tes.show_bar";
- + private static final String TES_HIDE_BAR = "com.tes.hide_bar";
- + //add by max.chen 20220602 end
-
-
-
- +
- + //add by max.chen 20220602 start
- + //createNavigationBar(result);
- + try{
- + //persist.sys.show_bar 1:display 0:hide
- + String nvbshow = SystemProperties.get("persist.sys.show_bar","1");
- + if(nvbshow.equals("1")){
- + mStatusBarWindowController.setForceStatusBarVisible(true);
- + mPhoneStatusBarWindow.setVisibility(View.VISIBLE);
- + Log.d(TAG,"display navigation bar");
- + createNavigationBar(result);
- +
- + }else{
- + Log.d(TAG,"hide navigation bar");
- + mStatusBarWindowController.setForceStatusBarVisible(false);
- + mPhoneStatusBarWindow.setVisibility(View.GONE);
- +
- + }
- + } catch (Exception ex) {
- + Log.d(TAG,"tes set PhoneStatusBarWindow failed");
- + }
-
- - createNavigationBar(result);
-
-
- 广播中增加
- + filter.addAction(TES_SHOW_BAR);
- + filter.addAction(TES_HIDE_BAR);
-
- private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver()方法中增加
-
- + RegisterStatusBarResult result = null;
- + try {
- + result = mBarService.registerStatusBar(mCommandQueue);
- + } catch (RemoteException ex) {
- + ex.rethrowFromSystemServer();
- + }
-
-
-
- + //add by max.chen 20220602 start
- + else if(TES_SHOW_BAR.equals(action)) {
- + NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
- + if(mNavigationBarView != null) return;
- + mStatusBarWindowController.setForceStatusBarVisible(true);
- + mPhoneStatusBarWindow.setVisibility(View.VISIBLE);
- + createNavigationBar(result);
- + SystemProperties.set("persist.sys.show_bar","1");
- + }
- + else if(TES_HIDE_BAR.equals(action)) {
- + NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
- + if(mNavigationBarView == null) return;
- + mNavigationBarController.removeTesNavigationBar();
- + SystemProperties.set("persist.sys.show_bar","0");
- + mStatusBarWindowController.setForceStatusBarVisible(false);
- + mPhoneStatusBarWindow.setVisibility(View.GONE);
- + }
- + //add by max.chen 20220602 end
3.增加platform_app对System_property的设置权限
device/mediatek/sepolicy/basic/plat_private/platform_app.te
+get_prop(platform_app, system_prop)
+set_prop(platform_app, system_prop)
- device/mediatek/sepolicy/basic/plat_private/platform_app.te 增加
- +get_prop(platform_app, system_prop)
- +set_prop(platform_app, system_prop)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。