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

Commit 5d7282dd authored by d34d's avatar d34d
Browse files

LLS: Add LiveLockScreenController

LiveLockScreenController uses the new LiveLockScreenManagerService
to coordinate displaying live lock screens.

Change-Id: I1549b4420f5d95bfbe0cc90cb4938efa65f1dfc4
parent 015241cc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@
    <!-- Performance Manager -->
    <uses-permission android:name="cyanogenmod.permission.PERFORMANCE_ACCESS" />

    <!-- Live lock screen manager -->
    <uses-permission android:name="cyanogenmod.permission.LIVE_LOCK_SCREEN_MANAGER_ACCESS_PRIVATE" />

    <application>
        <provider android:name=".cm.SpamMessageProvider"
                  android:permission="android.permission.INTERACT_ACROSS_USERS_FULL"
+0 −173
Original line number Diff line number Diff line
@@ -21,15 +21,10 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
@@ -46,7 +41,6 @@ import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
@@ -76,13 +70,9 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;

import cyanogenmod.externalviews.KeyguardExternalView;
import cyanogenmod.providers.CMSettings;

import java.util.List;
import java.util.Objects;

import org.cyanogenmod.internal.util.CmLockPatternUtils;

public class NotificationPanelView extends PanelView implements
        ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
@@ -109,11 +99,6 @@ public class NotificationPanelView extends PanelView implements
    public static final long DOZE_ANIMATION_DURATION = 700;


    // Layout params for external keyguard view
    private static final FrameLayout.LayoutParams EXTERNAL_KEYGUARD_VIEW_PARAMS =
            new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);

    private KeyguardAffordanceHelper mAfforanceHelper;
    private StatusBarHeaderView mHeader;
    private KeyguardUserSwitcher mKeyguardUserSwitcher;
@@ -229,11 +214,6 @@ public class NotificationPanelView extends PanelView implements
    private boolean mLaunchingAffordance;
    private String mLastCameraLaunchSource = KeyguardBottomAreaView.CAMERA_LAUNCH_SOURCE_AFFORDANCE;

    private ComponentName mThirdPartyKeyguardViewComponent;
    private KeyguardExternalView mKeyguardExternalView;
    private CmLockPatternUtils mLockPatternUtils;
    private boolean mLiveLockScreenEnabled;

    private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
        @Override
        public void run() {
@@ -318,20 +298,12 @@ public class NotificationPanelView extends PanelView implements
                }
            }
        });

        mLockPatternUtils = new CmLockPatternUtils(getContext());
        if (mLockPatternUtils.isThirdPartyKeyguardEnabled() && mLiveLockScreenEnabled) {
            mThirdPartyKeyguardViewComponent = mLockPatternUtils.getThirdPartyKeyguardComponent();
        }
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        mSettingsObserver.observe();
        mContext.registerReceiver(mExternalKeyguardViewChangedReceiver,
                new IntentFilter(CmLockPatternUtils.ACTION_THIRD_PARTY_KEYGUARD_COMPONENT_CHANGED));

        mScrollView.setListener(this);
    }

@@ -339,7 +311,6 @@ public class NotificationPanelView extends PanelView implements
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mSettingsObserver.unobserve();
        mContext.unregisterReceiver(mExternalKeyguardViewChangedReceiver);
    }

    @Override
@@ -1119,23 +1090,6 @@ public class NotificationPanelView extends PanelView implements
        if (statusBarState == StatusBarState.KEYGUARD ||
                statusBarState == StatusBarState.SHADE_LOCKED) {
            updateDozingVisibilities(false /* animate */);
            if (mThirdPartyKeyguardViewComponent != null) {
                if (mKeyguardExternalView == null) {
                    mKeyguardExternalView =
                            getExternalKeyguardView(mThirdPartyKeyguardViewComponent);
                    if (mKeyguardExternalView != null) {
                        mKeyguardExternalView.registerKeyguardExternalViewCallback(
                                mExternalKeyguardViewCallbacks);
                    }
                }
                if (mKeyguardExternalView != null && !mKeyguardExternalView.isAttachedToWindow()) {
                    addView(mKeyguardExternalView, 0, EXTERNAL_KEYGUARD_VIEW_PARAMS);
                }
            }
        } else {
            if (mKeyguardExternalView != null && mKeyguardExternalView.isAttachedToWindow()) {
                removeView(mKeyguardExternalView);
            }
        }
        resetVerticalPanelPosition();
        updateQsState();
