android 8.1 修改禁止状态栏下拉

提供接口给三方,三方发一个广播,就需要禁止下拉状态,下面是自测通过的代码修改。

 

 

Index: src/com/android/systemui/statusbar/phone/NotificationPanelView.java
===================================================================
--- src/com/android/systemui/statusbar/phone/NotificationPanelView.java	(revision 147)
+++ src/com/android/systemui/statusbar/phone/NotificationPanelView.java	(working copy)
@@ -70,6 +70,13 @@
 
 import java.util.List;
 
+/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.BroadcastReceiver;
+import android.util.Log;
+import android.util.Slog;
+/*[FEATURE]-Add-END by ssss*/
 public class NotificationPanelView extends PanelView implements
         ExpandableView.OnHeightChangedListener,
         View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
@@ -109,7 +116,9 @@
     private int mTrackingPointer;
     private VelocityTracker mVelocityTracker;
     private boolean mQsTracking;
-
+	/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+	private static boolean mPanelState = true;
+	/*[FEATURE]-Add-END by ssss*/
     /**
      * If set, the ongoing touch gesture might both trigger the expansion in {@link PanelView} and
      * the expansion for quick settings.
@@ -214,6 +223,14 @@
         super(context, attrs);
         setWillNotDraw(!DEBUG);
         mFalsingManager = FalsingManager.getInstance(context);
+		
+		/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+		IntentFilter filter = new IntentFilter();
+		filter = new IntentFilter();
+		filter.addAction("android.intent.action.PANEL_ENABLE");
+        filter.addAction("android.intent.action.PANEL_DISABLED");
+        context.registerReceiver(mPanelReceiver, filter);
+		/*[FEATURE]-Add-END by ssss*/
     }
 
     public void setStatusBar(PhoneStatusBar bar) {
@@ -307,7 +324,19 @@
             mNotificationStackScroller.setLayoutParams(lp);
         }
     }
-
+	/*[FEATURE]-Add-BEGIN by ssss, 17/06/2017, Home change state */
+	BroadcastReceiver mPanelReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {        	
+            if ("android.intent.action.PANEL_ENABLE".equals(intent.getAction())) {
+                mPanelState = true;
+            } else if ("android.intent.action.PANEL_DISABLED".equals(intent.getAction())) {
+                mPanelState = false;
+            }
+			Slog.d(TAG, "mPanelReceiver..........mPanelState="+mPanelState);
+        }
+    };
+	/*[FEATURE]-Add-END by ssss*/
     @Override
     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
         super.onLayout(changed, left, top, right, bottom);
@@ -575,7 +604,9 @@
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent event) {
-        if (mBlockTouches || mQsContainer.isCustomizing()) {
+	Log.i("ssssssssss","onInterceptTouchEvent"); 
+       
+	   if (mBlockTouches || mQsContainer.isCustomizing()) {
             return false;
         }
         initDownStates(event);
@@ -764,6 +795,7 @@
         return true;
     }
 
+
     private boolean handleQsTouch(MotionEvent event) {
         final int action = event.getActionMasked();
         if (action == MotionEvent.ACTION_DOWN && getExpandedFraction() == 1f
@@ -781,7 +813,9 @@
         if (!isFullyCollapsed()) {
             handleQsDown(event);
         }
-        if (!mQsExpandImmediate && mQsTracking) {
+       // if (!mKeyguardShowing&&!mQsExpandImmediate && mQsTracking) {//sssssss
+        if (mPanelState && !mQsExpandImmediate && mQsTracking) {//sssssss
+     
             onQsTouch(event);
             if (!mConflictingQsExpansionGesture) {
                 return true;
@@ -984,6 +1018,8 @@
     }
 
     private void setQsExpanded(boolean expanded) {
+		if(!mPanelState) return  ;//ssssssss
+	
         boolean changed = mQsExpanded != expanded;
         if (changed) {
             mQsExpanded = expanded;
@@ -1359,6 +1395,7 @@
             return false;
         }
         View header = mKeyguardShowing ? mKeyguardStatusBar : mQsContainer.getHeader();
+		if(!mPanelState) {header =mQsContainer.getHeader();}
         boolean onHeader = x >= mQsAutoReinflateContainer.getX()
                 && x <= mQsAutoReinflateContainer.getX() + mQsAutoReinflateContainer.getWidth()
                 && y >= header.getTop() && y <= header.getBottom();
Index: src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
===================================================================
--- src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java	(revision 147)
+++ src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java	(working copy)
@@ -28,6 +28,14 @@
 import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 
+/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.BroadcastReceiver;
+import android.util.Log;
+import android.util.Slog;
+/*[FEATURE]-Add-END by ssss*/ 
+
 public class PhoneStatusBarView extends PanelBar {
     private static final String TAG = "PhoneStatusBarView";
     private static final boolean DEBUG = PhoneStatusBar.DEBUG;
@@ -39,6 +47,13 @@
     private final PhoneStatusBarTransitions mBarTransitions;
     private ScrimController mScrimController;
     private float mMinFraction;
+	/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+	private static boolean mPanelState = true;
+	/*[FEATURE]-Add-END by ssss*/
+
+	//czb add for shield/enabled status bar
+	private Context mContext;
+    //czb add end
     private float mPanelFraction;
     private Runnable mHideExpandedRunnable = new Runnable() {
         @Override
@@ -53,6 +68,13 @@
         super(context, attrs);
 
         mBarTransitions = new PhoneStatusBarTransitions(this);
+		/*[FEATURE]-Add-BEGIN by ssss, 27/07/2017, Status change state */
+		IntentFilter filter = new IntentFilter();
+		filter = new IntentFilter();
+		filter.addAction("android.intent.action.PANEL_ENABLE");
+        filter.addAction("android.intent.action.PANEL_DISABLED");
+        context.registerReceiver(mPanelReceiver, filter);
+		/*[FEATURE]-Add-END by ssss*/
     }
 
     public BarTransitions getBarTransitions() {
@@ -74,6 +96,7 @@
 
     @Override
     public boolean panelEnabled() {
+		//return false;
         return mBar.panelsEnabled();
     }
 
@@ -118,11 +141,28 @@
         }
         mIsFullyOpenedPanel = true;
     }
-
+	/*[FEATURE]-Add-BEGIN by ssss, 17/06/2017, Home change state */
+	BroadcastReceiver mPanelReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {        	
+            if ("android.intent.action.PANEL_ENABLE".equals(intent.getAction())) {
+                mPanelState = true;
+            } else if ("android.intent.action.PANEL_DISABLED".equals(intent.getAction())) {
+                mPanelState = false;
+            }
+			Slog.d(TAG, "mPanelReceiver..........mPanelState="+mPanelState);
+        }
+    };
+	/*[FEATURE]-Add-END by ssss*/
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        boolean barConsumedEvent = mBar.interceptTouchEvent(event);
+		boolean barConsumedEvent = mBar.interceptTouchEvent(event);
 
+		if(!mPanelState){
+			return true;
+		}		   
+		Slog.d(TAG, "2  onTouchEvent mPanelReceiver..........mPanelState="+mPanelState);
+
         if (DEBUG_GESTURES) {
             if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
                 EventLog.writeEvent(EventLogTags.SYSUI_PANELBAR_TOUCH,
@@ -132,8 +172,10 @@
         }
 
         return barConsumedEvent || super.onTouchEvent(event);
+		
     }
 
+
     @Override
     public void onTrackingStarted() {
         super.onTrackingStarted();

 

你可能感兴趣的:(Android,Phone,android)