OSDN Git Service

Lock Work Profile immediately when user presses power button
authorClara Bayarri <clarabayarri@google.com>
Wed, 17 Feb 2016 15:17:14 +0000 (15:17 +0000)
committerClara Bayarri <clarabayarri@google.com>
Thu, 18 Feb 2016 11:20:35 +0000 (11:20 +0000)
Bug: 26579952
Change-Id: I6e4e0fc2a4f41c72f0d940006f6ceb17e7852682

packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java

index 90d56f7..6029c23 100644 (file)
@@ -758,7 +758,7 @@ public class KeyguardViewMediator extends SystemUI {
                 mPendingLock = false;
             }
         }
-        doKeyguardLaterLockedForChildProfiles();
+        doKeyguardForChildProfilesLocked();
         KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why);
     }
 
@@ -781,8 +781,7 @@ public class KeyguardViewMediator extends SystemUI {
 
         long timeout;
 
-        if ((mLockPatternUtils.isSeparateProfileChallengeEnabled(userId))
-                || policyTimeout <= 0) {
+        if (policyTimeout <= 0) {
             timeout = lockAfterTimeout;
         } else {
             // From DisplaySettings
@@ -815,23 +814,31 @@ public class KeyguardViewMediator extends SystemUI {
         mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender);
         if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = "
                          + mDelayedShowingSequence);
-        doKeyguardLaterLockedForChildProfiles();
+        doKeyguardLaterForChildProfilesLocked();
     }
 
-    private void doKeyguardLaterLockedForChildProfiles() {
+    private void doKeyguardLaterForChildProfilesLocked() {
         UserManager um = UserManager.get(mContext);
         List<UserInfo> profiles = um.getEnabledProfiles(UserHandle.myUserId());
-        if (profiles.size() > 1) {
-            for (UserInfo info : profiles) {
-                if (mLockPatternUtils.isSeparateProfileChallengeEnabled(info.id)) {
-                    long userTimeout = getLockTimeout(info.id);
-                    long userWhen = SystemClock.elapsedRealtime() + userTimeout;
-                    Intent lockIntent = new Intent(DELAYED_LOCK_PROFILE_ACTION);
-                    lockIntent.putExtra(Intent.EXTRA_USER_ID, info.id);
-                    PendingIntent lockSender = PendingIntent.getBroadcast(
-                            mContext, 0, lockIntent, PendingIntent.FLAG_CANCEL_CURRENT);
-                    mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, userWhen, lockSender);
-                }
+        for (UserInfo info : profiles) {
+            if (mLockPatternUtils.isSeparateProfileChallengeEnabled(info.id)) {
+                long userTimeout = getLockTimeout(info.id);
+                long userWhen = SystemClock.elapsedRealtime() + userTimeout;
+                Intent lockIntent = new Intent(DELAYED_LOCK_PROFILE_ACTION);
+                lockIntent.putExtra(Intent.EXTRA_USER_ID, info.id);
+                PendingIntent lockSender = PendingIntent.getBroadcast(
+                        mContext, 0, lockIntent, PendingIntent.FLAG_CANCEL_CURRENT);
+                mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, userWhen, lockSender);
+            }
+        }
+    }
+
+    private void doKeyguardForChildProfilesLocked() {
+        UserManager um = UserManager.get(mContext);
+        List<UserInfo> profiles = um.getEnabledProfiles(UserHandle.myUserId());
+        for (UserInfo info : profiles) {
+            if (mLockPatternUtils.isSeparateProfileChallengeEnabled(info.id)) {
+                lockProfile(info.id);
             }
         }
     }