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

Commit f82e73c5 authored by Chris Wren's avatar Chris Wren Committed by Android (Google) Code Review
Browse files

Merge "disable heads up feature in klp." into klp-dev

parents 219d0f32 f6e83f45
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -93,14 +93,14 @@ public abstract class BaseStatusBar extends SystemUI implements

    protected static final boolean ENABLE_HEADS_UP = true;
    // scores above this threshold should be displayed in heads up mode.
    private static final int INTERRUPTION_THRESHOLD = 11;
    protected static final int INTERRUPTION_THRESHOLD = 11;
    protected static final String SETTING_HEADS_UP = "heads_up_enabled";

    // Should match the value in PhoneWindowManager
    public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";

    public static final int EXPANDED_LEAVE_ALONE = -10000;
    public static final int EXPANDED_FULL_OPEN = -10001;
    private static final String SETTING_HEADS_UP = "heads_up_enabled";

    protected CommandQueue mCommandQueue;
    protected IStatusBarService mBarService;
@@ -125,7 +125,7 @@ public abstract class BaseStatusBar extends SystemUI implements

    protected int mLayoutDirection;
    private Locale mLocale;
    protected boolean mUseHeadsUp = true;
    protected boolean mUseHeadsUp = false;

    protected IDreamManager mDreamManager;
    KeyguardManager mKeyguardManager;
@@ -170,19 +170,6 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    };

    final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) {
        @Override
        public void onChange(boolean selfChange) {
            mUseHeadsUp = ENABLE_HEADS_UP && 0 != Settings.Global.getInt(
                    mContext.getContentResolver(), SETTING_HEADS_UP, 0);
            Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
            if (!mUseHeadsUp) {
                Log.d(TAG, "dismissing any existing heads up notification on disable event");
                mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
            }
        }
    };

    private RemoteViews.OnClickHandler mOnClickHandler = new RemoteViews.OnClickHandler() {
        @Override
        public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
@@ -242,11 +229,6 @@ public abstract class BaseStatusBar extends SystemUI implements
                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
                mProvisioningObserver);

        mHeadsUpObserver.onChange(false); // set up
        mContext.getContentResolver().registerContentObserver(
                Settings.Global.getUriFor(SETTING_HEADS_UP), true,
                mHeadsUpObserver);

        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));

+30 −1
Original line number Diff line number Diff line
@@ -304,6 +304,25 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        }
    };

    final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) {
        @Override
        public void onChange(boolean selfChange) {
            boolean wasUsing = mUseHeadsUp;
            mUseHeadsUp = ENABLE_HEADS_UP && 0 != Settings.Global.getInt(
                    mContext.getContentResolver(), SETTING_HEADS_UP, 0);
            Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
            if (wasUsing != mUseHeadsUp) {
                if (!mUseHeadsUp) {
                    Log.d(TAG, "dismissing any existing heads up notification on disable event");
                    mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
                    removeHeadsUpView();
                } else {
                    addHeadsUpView();
                }
            }
        }
    };

    private int mInteractingWindows;
    private boolean mAutohideSuspended;
    private int mStatusBarMode;
@@ -331,6 +350,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {

        // Lastly, call to the icon policy to install/update all the icons.
        mIconPolicy = new PhoneStatusBarPolicy(mContext);

        mHeadsUpObserver.onChange(true); // set up
        if (ENABLE_HEADS_UP) {
            mContext.getContentResolver().registerContentObserver(
                    Settings.Global.getUriFor(SETTING_HEADS_UP), true,
                    mHeadsUpObserver);
        }
    }

    // ================================================================================
@@ -816,6 +842,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
        mWindowManager.addView(mHeadsUpNotificationView, lp);
    }

    private void removeHeadsUpView() {
        mWindowManager.removeView(mHeadsUpNotificationView);
    }

    public void refreshAllStatusBarIcons() {
        refreshAllIconsForLayout(mStatusIcons);
        refreshAllIconsForLayout(mNotificationIcons);
@@ -2179,7 +2209,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
    @Override
    public void createAndAddWindows() {
        addStatusBarWindow();
        if (ENABLE_HEADS_UP) addHeadsUpView();
    }

    private void addStatusBarWindow() {