当前位置: 首页 > >

android 11.0 增加控制状态栏和导航栏的接口

发布时间:

?


增加控制状态栏和导航栏的接口,代码如下


?


?


?


?


.../statusbar/NavigationBarController.java | 6 +-
.../phone/NavigationBarFragment.java | 9 +-
.../statusbar/phone/PhoneStatusBarView.java | 7 +-
.../systemui/statusbar/phone/StatusBar.java | 31 +++-
packages/apps/Settings/AndroidManifest.xml | 61 ++++++-
.../ShellSettingsBroadcastReceiver.java | 163 ++++++++++++++++++
6 files changed, 262 insertions(+), 15 deletions(-)
mode change 100644 => 100755 frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
mode change 100644 => 100755 frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
mode change 100644 => 100755 frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
mode change 100644 => 100755 frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
create mode 100755 packages/apps/Settings/src/com/android/settings/ShellSettingsBroadcastReceiver.java

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
old mode 100644
new mode 100755
index 8c24c540e7..17339243da
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
@@ -155,7 +155,7 @@ public class NavigationBarController implements Callbacks {
navBar.setAutoHideController(autoHideController);
navBar.restoreAppearanceAndTransientState();
mNavigationBars.append(displayId, navBar);
-
+ mDisplayId = displayId;
if (result != null) {
navBar.setImeWindowStatus(display.getDisplayId(), result.mImeToken,
result.mImeWindowVis, result.mImeBackDisposition,
@@ -163,6 +163,10 @@ public class NavigationBarController implements Callbacks {
}
});
}
+ private int mDisplayId;
+ public void removeNavigationBarView(){
+ removeNavigationBar(mDisplayId);
+ }

private void removeNavigationBar(int displayId) {
NavigationBarFragment navBar = mNavigationBars.get(displayId);
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
old mode 100644
new mode 100755
index 27daf8615a..ec10f7e438
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -320,9 +320,10 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
buttonDispatcher = mNavigationBarView.getHomeHandle();
}
if (buttonDispatcher != null) {
- buttonDispatcher.setVisibility(
- (forceVisible || alpha > 0) ? View.VISIBLE : View.INVISIBLE);
- buttonDispatcher.setAlpha(forceVisible ? 1f : alpha, animate);
+ // buttonDispatcher.setVisibility(
+ // (forceVisible || alpha > 0) ? View.VISIBLE : View.INVISIBLE);
+ // buttonDispatcher.setAlpha(forceVisible ? 1f : alpha, animate);
+ buttonDispatcher.setAlpha(alpha, animate);
}
}

@@ -971,7 +972,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
}

- private void notifyNavigationBarScreenOn() {
+ public void notifyNavigationBarScreenOn() {
mNavigationBarView.updateNavButtonIcons();
}

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
old mode 100644
new mode 100755
index 7c41bcd09b..97dcb8925b
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.util.leak.RotationUtils;

import java.util.Objects;
+import android.provider.Settings;

public class PhoneStatusBarView extends PanelBar {
private static final String TAG = "PhoneStatusBarView";
@@ -221,7 +222,11 @@ public class PhoneStatusBarView extends PanelBar {
}
}

- return barConsumedEvent || super.onTouchEvent(event);
+ int status = Settings.System.getInt(mContext.getContentResolver(), "PANEL_BAR_STATUS", 1);
+ boolean isEnable = (status ==1);//wed112 add
+ return isEnable ? barConsumedEvent || super.onTouchEvent(event) : isEnable;
+
+// return barConsumedEvent || super.onTouchEvent(event);
}

@Override
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
old mode 100644
new mode 100755
index 0c88d06cc9..8b08cb732e
--- 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
@@ -265,6 +265,9 @@ public class StatusBar extends SystemUI implements DemoMode,

public static final boolean DEBUG_WINDOW_STATE = false;

+ private static final String OP_BUTTON = "cc.intent.systemui.SHOW_NAVIGATION_BUTTON";//wed112 add status bar
+ private static final String SHOW_NAVIGATION = "com.chengwei.NavBar_ENABLE";
+ private static final String HIDE_NAVIGATION = "com.chengwei.NavBar_DISABLED";
// additional instrumentation for testing purposes; intended to be left on during development
public static final boolean CHATTY = DEBUG;

@@ -394,6 +397,7 @@ public class StatusBar extends SystemUI implements DemoMode,

