Merge "Make the show/hide system setting for recent location acccesses sticky."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d6909d1843
@@ -20,6 +20,7 @@ import android.content.Intent;
|
||||
import android.icu.text.RelativeDateTimeFormatter;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -85,11 +86,17 @@ public class RecentLocationAccessPreferenceController extends LocationBasePrefer
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mCategoryRecentLocationRequests = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
mCategoryRecentLocationRequests.removeAll();
|
||||
final Context prefContext = mCategoryRecentLocationRequests.getContext();
|
||||
final List<RecentAppOpsAccess.Access> recentLocationAccesses = new ArrayList<>();
|
||||
final UserManager userManager = UserManager.get(mContext);
|
||||
for (RecentAppOpsAccess.Access access : mRecentLocationApps.getAppListSorted(
|
||||
/* showSystemApps= */ false)) {
|
||||
final boolean showSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
||||
for (RecentAppOpsAccess.Access access : mRecentLocationApps.getAppListSorted(showSystem)) {
|
||||
if (isRequestMatchesProfileType(userManager, access, mType)) {
|
||||
recentLocationAccesses.add(access);
|
||||
if (recentLocationAccesses.size() == MAX_APPS) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.settings.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -36,7 +37,6 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
|
||||
|
||||
private static final int MENU_SHOW_SYSTEM = Menu.FIRST + 1;
|
||||
private static final int MENU_HIDE_SYSTEM = Menu.FIRST + 2;
|
||||
private static final String EXTRA_SHOW_SYSTEM = "show_system";
|
||||
|
||||
private boolean mShowSystem = false;
|
||||
private MenuItem mShowSystemMenu;
|
||||
@@ -58,18 +58,8 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
mShowSystem = savedInstanceState.getBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
|
||||
}
|
||||
if (mController != null) {
|
||||
mController.setShowSystem(mShowSystem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
|
||||
mShowSystem = Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +78,8 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
|
||||
case MENU_SHOW_SYSTEM:
|
||||
case MENU_HIDE_SYSTEM:
|
||||
mShowSystem = menuItem.getItemId() == MENU_SHOW_SYSTEM;
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, mShowSystem ? 1 : 0);
|
||||
updateMenu();
|
||||
if (mController != null) {
|
||||
mController.setShowSystem(mShowSystem);
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.android.settings.location.RecentLocationAccessPreferenceContro
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -43,6 +44,8 @@ public class RecentLocationAccessSeeAllPreferenceController
|
||||
|
||||
public RecentLocationAccessSeeAllPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mShowSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
||||
mRecentLocationAccesses = RecentAppOpsAccess.createForLocation(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -83,8 +84,11 @@ public class RecentLocationRequestPreferenceController extends LocationBasePrefe
|
||||
final Context prefContext = mCategoryRecentLocationRequests.getContext();
|
||||
final List<RecentLocationApps.Request> recentLocationRequests = new ArrayList<>();
|
||||
final UserManager userManager = UserManager.get(mContext);
|
||||
final boolean showSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
||||
|
||||
for (RecentLocationApps.Request request : mRecentLocationApps.getAppListSorted(
|
||||
false /* systemApps */)) {
|
||||
showSystem)) {
|
||||
if (isRequestMatchesProfileType(userManager, request, mType)) {
|
||||
recentLocationRequests.add(request);
|
||||
if (recentLocationRequests.size() == MAX_APPS) {
|
||||
|
||||
Reference in New Issue
Block a user