From d10f6950c4321409d35476b934f09241b4a1b345 Mon Sep 17 00:00:00 2001 From: Kamaljeet Maini Date: Tue, 10 May 2016 16:25:17 -0700 Subject: Close "Protected apps" activity during power cycle Protected apps activity in Settings is accessed after entering correct pattern. If user turns off/on the phone while Protected apps is in foreground, the user must enter pattern again before using the Protected apps. Added code in onPause method to close the Protected apps activity if the user has already been authorized and there is no screen orientation change. Change-Id: Ie36ac0f54cce62228f6d0d56fef2e1f24096a803 Issue-Id: FEIJ-491 --- .../settings/applications/ProtectedAppsActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/applications/ProtectedAppsActivity.java b/src/com/android/settings/applications/ProtectedAppsActivity.java index 5089f1916..7156c92a0 100644 --- a/src/com/android/settings/applications/ProtectedAppsActivity.java +++ b/src/com/android/settings/applications/ProtectedAppsActivity.java @@ -72,6 +72,7 @@ public class ProtectedAppsActivity extends Activity { private boolean mWaitUserAuth = false; private boolean mUserIsAuth = false; private Intent mTargetIntent; + private int mOrientation; private HashSet mProtectedApps = new HashSet(); @@ -105,6 +106,7 @@ public class ProtectedAppsActivity extends Activity { } else { if (!mUserIsAuth) { // Require unlock + mWaitUserAuth = true; Intent lockPattern = new Intent(this, LockPatternActivity.class); startActivityForResult(lockPattern, REQ_ENTER_PATTERN); } else { @@ -114,6 +116,7 @@ public class ProtectedAppsActivity extends Activity { } } } + mOrientation = getResources().getConfiguration().orientation; } @Override @@ -167,8 +170,10 @@ public class ProtectedAppsActivity extends Activity { public void onPause() { super.onPause(); - // Don't stick around - if (mWaitUserAuth && !mUserIsAuth) { + // Close this app to prevent unauthorized access when + // 1) not waiting for authorization and + // 2) there is no portrait/landscape mode switching + if (!mWaitUserAuth && (mOrientation == getResources().getConfiguration().orientation)) { finish(); } } @@ -181,7 +186,7 @@ public class ProtectedAppsActivity extends Activity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQ_ENTER_PATTERN: - mWaitUserAuth = true; + mWaitUserAuth = false; switch (resultCode) { case RESULT_OK: //Nothing to do, proceed! @@ -197,7 +202,7 @@ public class ProtectedAppsActivity extends Activity { } break; case REQ_RESET_PATTERN: - mWaitUserAuth = true; + mWaitUserAuth = false; mUserIsAuth = false; } } @@ -244,7 +249,7 @@ public class ProtectedAppsActivity extends Activity { } private void resetLock() { - mWaitUserAuth = false; + mWaitUserAuth = true; Intent lockPattern = new Intent(LockPatternActivity.RECREATE_PATTERN, null, this, LockPatternActivity.class); startActivityForResult(lockPattern, REQ_RESET_PATTERN); -- cgit v1.2.3