// settings
private QSPanel mQSPanel;
+ RegisterStatusBarResult result = null;

KeyguardIndicationController mKeyguardIndicationController;

@@ -853,7 +857,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// Connect in to the status bar manager service
mCommandQueue.addCallback(this);

- RegisterStatusBarResult result = null;
+ // RegisterStatusBarResult result = null;
try {
result = mBarService.registerStatusBar(mCommandQueue);
} catch (RemoteException ex) {
@@ -1086,8 +1090,16 @@ public class StatusBar extends SystemUI implements DemoMode,
mHeadsUpManager.addListener(mVisualStabilityManager);
mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager);
mNotificationLogger.setHeadsUpManager(mHeadsUpManager);
-
- createNavigationBar(result);
+ // createNavigationBar(result);
+ try {
+ boolean cwnvb ="0".equals(SystemProperties.get("persist.sys.nvbshow")) ;
+ if (DEBUG) Log.v(TAG, "cwnvb=" + cwnvb);
+ if (cwnvb) {
+ createNavigationBar(result);
+ }
+ } catch (Exception ex) {
+ // no window manager? good luck with that
+ }

if (ENABLE_LOCKSCREEN_WALLPAPER && mWallpaperSupported) {
mLockscreenWallpaper = mLockscreenWallpaperLazy.get();
@@ -1273,6 +1285,8 @@ public class StatusBar extends SystemUI implements DemoMode,
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG);
+ filter.addAction(SHOW_NAVIGATION);//wed112 add status bar
+ filter.addAction(HIDE_NAVIGATION);//wed112 add status bar
mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, null, UserHandle.ALL);
}

@@ -2771,6 +2785,17 @@ public class StatusBar extends SystemUI implements DemoMode,
else if (DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG.equals(action)) {
mQSPanel.showDeviceMonitoringDialog();
}
+ else if (HIDE_NAVIGATION.equals(action)) {
+ NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
+ if (mNavigationBarView == null) return;
+ mNavigationBarController.removeNavigationBarView();
+ }
+ else if (SHOW_NAVIGATION.equals(action)) {
+ Log.e("StatusBar", "SHOW_NAVIGATION : " + action);
+ NavigationBarView mNavigationBarView = mNavigationBarController.getDefaultNavigationBarView();
+ if (mNavigationBarView != null) return;
+ createNavigationBar(result);
+ }
}
};

diff --git a/packages/apps/Settings/AndroidManifest.xml b/packages/apps/Settings/AndroidManifest.xml
index 0bae141537..17fddeb137 100755
--- a/packages/apps/Settings/AndroidManifest.xml
+++ b/packages/apps/Settings/AndroidManifest.xml
@@ -1918,7 +1918,61 @@
android:theme="@style/GlifV3Theme.Light"
android:exported="true"
android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
+
+
+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+


+
+
+

+
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+

+

android:exported="true"
@@ -2169,12 +2223,7 @@
android:value="com.android.settings.TestingSettings" />


-
-
-
-
-

-

+