@@ -1213,82 +1167,6 @@ public class NotificationPanelView extends PanelView implements
        }
    };

    private KeyguardExternalView.KeyguardExternalViewCallbacks mExternalKeyguardViewCallbacks =
            new KeyguardExternalView.KeyguardExternalViewCallbacks() {
        @Override
        public boolean requestDismiss() {
            if (hasExternalKeyguardView()) {
                post(new Runnable() {
                    @Override
                    public void run() {
                        mStatusBar.showKeyguard();
                        mStatusBar.showBouncer();
                    }
                });
                return true;
            }
            return false;
        }

        @Override
        public boolean requestDismissAndStartActivity(final Intent intent) {
            if (hasExternalKeyguardView()) {
                if (hasExternalKeyguardView()) {
                    post(new Runnable() {
                        @Override
                        public void run() {
                            mStatusBar.showKeyguard();
                            mStatusBar.startActivityDismissingKeyguard(intent, false, true, true,
                                    null);
                        }
                    });
                }
                return true;
            }
            return false;
        }

        @Override
        public void collapseNotificationPanel() {
            if (mStatusBar.getBarState() == StatusBarState.KEYGUARD && hasExternalKeyguardView() &&
                    mKeyguardExternalView.isInteractive()) {
                post(new Runnable() {
                    @Override
                    public void run() {
                        mStatusBar.focusKeyguardExternalView();
                    }
                });
            }
        }

        @Override
        public void providerDied() {
            mKeyguardExternalView.unregisterKeyguardExternalViewCallback(
                    mExternalKeyguardViewCallbacks);
            mKeyguardExternalView = null;
        }
    };

    private BroadcastReceiver mExternalKeyguardViewChangedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String pkgName = getSendingPackage(intent);
            if (pkgName != null) {
                PackageManager pm = context.getPackageManager();
                if (pm.checkPermission(android.Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE,
                        pkgName) != PackageManager.PERMISSION_GRANTED) {
                    // we should not be here if the sending app does not have the proper permission,
                    // so do nothing and return.
                    return;
                }
            } else {
                // null package name?  something is not right so just return and skip doing anything
                return;
            }
            updateExternalKeyguardView();
        }
    };

    private void animateHeaderSlidingIn() {
        // If the QS is already expanded we don't need to slide in the header as it's already
        // visible.
@@ -2595,8 +2473,6 @@ public class NotificationPanelView extends PanelView implements
                    CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN), false, this);
            resolver.registerContentObserver(CMSettings.System.getUriFor(
                    CMSettings.System.DOUBLE_TAP_SLEEP_GESTURE), false, this);
            resolver.registerContentObserver(CMSettings.Secure.getUriFor(
                    CMSettings.Secure.LIVE_LOCK_SCREEN_ENABLED), false, this);
            update();
        }

@@ -2624,10 +2500,6 @@ public class NotificationPanelView extends PanelView implements

            boolean liveLockScreenEnabled = CMSettings.Secure.getInt(
                    resolver, CMSettings.Secure.LIVE_LOCK_SCREEN_ENABLED, 0) == 1;
            if (liveLockScreenEnabled != mLiveLockScreenEnabled) {
                mLiveLockScreenEnabled = liveLockScreenEnabled;
                updateExternalKeyguardView();
            }
        }
    }

