做项目软件时,会遇到客户提出屏蔽禁用下拉状态栏,其实禁用下拉状态栏主要包含两个地方
第一个地方就是解锁后进入到桌面时,在顶部和中部下拉时会将状态栏拉出来显示
第二个地方就是锁屏界面在顶部和中部下拉时会将状态栏拉出来显示
具体屏蔽禁用这两处的下拉状态栏修改如下:
1. 屏蔽禁用解锁后进入到桌面时,在顶部和中部下拉时会将状态栏拉出来显示,修改如下:
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
old mode 100644
new mode 100755
index 96d6ecb..b938044
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -371,11 +371,14 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
// TODO(b/118592525): add multi-display support if needed.
public boolean panelsEnabled() {
- final int disabled1 = getDisabled1(DEFAULT_DISPLAY);
+
+ return false;
+
+ /*final int disabled1 = getDisabled1(DEFAULT_DISPLAY);
final int disabled2 = getDisabled2(DEFAULT_DISPLAY);
return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
&& (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
- && !ONLY_CORE_APPS;
+ && !ONLY_CORE_APPS;*/
}
public void addCallback(Callbacks callbacks) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
old mode 100644
new mode 100755
index 790b2585..2582e4a
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -185,37 +185,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
// TODO: change the method signature to use (boolean inputFocusTransferStarted)
@Override
public void onStatusBarMotionEvent(MotionEvent event) {
- if (!verifyCaller("onStatusBarMotionEvent")) {
- return;
- }
- long token = Binder.clearCallingIdentity();
- try {
- // TODO move this logic to message queue
- mStatusBarOptionalLazy.ifPresent(statusBarLazy -> {
- mHandler.post(()-> {
- StatusBar statusBar = statusBarLazy.get();
- int action = event.getActionMasked();
- if (action == ACTION_DOWN) {
- mInputFocusTransferStarted = true;
- mInputFocusTransferStartY = event.getY();
- mInputFocusTransferStartMillis = event.getEventTime();
- statusBar.onInputFocusTransfer(
- mInputFocusTransferStarted, false /* cancel */,
- 0 /* velocity */);
- }
- if (action == ACTION_UP || action == ACTION_CANCEL) {
- mInputFocusTransferStarted = false;
- statusBar.onInputFocusTransfer(mInputFocusTransferStarted,
- action == ACTION_CANCEL,
- (event.getY() - mInputFocusTransferStartY)
- / (event.getEventTime() - mInputFocusTransferStartMillis));
- }
- event.recycle();
- });
- });
- } finally {
- Binder.restoreCallingIdentity(token);
- }
+
}
@Override
2. 屏蔽禁用锁屏界面在顶部和中部下拉时会将状态栏拉出来显示,修改如下:文章来源:https://www.toymoban.com/news/detail-682179.html
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
old mode 100644
new mode 100755
index a4a5819..89791ff
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -6651,6 +6651,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
/* Only ever called as a consequence of a lockscreen expansion gesture. */
@Override
public boolean onDraggedDown(View startingChild, int dragLengthY) {
+
+ if (mStatusBarState == StatusBarState.KEYGUARD) {
+ return false;
+ }
+
boolean canDragDown = hasActiveNotifications()
|| mKeyguardMediaController.getView().getVisibility() == VISIBLE;
if (mStatusBarState == StatusBarState.KEYGUARD && canDragDown) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
old mode 100644
new mode 100755
index 799e16c..231e1ec
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -130,6 +130,8 @@ public class NotificationPanelViewController extends PanelViewController {
private static final boolean DEBUG = false;
+ private boolean mUnallowedState = true;
+
/**
* Fling expanding QS.
*/
@@ -1674,6 +1676,11 @@ public class NotificationPanelViewController extends PanelViewController {
}
private void setQsExpansion(float height) {
+
+ if(mUnallowedState) {
+ return;
+ }
+
height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight);
mQsFullyExpanded = height == mQsMaxExpansionHeight && mQsMaxExpansionHeight != 0;
if (height > mQsMinExpansionHeight && !mQsExpanded && !mStackScrollerOverscrolling
以上在Android11系统平台亲测有效,下拉状态栏包括解锁后在桌面下拉和在锁屏界面下拉,下拉又包括在顶部下拉和在屏幕中间部位下拉,所以总共有4处修改,思路主要就是屏蔽代码执行达到屏蔽禁用的效果文章来源地址https://www.toymoban.com/news/detail-682179.html
到了这里,关于Android11屏蔽禁用下拉状态栏的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!