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

Commit 24e19bff authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Adnan Begovic
Browse files

base: hide qs tiles with sensitive data



This changes add an option to respect the new sensitive data flag of the QS tiles when
lockscreen is showing and lockscreen is secure.

Requires: topic:hide-qs-tiles

Change-Id: I92d100cdbf8de47fa6cf574e3a5e5c9da71ae749
JIRA: CML-140
JIRA: BACON-3519
JIRA: CYAN-6720
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
Signed-off-by: default avatarAdnan Begovic <adnan@cyngn.com>
parent a9895032
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6108,6 +6108,15 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_VISUALIZER_ENABLED = "lockscreen_visualizer";

        /**
         * Whether to show quick settings tiles with sensitive data in secure lockscreens.
         * 0 will ignore the sensitive data flag, anything else will take care of that
         * flag. Default is off.
         * @hide
         */
        public static final String LOCKSCREEN_HIDE_TILES_WITH_SENSITIVE_DATA =
                "lockscreen_hide_qs_tiles_with_sensitive_data";

        /**
         * This are the settings to be backed up.
         *
+40 −1
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import com.android.systemui.settings.BrightnessController;
import com.android.systemui.settings.ToggleSlider;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;

import cyanogenmod.app.StatusBarPanelCustomTile;

import java.util.ArrayList;
@@ -91,6 +93,14 @@ public class QSPanel extends ViewGroup {
    private DetailCallback mDetailCallback;
    private int mContainerTop;

    private boolean mHideQsTilesWithSensitiveData;
    private final KeyguardMonitor.Callback mKeyguardListener = new KeyguardMonitor.Callback() {
        @Override
        public void onKeyguardChanged() {
            refreshAllTiles();
        }
    };

    public QSPanel(Context context) {
        this(context, null);
    }
@@ -174,7 +184,11 @@ public class QSPanel extends ViewGroup {
    }

    public void setHost(QSTileHost host) {
        if (mHost != null) {
            mHost.getKeyguardMonitor().removeCallback(mKeyguardListener);
        }
        mHost = host;
        mHost.getKeyguardMonitor().addCallback(mKeyguardListener);
        mFooter.setHost(host);
    }

@@ -253,6 +267,19 @@ public class QSPanel extends ViewGroup {
            TileRecord r = mRecords.get(i);
            r.tileView.setDual(mUseMainTiles && i < 2);
            r.tile.refreshState();

            // If we are in a secure lockscreen, then we should hide tiles with sensitive
            // data to be accessed from the lockscreen
            boolean hideTilesWithSensitiveData = mHideQsTilesWithSensitiveData
                    && mHost != null
                    && mHost.getKeyguardMonitor().isShowing()
                    && mHost.getKeyguardMonitor().isSecure();
            if (hideTilesWithSensitiveData && r.tile.hasSensitiveData()) {
                r.tileView.setVisibility(View.GONE);
            } else if (r.tile.hasSensitiveData() && r.lastVisibityState == View.VISIBLE
                    && r.tileView.getVisibility() != View.VISIBLE){
                r.tileView.setVisibility(View.VISIBLE);
            }
        }
        mFooter.refreshState();
    }
@@ -313,7 +340,14 @@ public class QSPanel extends ViewGroup {
                    // then we just set it to invisible, to ensure that it gets visible again
                    visibility = INVISIBLE;
                }
                r.lastVisibityState = visibility;
                boolean hideTilesWithSensitiveData = mHideQsTilesWithSensitiveData
                        && mHost != null
                        && mHost.getKeyguardMonitor().isShowing()
                        && mHost.getKeyguardMonitor().isSecure();
                if (!r.tile.hasSensitiveData() || !hideTilesWithSensitiveData) {
                    setTileVisibility(r.tileView, visibility);
                }
                setTileEnabled(r.tileView, state.enabled);
                r.tileView.onStateChanged(state);
            }
@@ -610,6 +644,10 @@ public class QSPanel extends ViewGroup {
        }
    }

    public void setHideQsTilesWithSensitiveData(boolean value) {
        mHideQsTilesWithSensitiveData = value;
    }

    private class H extends Handler {
        private static final int SHOW_DETAIL = 1;
        private static final int SET_TILE_VISIBILITY = 2;
@@ -637,6 +675,7 @@ public class QSPanel extends ViewGroup {
        int row;
        int col;
        boolean scanState;
        int lastVisibityState = View.VISIBLE;
    }

    private final AnimatorListenerAdapter mTeardownDetailWhenDone = new AnimatorListenerAdapter() {
+4 −0
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public abstract class QSTile<TState extends State> implements Listenable {

    // safe to call from any thread

    public boolean hasSensitiveData() {
        return false;
    }

    public void setCallback(Callback callback) {
        mHandler.obtainMessage(H.SET_CALLBACK, callback).sendToTarget();
    }
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ public class AdbOverNetworkTile extends QSTile<QSTile.BooleanState> {
    private static final Intent SETTINGS_DEVELOPMENT =
            new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);

    @Override
    public boolean hasSensitiveData() {
        return true;
    }

    @Override
    protected BooleanState newTileState() {
        return new BooleanState();
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
        };
    }

    @Override
    public boolean hasSensitiveData() {
        return true;
    }

    @Override
    protected BooleanState newTileState() {
        return new BooleanState();
Loading