diff --git a/packages/apps/Settings/src/com/android/settings/ShellSettingsBroadcastReceiver.java b/packages/apps/Settings/src/com/android/settings/ShellSettingsBroadcastReceiver.java
new file mode 100755
index 0000000000..e5ef03efc7
--- /dev/null
+++ b/packages/apps/Settings/src/com/android/settings/ShellSettingsBroadcastReceiver.java
@@ -0,0 +1,163 @@
+package com.android.settings;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+
+import android.provider.Settings.Global;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import java.lang.reflect.Method;
+import android.provider.Settings;
+import android.provider.Settings.Secure;
+import android.os.SystemProperties;
+import android.bluetooth.BluetoothAdapter;
+
+
+public class ShellSettingsBroadcastReceiver extends BroadcastReceiver {
+
+ private static final String DATA_ENABLE = "com.chengwei.DATA_ENABLE";
+ private static final String DATA_DISABLE = "com.chengwei.DATA_DISABLE";
+ private static final String GPS_ENABLE = "com.chengwei.GPS_ENABLE";
+ private static final String GPS_DISABLE = "com.chengwei.GPS_DISABLE" ;
+ private static final String BT_ENABLE = "com.chengwei.BT_ENABLE" ;
+ private static final String BT_DISABLE = "com.chengwei.BT_DISABLE" ;
+ private static final String SHOW_NAVIGATION = "com.chengwei.NavBar_ENABLE";
+ private static final String HIDE_NAVIGATION = "com.chengwei.NavBar_DISABLED";
+
+ private static final String TAG = "ShellSettingsBroadcastReceiver" ;
+ private Context mContext;
+ private TelephonyManager mTelephonyManager;
+ private BluetoothAdapter mBluetoothAdapter;
+ public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+ public ShellSettingsBroadcastReceiver() {
+ }
+ public ShellSettingsBroadcastReceiver(Context context) {
+ mContext =context;
+ }
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mContext =context;
+ mTelephonyManager = TelephonyManager.from(context);
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ Log.e("ShellSettingsBroadcastReceiver","232action: "+intent.getAction());
+ if (intent.getAction().equals(DATA_ENABLE)) {
+ // String dataabel = execByRuntime("svc data enable");
+ SystemProperties.set("persist.sys.dataable","0");
+ setMobileDataEnabled(true);
+
+
+ }else if(intent.getAction().equals(DATA_DISABLE)){
+ // String datadisable = execByRuntime("svc data disable");
+ // Log.e("ShellSettingsBroadcastReceiver","datadisable: "+datadisable);
+
+ setMobileDataEnabled(false);
+ SystemProperties.set("persist.sys.dataable","1");
+ }else if(intent.getAction().equals(GPS_ENABLE)){
+ // String gpsabel = execByRuntime("settings put secure location_providers_allowed +gps");
+ // Log.e("ShellSettingsBroadcastReceiver","gpsabel: "+gpsabel);
+ Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
+
+ }else if(intent.getAction().equals(GPS_DISABLE)){
+ // String gpsdisale = execByRuntime("settings put secure location_providers_allowed -gps");
+ Log.e("ShellSettingsBroadcastReceiver","gpsdisale: ");
+
+
+ Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_OFF);
+
+
+ }else if(intent.getAction().equals(BT_ENABLE)){
+
+ mBluetoothAdapter.enable();
+
+ SystemProperties.set("persist.sys.blueth","0");
+ }else if(intent.getAction().equals(BT_DISABLE)){
+
+ mBluetoothAdapter.disable();
+ SystemProperties.set("persist.sys.blueth","1");
+ }else if(intent.getAction().equals(HIDE_NAVIGATION)){
+ Log.e("ShellSettingsBroadcastReceiver","HIDE_NAVIGATION: ");
+
+ SystemProperties.set("persist.sys.nvbshow","1");
+ }else if(intent.getAction().equals(SHOW_NAVIGATION)){
+ Log.e("ShellSettingsBroadcastReceiver","SHOW_NAVIGATION: ");
+
+ SystemProperties.set("persist.sys.nvbshow","0");
+ }
+ }
+
+
+
+ public void setMobileDataEnabled(boolean enabled) {
+ Log.d(TAG, "setMobileDataEnabled: enabled=" + enabled);
+ try {
+ mTelephonyManager.setDataEnabled(enabled);
+ }catch (Exception e){
+ e.printStackTrace();
+ Log.w("ssssett","setDataEnabled exception");
+ }
+ }
+
+
+
+
+
+
+
+ /**
+ * ?ц?shell ?戒护锛??戒护涓??蹇??甯?adb shell
+ * @param cmd
+ * @return Sting ?戒护?ц??ㄦ??跺?杈???????+*/
+
+public static String execByRuntime(String cmd) {
+ Process process = null;
+ BufferedReader bufferedReader = null;
+ InputStreamReader inputStreamReader = null;
+ try {
+ process = Runtime.getRuntime().exec(cmd);
+ inputStreamReader = new InputStreamReader(process.getInputStream());
+ bufferedReader = new BufferedReader(inputStreamReader);
+
+ int read;
+ char[] buffer = new char[4096];
+ StringBuilder output = new StringBuilder();
+ while ((read = bufferedReader.read(buffer)) > 0) {
+ output.append(buffer, 0, read);
+ }
+ return output.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ if (null != inputStreamReader) {
+ try {
+ inputStreamReader.close();
+ } catch (Throwable t) {
+
+ }
+ }
+ if (null != bufferedReader) {
+ try {
+ bufferedReader.close();
+ } catch (Throwable t) {
+
+ }
+ }
+ if (null != process) {
+ try {
+ process.destroy();
+ } catch (Throwable t) {
+
+ }
+ }
+ }
+ }
+}
--
2.17.1

?



友情链接: