android systemui禁止下拉怎么做
发布网友
发布时间:2022-04-27 10:28
我来回答
共1个回答
热心网友
时间:2023-09-12 20:13
PhoneWindowManager.java里面的修改
[java] view plain copy
--- a/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -2863,7 +2863,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override
public int adjustSystemUiVisibilityLw(int visibility) {
- mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
+ if(Settings.System.getInt(mContext.getContentResolver(),"factorytest.touch.mode",0) == 0){
+ mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
+ }
mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility);
// Reset any bits in mForceClearingStatusBarVisibility that
Acitvity里面使用如下方式:
[java] view plain copy
--- a/huaqin/source/packages/FactoryKitTest/src/com/android/huaqin/factory/TestTouchPanelLine2.java
+++ b/huaqin/source/packages/FactoryKitTest/src/com/android/huaqin/factory/TestTouchPanelLine2.java
@@ -32,6 +32,8 @@ import android.view.WindowManager;
import java.util.ArrayList;
import java.util.List;
+import android.provider.Settings;
+import android.app.StatusBarManager;
public class TestTouchPanelLine2 extends Activity {
private static final String TAG = "TestTouchPanelLine";
@@ -54,6 +56,7 @@ public class TestTouchPanelLine2 extends Activity {
private static final int MSG_TEST_PANEL_NEXT_ITEM = 100;
private static final int MSG_TEST_PANEL_START = 101;
private static final int MSG_TEST_PANEL_STOP = 102;
+ private StatusBarManager mStatusBarManager;
private Handler mInHandler = new Handler() {
@Override
@@ -94,6 +97,12 @@ public class TestTouchPanelLine2 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -141,8 +150,22 @@ public class TestTouchPanelLine2 extends Activity {
.obtainMessage(FactoryTestMessage.MSG_OPEN_UI_OK);
msg.arg1 = (int) ID;
mOutHandler.sendMessage(msg);
+ mStatusBarManager = (StatusBarManager) this.getSystemService(Context.STATUS_BAR_SERVICE);
+ int state= StatusBarManager.DISABLE_EXPAND;
+ state |= StatusBarManager.DISABLE_NOTIFICATION_ICONS;
+ state |= StatusBarManager.DISABLE_SYSTEM_INFO;
+ mStatusBarManager.disable(state);
}
+ @Override
+ protected void onPause() {
+ int state = StatusBarManager.DISABLE_NONE;
+ mStatusBarManager.disable(state);
+ super.onPause();
+ }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// 是否触发按键为back键
以下是从MTK Online 上面找到的解决方案,保留备用。
Google从KK开始增加了状态栏透明以及全屏界面有通知可以下拉状态栏的设计,而这个设计出现的隐患是设置了FULL_SCREEN的界面是无法禁止状态栏下拉的,这样对一些工程测试app可能会造成一定的影响,但是以google默认的设计,应用端无法修改此设计来满足自己的需求。
MTK 内部已经开发提供新的接口来实现全屏界面禁止下拉状态栏,如果贵司的代码还没有这部分逻辑,请参考如下:
1. frameworks\base\core\java\android\view\View.java
[java] view plain copy
public static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 0x00001000;
+ /**
+ * @hide
+ *
+ * NOTE: Flag for {@link #setSystemUiVisibility(int)}: It help user to disable transient
+ * status bar triggered by gesture
+ */
+ public static final int SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED = 0x00002000;
2. frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindowManager.java
[java] view plain copy
// monitor for system gestures
mSystemGestures = new SystemGesturesPointerEventListener(context,
new SystemGesturesPointerEventListener.Callbacks() {
@Override
public void onSwipeFromTop() {
+ if (isGestureIsolated())
+ return;
if (mStatusBar != null) {
requestTransientBars(mStatusBar);
}
}
@Override
public void onSwipeFromBottom() {
+ if (isGestureIsolated())
+ return;
if (mNavigationBar != null && mNavigationBarOnBottom) {
requestTransientBars(mNavigationBar);
}
}
@Override
public void onSwipeFromRight() {
+ if (isGestureIsolated())
+ return;
if (mNavigationBar != null && !mNavigationBarOnBottom) {
requestTransientBars(mNavigationBar);
}
}
@Override
public void onDebug() {
// no-op
}
+ private boolean isGestureIsolated() {
+ WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState;
+ if (win != null && (win.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED) != 0)
+ return true;
+ else
+ return false;
+ }
});
3. 请在修改完framework后,将测试app用setSystemUiVisibility的API加上SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED的flag