我们的app跑在RK3399Pro上面,是放在一个公共场合使用,所以把底部的 返回,HOME,MENU键都隐藏掉,并且上部导航栏下拉功能也要取消。
代码我是参考Firefly的代码写的。
实现了一下功能
frameworks层添加三个功能
1.导航栏添加关机功能.
2.导航栏支持屏幕横竖屏切换功能.
3.导航栏支持动态隐藏和显示导航栏,永久关闭导航栏在framework层提供借口供外部使用
不多说,直接上代码
frameworks/base/core/java/android/content/Intent.java
diff --git a/frameworks/base/core/java/android/content/Intent.java b/frameworks/base/core/java/android/content/Intent.java
index 6fd333a0c9..1dc8da6746 100755
--- a/frameworks/base/core/java/android/content/Intent.java
+++ b/frameworks/base/core/java/android/content/Intent.java
@@ -2079,6 +2079,31 @@ public class Intent implements Parcelable, Cloneable {
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
+
+ /****/
+ /**firefly_modify_songjf Broadcast Action:Status bar hidden
+ * @hide
+ */
+ public static final String ACTION_HIDE_BAR = "action.HIDE_STATUSBAR";
+ /****/
+ /**firefly_modify_songjf Broadcast Action:Status bar show
+ * @hide
+ */
+ public static final String ACTION_SHOW_BAR = "action.SHOW_STATUSBAR";
+
+ /****/
+ /**firefly_modify_songjf Broadcast Action:Status bar show
+ * @hide
+ */
+ public static final String ACTION_ALWAYS_HIDE_BAR_CHANGE = "action.ALWAYS_HIDE_STATUSBAR_CHENAGE";
+
+
+ /****/
+ /**firefly_modify_songjf Broadcast Action:poweroff
+ * @hide
+ */
+ public static final String ACTION_SYSTEMUI_FIREFLY_POWEROFF = "action.SYSTEMUI_FIREFLY_POWEROFF";
+
/**
* Broadcast Action: Trigger the download and eventual installation
* of a package.
frameworks/base/core/java/android/provider/Settings.java
diff --git a/frameworks/base/core/java/android/provider/Settings.java b/frameworks/base/core/java/android/provider/Settings.java
index d5a9d09ce4..a4fbd2064f 100755
--- a/frameworks/base/core/java/android/provider/Settings.java
+++ b/frameworks/base/core/java/android/provider/Settings.java
@@ -3627,6 +3627,23 @@ public final class Settings {
*/
public static final String SCREENSHOT_BUTTON_SHOW = "screenshot_button_show";
+ /**
+ *hidebar button wether display
+ * @hide
+ */
+ public static final String HIDEBAR_BUTTON_SHOW = "hidebar_button_show";
+
+ /**
+ *hide status bar
+ * @hide
+ */
+ public static final String ALWAYS_HIDE_BAR="always_hide_bar";
+
+ /**
+ * if enabled while show rotation in SystenUI and Settings-DisplaySettings
+ * @hide
+ */
+ public static final String ENABLE_ROTATION_BY_USER = "enable_rotation_by_user";
/**
* Whether the phone vibrates when it is ringing due to an incoming call. This will
* be used by Phone and Setting apps; it shouldn't affect other apps.
frameworks/base/core/java/com/android/internal/statusbar/IStatusBar.aidl
diff --git a/frameworks/base/core/java/com/android/internal/statusbar/IStatusBar.aidl b/frameworks/base/core/java/com/android/internal/statusbar/IStatusBar.aidl
index bab0306aaf..8da31c5df1 100644
--- a/frameworks/base/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/frameworks/base/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -55,6 +55,10 @@ oneway interface IStatusBar
boolean showImeSwitcher);
void setWindowState(int window, int state);
+
+ //firefly_modify_songjf, add bar interface
+ void addBar();
+
void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleRecentApps();
frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl
diff --git a/frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 82eb1abcba..4f59192186 100644
--- a/frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/frameworks/base/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -73,6 +73,9 @@ interface IStatusBarService
void shutdown();
void reboot(boolean safeMode);
+ //firefly_modify_songjf, add bar interface
+ void addBar();
+
void addTile(in ComponentName tile);
void remTile(in ComponentName tile);
void clickTile(in ComponentName tile);
frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
diff --git a/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
new file mode 100644
index 0000000000..53da8c515b
--- /dev/null
+++ b/frameworks/base/packages/SettingsProvider/res/values/custom_defaults.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- should show the hidebar button default -->
+ <bool name="def_hidebar_button_show">true</bool>
+ <!-- always hide statusbar -->
+ <bool name="def_always_hide_bar">false</bool>
+
+ <!--if true while show rotation in SystenUI and Settings-DisplaySettings -->
+ <bool name="def_enable_rotation_by_user">true</bool>
+</resources>
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index d8f3daf1d4..858babef54 100644
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2339,6 +2339,16 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadIntegerSetting(stmt, Settings.System.SCREENSHOT_BUTTON_SHOW,
R.integer.def_screenshot_button_show);
+ loadBooleanSetting(stmt, Settings.System.HIDEBAR_BUTTON_SHOW,
+ R.bool.def_hidebar_button_show);
+
+ loadBooleanSetting(stmt, Settings.System.ALWAYS_HIDE_BAR,
+ R.bool.def_always_hide_bar);
+
+
+ loadBooleanSetting(stmt, Settings.System.ENABLE_ROTATION_BY_USER,
+ R.bool.def_enable_rotation_by_user);
+
/*
* IMPORTANT: Do not add any more upgrade steps here as the global,
* secure, and system settings are no longer stored in a database
frameworks/base/packages/SystemUI/res/layout/hide_bar.xml
diff --git a/frameworks/base/packages/SystemUI/res/layout/hide_bar.xml b/frameworks/base/packages/SystemUI/res/layout/hide_bar.xml
new file mode 100644
index 0000000000..1b2fe27d9e
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/layout/hide_bar.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.android.systemui.statusbar.policy.KeyButtonView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:systemui="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/hide_bar"
+ android:layout_width="@dimen/navigation_key_width"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ systemui:keyCode="-1"
+ android:scaleType="center"
+ android:contentDescription="@string/accessibility_home"
+ android:paddingStart="@dimen/navigation_key_padding"
+ android:paddingEnd="@dimen/navigation_key_padding"
+ />
frameworks/base/packages/SystemUI/res/layout/poweroff.xml
diff --git a/frameworks/base/packages/SystemUI/res/layout/poweroff.xml b/frameworks/base/packages/SystemUI/res/layout/poweroff.xml
new file mode 100644
index 0000000000..487b563103
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/layout/poweroff.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.android.systemui.statusbar.policy.KeyButtonView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:systemui="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/poweroff"
+ android:layout_width="@dimen/navigation_key_width"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ systemui:keyCode="-1"
+ android:scaleType="center"
+ android:contentDescription="@string/accessibility_home"
+ android:paddingStart="@dimen/navigation_key_padding"
+ android:paddingEnd="@dimen/navigation_key_padding"
+ />
\ No newline at end of file
frameworks/base/packages/SystemUI/res/layout/rotation.xml
diff --git a/frameworks/base/packages/SystemUI/res/layout/rotation.xml b/frameworks/base/packages/SystemUI/res/layout/rotation.xml
new file mode 100644
index 0000000000..20ab401782
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/layout/rotation.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.android.systemui.statusbar.policy.KeyButtonView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:systemui="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/rotation"
+ android:layout_width="@dimen/navigation_key_width"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ systemui:keyCode="-2"
+ android:scaleType="center"
+ android:contentDescription="@string/accessibility_home"
+ android:paddingStart="@dimen/navigation_key_padding"
+ android:paddingEnd="@dimen/navigation_key_padding"
+ />
\ No newline at end of file
frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml
diff --git a/frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml b/frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml
index d5c4303003..07ea9ba760 100644
--- a/frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml
+++ b/frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml
@@ -34,7 +34,7 @@
<bool name="config_keyguardUserSwitcher">true</bool>
<!-- Nav bar button default ordering/layout -->
- <string name="config_navBarLayout" translatable="false">left;volume_sub,back,home,recent,volume_add,screenshot;right</string>
+ <string name="config_navBarLayout" translatable="false">left;poweroff,hide_bar,volume_sub,back,home,recent,volume_add,screenshot,rotation;right</string>
<!-- Animation duration when using long press on recents to dock -->
<integer name="long_press_dock_anim_duration">290</integer>
frameworks/base/packages/SystemUI/res/values-zh-rCN/custom_strings.xml
diff --git a/frameworks/base/packages/SystemUI/res/values-zh-rCN/custom_strings.xml b/frameworks/base/packages/SystemUI/res/values-zh-rCN/custom_strings.xml
new file mode 100644
index 0000000000..d2d323ef24
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/values-zh-rCN/custom_strings.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!--firefly_modify_songjf,add add/remove bar button-->
+ <string name="hidebar_msg">"系统栏已经被隐藏\n您可以在屏幕下边缘拖拉再次显示它。" </string>
+ <!--<string name="hidebar_msg">"系统栏已经被隐藏\n您可以在[系统设置 > 显示]里边设置再次显示它。" </string>-->
+
+ <string name="recents_menu_hint">菜单键更多选项</string>
+ </resources>
\ No newline at end of file
frameworks/base/packages/SystemUI/res/values-zh-rHK/custom_strings.xml
diff --git a/frameworks/base/packages/SystemUI/res/values-zh-rHK/custom_strings.xml b/frameworks/base/packages/SystemUI/res/values-zh-rHK/custom_strings.xml
new file mode 100644
index 0000000000..6850f153b3
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/values-zh-rHK/custom_strings.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!--firefly_modify_songjf,add add/remove bar button-->
+ <string name="hidebar_msg">"系統欄已經被隱藏\n您可以在荧幕下邊緣拖拉再次顯示它。" </string>
+ <!--<string name="hidebar_msg">"系統欄已經被隱藏\n您可以在[系統設置>顯示]裡邊設定再次顯示它。" </string>-->
+
+ <string name="recents_menu_hint">選單鍵更多選項</string>
+ </resources>s
\ No newline at end of file
frameworks/base/packages/SystemUI/res/values/config.xml
diff --git a/frameworks/base/packages/SystemUI/res/values/config.xml b/frameworks/base/packages/SystemUI/res/values/config.xml
index 8511fed05c..94eb8a676b 100644
--- a/frameworks/base/packages/SystemUI/res/values/config.xml
+++ b/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -107,12 +107,12 @@
<!-- The default tiles to display in QuickSettings -->
<string name="quick_settings_tiles_default" translatable="false">
- wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast
+ wifi,bt,dnd,flashlight,rotation,battery,cell,airplane,cast,screenshot
</string>
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
<string name="quick_settings_tiles_stock" translatable="false">
- wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,work,cast,night
+ wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,work,cast,screenshot,night
</string>
<!-- The tiles to display in QuickSettings -->
@@ -320,7 +320,7 @@
<string name="config_systemUIFactoryComponent" translatable="false">com.android.systemui.SystemUIFactory</string>
<!-- Nav bar button default ordering/layout -->
- <string name="config_navBarLayout" translatable="false">left;volume_sub,back,home,recent,volume_add,screenshot;right</string>
+ <string name="config_navBarLayout" translatable="false">left;poweroff,hide_bar,volume_sub,back,home,recent,volume_add,screenshot,rotation;right</string>
<bool name="quick_settings_show_full_alarm">false</bool>
frameworks/base/packages/SystemUI/res/values/custom_strings.xml
diff --git a/frameworks/base/packages/SystemUI/res/values/custom_strings.xml b/frameworks/base/packages/SystemUI/res/values/custom_strings.xml
new file mode 100644
index 0000000000..3c3fdefe10
--- /dev/null
+++ b/frameworks/base/packages/SystemUI/res/values/custom_strings.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!--firefly_modify_songjf,add add/remove bar button-->
+ <string name="hidebar_msg">"System Bar has hidden\nyou can swipe from the bottom of screen to show it again." </string>
+ <!--<string name="hidebar_msg">"System Bar has hidden \ you can show it again from the [Settings > Display]. " </string>-->
+
+ <string name="quick_settings_screenshot">Screenshot</string>
+
+ <string name="recents_menu_hint">Press Menu Edit</string>
+ </resources>s
\ No newline at end of file
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 6349275037..59e738a375 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -83,6 +83,9 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_SHOW_SHUTDOWN_UI = 36 << MSG_SHIFT;
private static final int MSG_SET_TOP_APP_HIDES_STATUS_BAR = 37 << MSG_SHIFT;
+ /**firefly_modify_songjf, add bar interface**/
+ private static final int MSG_ADD_BAR = 38 << MSG_SHIFT;
+
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
@@ -142,6 +145,9 @@ public class CommandQueue extends IStatusBar.Stub {
default void handleSystemKey(int arg1) { }
default void handleShowGlobalActionsMenu() { }
default void handleShowShutdownUi(boolean isReboot, String reason) { }
+
+ /**firefly_modify_songjf, add bar interface **/
+ default void addBar(){ }
}
@VisibleForTesting
@@ -343,6 +349,14 @@ public class CommandQueue extends IStatusBar.Stub {
}
}
+ /**firefly_modify_songjf, add bar interface **/
+ public void addBar() {
+ synchronized (mLock) {
+ mHandler.removeMessages(MSG_ADD_BAR);
+ mHandler.obtainMessage(MSG_ADD_BAR, 0, 0, null).sendToTarget();
+ }
+ }
+
public void showScreenPinningRequest(int taskId) {
synchronized (mLock) {
mHand
最后效果:
由于写文章的时候板子不在身边,图片就找张网上的图片,效果是一样的。
在第三方APP里面控制状态栏。
/****/
/** Broadcast Action:Status bar show
*/
public static final String ACTION_ALWAYS_HIDE_BAR_CHANGE = "action.ALWAYS_HIDE_STATUSBAR_CHENAGE";
public static final String CNBOT_ACTION_ALWAYS_HIDE = "cnbot_always_hide_bar";
/**
* 系统的状态栏控制
* @param context
* @param hide 是否隐藏
*/
public static void changeBarHideStatus(Context context , boolean hide){
if (context == null){
return;
}
Intent i = new Intent(ACTION_ALWAYS_HIDE_BAR_CHANGE);
i.putExtra(CNBOT_ACTION_ALWAYS_HIDE,hide?1:0);
context.sendBroadcast(i);
}