@@ -2698,49 +2570,4 @@ public class NotificationPanelView extends PanelView implements
        List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1);
        return !tasks.isEmpty() && pkgName.equals(tasks.get(0).topActivity.getPackageName());
    }

    public boolean hasExternalKeyguardView() {
        return mKeyguardExternalView != null && mKeyguardExternalView.isAttachedToWindow();
    }

    public boolean isExternalKeyguardViewInteractive() {
        return mKeyguardExternalView != null && mKeyguardExternalView.isInteractive();
    }

    public KeyguardExternalView getExternalKeyguardView() {
        return mKeyguardExternalView;
    }

    private KeyguardExternalView getExternalKeyguardView(ComponentName componentName) {
        try {
            return new KeyguardExternalView(getContext(), null, componentName);
        } catch (Exception e) {
            // just return null below and move on
        }
        return null;
    }

    private void updateExternalKeyguardView() {
        ComponentName cn = mLiveLockScreenEnabled ?
                mLockPatternUtils.getThirdPartyKeyguardComponent() : null;
        // If mThirdPartyKeyguardViewComponent differs from cn, go ahead and update
        if (!Objects.equals(mThirdPartyKeyguardViewComponent, cn)) {
            mThirdPartyKeyguardViewComponent = cn;
            if (mKeyguardExternalView != null) {
                if (indexOfChild(mKeyguardExternalView) >= 0) {
                    removeView(mKeyguardExternalView);
                }
                mKeyguardExternalView.unregisterKeyguardExternalViewCallback(
                        mExternalKeyguardViewCallbacks);
                if (mThirdPartyKeyguardViewComponent != null) {
                    mKeyguardExternalView =
                            getExternalKeyguardView(mThirdPartyKeyguardViewComponent);
                    mKeyguardExternalView.registerKeyguardExternalViewCallback(
                            mExternalKeyguardViewCallbacks);
                } else {
                    mKeyguardExternalView = null;
                }
            }
        }
    }
}
+26 −14
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ import com.android.systemui.statusbar.policy.HotspotControllerImpl;
import com.android.systemui.statusbar.policy.KeyButtonView;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.policy.LiveLockScreenController;
import com.android.systemui.statusbar.policy.LocationControllerImpl;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkControllerImpl;
@@ -322,6 +323,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    WeatherControllerImpl mWeatherController;
    SuControllerImpl mSuController;
    FingerprintUnlockController mFingerprintUnlockController;
    LiveLockScreenController mLiveLockScreenController;

    int mNaturalBarHeight = -1;

@@ -921,6 +923,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mNotificationPanel.setBackground(new FastColorDrawable(context.getColor(
                    R.color.notification_panel_solid_background)));
        }
        mLiveLockScreenController = new LiveLockScreenController(mContext, this,
                mNotificationPanel);

        if (mHeadsUpManager == null) {
            mHeadsUpManager = new HeadsUpManager(context, mStatusBarWindow);
@@ -2202,7 +2206,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }

        // apply user lockscreen image
        if (backdropBitmap == null && !mNotificationPanel.hasExternalKeyguardView()) {
        if (backdropBitmap == null && !mLiveLockScreenController.isShowingLiveLockScreenView()) {
            backdropBitmap = mKeyguardWallpaper;
        }

@@ -3765,6 +3769,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        if (mKeyguardIndicationController != null) {
            mKeyguardIndicationController.cleanup();
        }
        if (mLiveLockScreenController != null) {
            mLiveLockScreenController.cleanup();
        }

        mStatusBarWindow.removeContent(mStatusBarWindowContent);
        mStatusBarWindow.clearDisappearingChildren();
@@ -4323,8 +4330,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mDraggedDownRow = null;
        }
        mAssistManager.onLockscreenShown();
        if (mNotificationPanel.hasExternalKeyguardView()) {
            mNotificationPanel.getExternalKeyguardView().onKeyguardShowing(
        if (mLiveLockScreenController.isShowingLiveLockScreenView()) {
            mLiveLockScreenController.getLiveLockScreenView().onKeyguardShowing(
                    mStatusBarKeyguardViewManager.isScreenTurnedOn());
        }
    }
@@ -4477,8 +4484,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mNotificationPanel.onAffordanceLaunchEnded();
        mNotificationPanel.animate().cancel();
        mNotificationPanel.setAlpha(1f);
        if ( mNotificationPanel.getExternalKeyguardView() != null) {
            mNotificationPanel.getExternalKeyguardView().onKeyguardDismissed();
        if (mLiveLockScreenController.isShowingLiveLockScreenView()) {
            mLiveLockScreenController.getLiveLockScreenView().onKeyguardDismissed();
        }
        return staying;
    }
@@ -4568,6 +4575,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mIconPolicy.setKeyguardShowing(false);
        }
        mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade);
        mLiveLockScreenController.setBarState(mState);
        updateDozingState();
        updatePublicMode();
        updateStackScrollerState(goingToFullShade);
