Prevent accounts page directly opening in screen pinning mode
In Settings there is no auth mechanism to prevent accounts page being opened in screen pinning mode. This CL makes it so that when users are trying to navigate to any pages in Settings from other apps in screen pinning mode, Settings app will directly close its page. Bug: 137015265 Bug: 135604684 Test: manual Change-Id: If26eda408a9ef6fa03ad82e5bee51bb7185950d6 Merged-In: If26eda408a9ef6fa03ad82e5bee51bb7185950d6 (cherry picked from commitf3242dab35
) (cherry picked from commita545a85f9d
)
This commit is contained in:
committed by
android-build-team Robot
parent
9f75893c59
commit
36bbb02dca
@@ -17,6 +17,7 @@ package com.android.settings.core;
|
||||
|
||||
import android.annotation.LayoutRes;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -26,6 +27,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -61,6 +63,10 @@ public class SettingsBaseActivity extends FragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (isLockTaskModePinned() && !isSettingsRunOnTop()) {
|
||||
Log.w(TAG, "Devices lock task mode pinned.");
|
||||
finish();
|
||||
}
|
||||
final long startTime = System.currentTimeMillis();
|
||||
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||
|
||||
@@ -148,6 +154,20 @@ public class SettingsBaseActivity extends FragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLockTaskModePinned() {
|
||||
final ActivityManager activityManager =
|
||||
getApplicationContext().getSystemService(ActivityManager.class);
|
||||
return activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED;
|
||||
}
|
||||
|
||||
private boolean isSettingsRunOnTop() {
|
||||
final ActivityManager activityManager =
|
||||
getApplicationContext().getSystemService(ActivityManager.class);
|
||||
final String taskPkgName = activityManager.getRunningTasks(1 /* maxNum */)
|
||||
.get(0 /* index */).baseActivity.getPackageName();
|
||||
return TextUtils.equals(getPackageName(), taskPkgName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether or not the enabled state actually changed.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user