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

Commit 2fa41c61 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

SystemUI: update keyguard state when profiles disable keyguard



Also add a broadcast receiver to watch for profile changes/updates and
update the tile whenever we receive those.

Ref: OSS NIGHTLIES-1721

Change-Id: I68d4789159cb9a0a25609380054ae5545c9df5bd
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 4d44ddac
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1136,6 +1136,12 @@ public class KeyguardViewMediator extends SystemUI {
        return !mInternallyDisabled;
    }

    private boolean isProfileDisablingKeyguard() {
        final Profile activeProfile = ProfileManager.getInstance(mContext).getActiveProfile();
        return activeProfile != null
                && activeProfile.getScreenLockMode().getValue() == Profile.LockMode.DISABLE;
    }

    /**
     * Same semantics as {@link android.view.WindowManagerPolicy#enableKeyguard}; provide
     * a way for external stuff to override normal keyguard behavior.  For instance
@@ -1164,7 +1170,7 @@ public class KeyguardViewMediator extends SystemUI {
                // hiding keyguard that is showing, remember to reshow later
                if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "
                        + "disabling status bar expansion");
                mNeedToReshowWhenReenabled = true;
                mNeedToReshowWhenReenabled = !isProfileDisablingKeyguard();
                updateInputRestrictedLocked();
                hideLocked();
            } else if (enabled && mNeedToReshowWhenReenabled) {
+18 −0
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package com.android.systemui.qs.tiles;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.media.AudioManager;
import android.os.Handler;
import android.provider.Settings;
import android.view.LayoutInflater;
@@ -125,8 +128,13 @@ public class ProfilesTile extends QSTile<QSTile.State> implements KeyguardMonito
        mListening = listening;
        if (listening) {
            mObserver.startObserving();
            final IntentFilter filter = new IntentFilter();
            filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_SELECTED);
            filter.addAction(ProfileManager.INTENT_ACTION_PROFILE_UPDATED);
            mContext.registerReceiver(mReceiver, filter);
        } else {
            mObserver.endObserving();
            mContext.unregisterReceiver(mReceiver);
        }
    }

@@ -158,6 +166,16 @@ public class ProfilesTile extends QSTile<QSTile.State> implements KeyguardMonito
        }
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (ProfileManager.INTENT_ACTION_PROFILE_SELECTED.equals(intent.getAction())
                    || ProfileManager.INTENT_ACTION_PROFILE_UPDATED.equals(intent.getAction())) {
                refreshState();
            }
        }
    };

    public class ProfileDetailAdapter implements DetailAdapter, AdapterView.OnItemClickListener {

        private List<Profile> mProfilesList;