packages/apps/Settings
Revisão | c92ac15e06b042383a454669f2b39f33a3a724a2 (tree) |
---|---|
Hora | 2020-05-20 22:48:00 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge remote-tracking branch 'cm/cm-14.1' into cm-14.1-x86
@@ -536,6 +536,12 @@ public class SettingsActivity extends SettingsDrawerActivity | ||
536 | 536 | @Override |
537 | 537 | protected void onCreate(Bundle savedState) { |
538 | 538 | super.onCreate(savedState); |
539 | + | |
540 | + if (isLockTaskModePinned() && !isSettingsRunOnTop()) { | |
541 | + Log.w(LOG_TAG, "Devices lock task mode pinned."); | |
542 | + finish(); | |
543 | + } | |
544 | + | |
539 | 545 | long startTime = System.currentTimeMillis(); |
540 | 546 | |
541 | 547 | // Should happen before any call to getIntent() |
@@ -1349,4 +1355,16 @@ public class SettingsActivity extends SettingsDrawerActivity | ||
1349 | 1355 | } |
1350 | 1356 | super.onActivityResult(requestCode, resultCode, data); |
1351 | 1357 | } |
1358 | + private boolean isLockTaskModePinned() { | |
1359 | + final ActivityManager activityManager = | |
1360 | + getApplicationContext().getSystemService(ActivityManager.class); | |
1361 | + return activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED; | |
1362 | + } | |
1363 | + private boolean isSettingsRunOnTop() { | |
1364 | + final ActivityManager activityManager = | |
1365 | + getApplicationContext().getSystemService(ActivityManager.class); | |
1366 | + final String taskPkgName = activityManager.getRunningTasks(1 /* maxNum */) | |
1367 | + .get(0 /* index */).baseActivity.getPackageName(); | |
1368 | + return TextUtils.equals(getPackageName(), taskPkgName); | |
1369 | + } | |
1352 | 1370 | } |