Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29fd5bac authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove add slippery flag to nav bar when connected to launcher service"

parents c8e3c7c8 7d05e77d
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -32,13 +32,17 @@ import android.view.SurfaceControl;

import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.statusbar.policy.CallbackController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import java.util.ArrayList;
import java.util.List;

/**
 * Class to send information from overview to launcher with a binder.
 */
public class OverviewProxyService {
public class OverviewProxyService implements CallbackController<OverviewProxyListener> {

    private static final String TAG = "OverviewProxyService";
    private static final long BACKOFF_MILLIS = 5000;
@@ -48,6 +52,7 @@ public class OverviewProxyService {
    private final Runnable mConnectionRunnable = this::startConnectionToCurrentUser;
    private final DeviceProvisionedController mDeviceProvisionedController
            = Dependency.get(DeviceProvisionedController.class);
    private final List<OverviewProxyListener> mConnectionCallbacks = new ArrayList<>();

    private IOverviewProxy mOverviewProxy;
    private int mConnectionBackoffAttempts;
@@ -82,6 +87,7 @@ public class OverviewProxyService {
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to call onBind()", e);
                }
                notifyConnectionChanged();
            }
        }

@@ -144,6 +150,17 @@ public class OverviewProxyService {
        }
    }

    @Override
    public void addCallback(OverviewProxyListener listener) {
        mConnectionCallbacks.add(listener);
        listener.onConnectionChanged(mOverviewProxy != null);
    }

    @Override
    public void removeCallback(OverviewProxyListener listener) {
        mConnectionCallbacks.remove(listener);
    }

    public IOverviewProxy getProxy() {
        return mOverviewProxy;
    }
@@ -152,6 +169,17 @@ public class OverviewProxyService {
        if (mOverviewProxy != null) {
            mContext.unbindService(mOverviewServiceConnection);
            mOverviewProxy = null;
            notifyConnectionChanged();
        }
    }

    private void notifyConnectionChanged() {
        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
            mConnectionCallbacks.get(i).onConnectionChanged(mOverviewProxy != null);
        }
    }

    public interface OverviewProxyListener {
        void onConnectionChanged(boolean isConnected);
    }
}
+11 −5
Original line number Diff line number Diff line
@@ -112,20 +112,26 @@ public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureL
        mIsRTL = isRTL;
    }

    public boolean onInterceptTouchEvent(MotionEvent event) {
    private boolean proxyMotionEvents(MotionEvent event) {
        final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
        if (overviewProxy != null) {
            mNavigationBarView.requestUnbufferedDispatch(event);
            try {
                overviewProxy.onMotionEvent(event);
                return true;
            } catch (RemoteException e) {
                Log.e(TAG, "Callback failed", e);
            }
        }
        return false;
    }

    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (!proxyMotionEvents(event)) {
            // If we move more than a fixed amount, then start capturing for the
        // task switcher detector
            // task switcher detector, disabled when proxying motion events to launcher service
            mTaskSwitcherDetector.onTouchEvent(event);
        }
        int action = event.getAction();
        switch (action & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN: {
@@ -289,7 +295,7 @@ public class NavigationBarGestureHelper extends GestureDetector.SimpleOnGestureL
    }

    public boolean onTouchEvent(MotionEvent event) {
        boolean result = mTaskSwitcherDetector.onTouchEvent(event);
        boolean result = proxyMotionEvents(event) || mTaskSwitcherDetector.onTouchEvent(event);
        if (mDockWindowEnabled) {
            result |= handleDockWindowEvent(event);
        }
+25 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ import android.widget.FrameLayout;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.DockedStackExistsListener;
import com.android.systemui.OverviewProxyService;
import com.android.systemui.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.plugins.PluginListener;
@@ -196,6 +198,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        }
    }

    private final OverviewProxyListener mOverviewProxyListener =
            isConnected -> setSlippery(!isConnected);

    public NavigationBarView(Context context, AttributeSet attrs) {
        super(context, attrs);

@@ -531,6 +536,24 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        }
    }

    private void setSlippery(boolean slippery) {
        boolean changed = false;
        final ViewGroup navbarView = ((ViewGroup) getParent());
        final WindowManager.LayoutParams lp = (WindowManager.LayoutParams) navbarView
                .getLayoutParams();
        if (slippery && (lp.flags & WindowManager.LayoutParams.FLAG_SLIPPERY) == 0) {
            lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY;
            changed = true;
        } else if (!slippery && (lp.flags & WindowManager.LayoutParams.FLAG_SLIPPERY) != 0) {
            lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY;
            changed = true;
        }
        if (changed) {
            WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
            wm.updateViewLayout(navbarView, lp);
        }
    }

    public void setMenuVisibility(final boolean show) {
        setMenuVisibility(show, false);
    }
@@ -756,6 +779,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        onPluginDisconnected(null); // Create default gesture helper
        Dependency.get(PluginManager.class).addPluginListener(this,
                NavGesture.class, false /* Only one */);
        Dependency.get(OverviewProxyService.class).addCallback(mOverviewProxyListener);
    }

    @Override
@@ -765,6 +789,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        if (mGestureHelper != null) {
            mGestureHelper.destroy();
        }
        Dependency.get(OverviewProxyService.class).removeCallback(mOverviewProxyListener);
    }

    @Override