Prevent accounts page directly opening in screen pinning mode
There is no auth mechanism to prevent accounts page being opened in screen pinning mode. We will directly close the account page if users are trying to navigate to it from screen pinning mode. Fixes: 137015265 Test: manual, robotests Change-Id: If26eda408a9ef6fa03ad82e5bee51bb7185950d6
This commit is contained in:
@@ -15,11 +15,17 @@
|
||||
*/
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED;
|
||||
import static android.provider.Settings.EXTRA_AUTHORITIES;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
@@ -40,6 +46,14 @@ public class AccountDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "AccountDashboardFrag";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
if (isLockTaskModePinned()) {
|
||||
Log.w(TAG, "Devices lock task mode pinned.");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -83,6 +97,13 @@ public class AccountDashboardFragment extends DashboardFragment {
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isLockTaskModePinned() {
|
||||
final ActivityManager activityManager =
|
||||
getContext().getSystemService(ActivityManager.class);
|
||||
return activityManager.getLockTaskModeState() == LOCK_TASK_MODE_PINNED;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user