@@ -4656,7 +4664,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        return false;
    }

    protected void showBouncer() {
    public void showBouncer() {
        if (!mRecreating &&
                (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
            mWaitingForKeyguardExit = mStatusBarKeyguardViewManager.isShowing();
@@ -4665,15 +4673,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }

    protected void showBouncerOrFocusKeyguardExternalView() {
        if (mNotificationPanel.hasExternalKeyguardView() && !isKeyguardShowingMedia() &&
                mNotificationPanel.isExternalKeyguardViewInteractive()) {
        if (mLiveLockScreenController.isShowingLiveLockScreenView() && !isKeyguardShowingMedia() &&
                mLiveLockScreenController.isLiveLockScreenInteractive()) {
            focusKeyguardExternalView();
        } else {
            showBouncer();
        }
    }

    protected void focusKeyguardExternalView() {
    public void focusKeyguardExternalView() {
        mStatusBarView.collapseAllPanels(/*animate=*/ false, false /* delayed*/,
                1.0f /* speedUpFactor */);
        mStatusBarKeyguardViewManager.setKeyguardExternalViewFocus(true);
@@ -4758,7 +4766,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    public void onTrackingStopped(boolean expand) {
        if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
            if (!expand && (!mUnlockMethodCache.canSkipBouncer() ||
                    mNotificationPanel.hasExternalKeyguardView())) {
                    mLiveLockScreenController.isShowingLiveLockScreenView())) {
                showBouncerOrFocusKeyguardExternalView();
            }
        } else if (expand && mStatusBarWindowManager.keyguardExternalViewHasFocus()) {
@@ -4927,15 +4935,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mScreenTurningOn = false;
        mDozeScrimController.onScreenTurnedOn();
        mVisualizerView.setVisible(true);
        if (mNotificationPanel.hasExternalKeyguardView()) {
            mNotificationPanel.getExternalKeyguardView().onScreenTurnedOn();
        if (mLiveLockScreenController.isShowingLiveLockScreenView()) {
            mLiveLockScreenController.getLiveLockScreenView().onScreenTurnedOn();
        }
    }

    public void onScreenTurnedOff() {
        mVisualizerView.setVisible(false);
        if (mNotificationPanel.hasExternalKeyguardView()) {
            mNotificationPanel.getExternalKeyguardView().onScreenTurnedOff();
        if (mLiveLockScreenController.isShowingLiveLockScreenView()) {
            mLiveLockScreenController.getLiveLockScreenView().onScreenTurnedOff();
        }
    }

@@ -5342,6 +5350,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        return mVisualizerView;
    }

    public boolean isShowingLiveLockScreenView() {
        return mLiveLockScreenController.isShowingLiveLockScreenView();
    }

    private final class ShadeUpdates {
        private final ArraySet<String> mVisibleNotifications = new ArraySet<String>();
        private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>();
+1 −1
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ public class StatusBarKeyguardViewManager {

    public boolean shouldDisableWindowAnimationsForUnlock() {
        return mPhoneStatusBar.isInLaunchTransition() ||
                mPhoneStatusBar.mNotificationPanel.hasExternalKeyguardView();
                mPhoneStatusBar.isShowingLiveLockScreenView();
    }

    public boolean isGoingToNotificationShade() {
+223 −0

File added.

Preview size limit exceeded, changes collapsed.