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

Commit 312e5007 authored by DvTonder's avatar DvTonder Committed by Matt Garnes
Browse files

Profiles : Global actions (Power dialog)

Change-Id: I9c7c5440b7b893eafefcfb6421ab6e7fec7401df
parent e5d1dd02
Loading
Loading
Loading
Loading
+3.83 KiB
Loading image diff...
+3.43 KiB
Loading image diff...
+4.11 KiB
Loading image diff...
+4 −0
Original line number Diff line number Diff line
@@ -40,4 +40,8 @@
     <!-- The title of the profile picker dialog. -->
     <string name="profile_picker_title">Profiles</string>

    <!-- label for item that opens the profile choosing dialog -->
    <string name="global_action_choose_profile">Profile</string>


</resources>
+26 −4
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Profile;
import android.app.ProfileManager;
import android.app.SearchManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
@@ -168,7 +170,7 @@ public class KeyguardViewMediator extends SystemUI {
    private AudioManager mAudioManager;
    private StatusBarManager mStatusBarManager;
    private boolean mSwitchingUser;

    private ProfileManager mProfileManager;
    private boolean mSystemReady;
    private boolean mBootCompleted;
    private boolean mBootSendUserPresent;
@@ -480,7 +482,7 @@ public class KeyguardViewMediator extends SystemUI {
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
        mShowKeyguardWakeLock.setReferenceCounted(false);

        mProfileManager = (ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);
        mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION));

        mKeyguardDisplayManager = new KeyguardDisplayManager(mContext);
@@ -685,7 +687,8 @@ public class KeyguardViewMediator extends SystemUI {
    }

    private void maybeSendUserPresentBroadcast() {
        if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()) {
        if (mSystemReady && isKeyguardDisabled()
                && !mUserManager.isUserSwitcherEnabled()) {
            // Lock screen is disabled because the user has set the preference to "None".
            // In this case, send out ACTION_USER_PRESENT here instead of in
            // handleKeyguardDone()
@@ -693,6 +696,25 @@ public class KeyguardViewMediator extends SystemUI {
        }
    }

    private boolean isKeyguardDisabled() {
        if (!mExternallyEnabled) {
            if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled externally");
            return true;
        }
        if (mLockPatternUtils.isLockScreenDisabled() && mUserManager.getUsers(true).size() == 1) {
            if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled by setting");
            return true;
        }
        Profile profile = mProfileManager.getActiveProfile();
        if (profile != null) {
            if (profile.getScreenLockMode() == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled by profile");
                return true;
            }
         }
        return false;
     }

    /**
     * A dream started.  We should lock after the usual screen-off lock timeout but only
     * if there is a secure lock pattern.
@@ -921,7 +943,7 @@ public class KeyguardViewMediator extends SystemUI {
            return;
        }

        if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
        if (isKeyguardDisabled() && !lockedOrMissing) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
            return;
        }
Loading