1、禁止systemUI下拉状态栏和通知栏的核心代码部分
framework/base/packages/apps/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
/framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/notification/NotificationStackScrollLayout.java
2、禁止systemUI下拉状态栏和通知栏,考虑需要在锁屏状态下,和未锁屏状态下
2.1 没有锁屏状态下通过
KeyguardViewMediator.java来在adjustStatusBarLocked()中通过设置StatusBarManager的flag
属性来设置禁用下拉状态栏,然后在开机以后就禁用下拉状态栏达到禁用的目的
framework/base/packages/apps/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
private void handleShow(Bundle options) {
Trace.beginSection("KeyguardViewMediator#handleShow");
final int currentUser = KeyguardUpdateMonitor.getCurrentUser();
if (mLockPatternUtils.isSecure(currentUser)) {
mLockPatternUtils.getDevicePolicyManager().reportKeyguardSecured(currentUser);
}
synchronized (KeyguardViewMediator.this) {
if (!mSystemReady) {
if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready.");
return;
} else {
if (DEBUG) Log.d(TAG, "handleShow");
}
mHiding = false;
mWakeAndUnlocking = false;
setShowingLocked(true);
mKeyguardViewControllerLazy.get().show(options);
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
adjustStatusBarLocked();
userActivity();
mUpdateMonitor.setKeyguardGoingAway(false);
mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false);
mShowKeyguardWakeLock.release();
}
private void adjustStatusBarLocked(boolean forceHideHomeRecentsButtons,
boolean forceClearFlags) {
if (mStatusBarManager == null) {
mStatusBarManager = (StatusBarManager)
mContext.getSystemService(Context.STATUS_BAR_SERVICE);
}
if (mStatusBarManager == null) {
Log.w(TAG, "Could not get status bar manager");
} else {
// Disable aspects of the system/status/navigation bars that must not be re-enabled by
// windows that appear on top, ever
int flags = StatusBarManager.DISABLE_NONE;
// TODO (b/155663717) After restart, status bar will not properly hide home button
// unless disable is called to show un-hide it once first
if (forceClearFlags) {
mStatusBarManager.disable(flags);
}
if (forceHideHomeRecentsButtons || isShowingAndNotOccluded()) {
if (!mShowHomeOverLockscreen || !mInGestureNavigationMode) {
flags |= StatusBarManager.DISABLE_HOME;
}
flags |= StatusBarManager.DISABLE_RECENT;
}
if (DEBUG) {
Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mOccluded=" + mOccluded
+ " isSecure=" + isSecure() + " force=" + forceHideHomeRecentsButtons
+ " --> flags=0x" + Integer.toHexString(flags));
}
mStatusBarManager.disable(flags);
}
}
在调用show 显示状态栏的时候,adjustStatusBarLocked() 可以设置 mStatusBarManager 的flag为StatusBarManager.DISABLE_EXPAND表示禁用下拉状态栏
@@ -2168,7 +2168,7 @@ public class KeyguardViewMediator extends SystemUI {
+ " isSecure=" + isSecure() + " force=" + forceHideHomeRecentsButtons
+ " --> flags=0x" + Integer.toHexString(flags));
}
-
+ flags = StatusBarManager.DISABLE_EXPAND;
mStatusBarManager.disable(flags);
}
}
2.2 StatusBar 中不显示通知信息的图片:
在锁屏通知栏中去掉显示通知的部分,达到禁用下拉状态栏的功能
主要实现如下:
framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
@@ -159,7 +159,8 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
if ((state1 & DISABLE_NOTIFICATION_ICONS) != 0) {
hideNotificationIconArea(animate);
} else {
- showNotificationIconArea(animate);
+ //showNotificationIconArea(animate);
+ hideNotificationIconArea(animate);
}
}
2.3 锁屏是 禁止状态栏下拉
在锁屏状态下禁用下拉状态栏 通知界面NotificationPanelView.java 去掉下拉开展状态栏部分的功能
路径
framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -908,7 +908,7 @@ public class NotificationPanelView extends PanelView implements
if (!isFullyCollapsed()) {
handleQsDown(event);
}
- if (!mQsExpandImmediate && mQsTracking) {
+ if (!mKeyguardShowing && !mQsExpandImmediate && mQsTracking) {
onQsTouch(event);
if (!mConflictingQsExpansionGesture) {
return true;
@@ -1114,6 +1114,9 @@ public class NotificationPanelView extends PanelView implements
}
private void setQsExpanded(boolean expanded) {
+ if (mKeyguardShowing) {
+ return;
+ }
boolean changed = mQsExpanded != expanded;
if (changed) {
mQsExpanded = expanded;
@@ -1508,7 +1511,7 @@ public class NotificationPanelView extends PanelView implements
if (!mQsExpansionEnabled || mCollapsedOnDown) {
return false;
}
- View header = mKeyguardShowing ? mKeyguardStatusBar : mQs.getHeader();
+ View header = /*mKeyguardShowing ? mKeyguardStatusBar :*/ mQs.getHeader();
final boolean onHeader = x >= mQsFrame.getX()
&& x <= mQsFrame.getX() + mQsFrame.getWidth()
&& y >= header.getTop() && y <= header.getBottom();
2.4 锁屏状态隐藏通知栏的显示
禁止显示通知栏
/framework/base/packages/apps/SystemUI/src/com/android/systemui/statusbar/notification/NotificationStackScrollLayout.java
@@ -717,7 +717,8 @@ public class NotificationStackScrollLayout extends ViewGroup
}
private void setMaxLayoutHeight(int maxLayoutHeight) {
- mMaxLayoutHeight = maxLayoutHeight;
+ //mMaxLayoutHeight = maxLayoutHeight;
+ mMaxLayoutHeight = 0;
mShelf.setMaxLayoutHeight(maxLayoutHeight);
updateAlgorithmHeightAndPadding();
}
@@ -2590,9 +2591,10 @@ public class NotificationStackScrollLayout extends ViewGroup
} else {
mTopPaddingOverflow = 0;
}
- setTopPadding(ignoreIntrinsicPadding ? topPadding : clampPadding(topPadding),
- animate);
- setExpandedHeight(mExpandedHeight);
+ //setTopPadding(ignoreIntrinsicPadding ? topPadding : clampPadding(topPadding),
+ // animate);
+ //setExpandedHeight(mExpandedHeight);
+ setTopPadding(-500,animate);
}