Suppress work-profile search terms when no AfW is on device
- Share the same set of pref controller between main UI and search in AccountDashboardFragment. - Update WorkSoundPreferenceController to actually do something for updateNonIndexable() method. - LockscreenDashboardFragment to also suppress "Work notification" header. I think we just missed it previously. Change-Id: Ifa6f9b2077c9810ffff33f240929f418d4a8a5aa Fixes: 62167659 Test: robotests
This commit is contained in:
@@ -17,7 +17,6 @@ package com.android.settings.accounts;
|
||||
|
||||
import static android.provider.Settings.EXTRA_AUTHORITIES;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.icu.text.ListFormatter;
|
||||
import android.os.UserHandle;
|
||||
@@ -27,6 +26,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -69,15 +69,23 @@ public class AccountDashboardFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
|
||||
return buildPreferenceControllers(context, this /* parent */, authorities);
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
SettingsPreferenceFragment parent, String[] authorities) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
|
||||
final AccountPreferenceController accountPrefController =
|
||||
new AccountPreferenceController(context, this, authorities);
|
||||
getLifecycle().addObserver(accountPrefController);
|
||||
new AccountPreferenceController(context, parent, authorities);
|
||||
if (parent != null) {
|
||||
parent.getLifecycle().addObserver(accountPrefController);
|
||||
}
|
||||
controllers.add(accountPrefController);
|
||||
controllers.add(new AutoSyncDataPreferenceController(context, this /*parent */));
|
||||
controllers.add(new AutoSyncPersonalDataPreferenceController(context, this /*parent */));
|
||||
controllers.add(new AutoSyncWorkDataPreferenceController(context, this /* parent */));
|
||||
controllers.add(new AutoSyncDataPreferenceController(context, parent));
|
||||
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
|
||||
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@@ -122,13 +130,7 @@ public class AccountDashboardFragment extends DashboardFragment {
|
||||
}
|
||||
|
||||
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
|
||||
= new SummaryLoader.SummaryProviderFactory() {
|
||||
@Override
|
||||
public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
|
||||
SummaryLoader summaryLoader) {
|
||||
return new SummaryProvider(activity, summaryLoader);
|
||||
}
|
||||
};
|
||||
= (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader);
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@@ -139,5 +141,12 @@ public class AccountDashboardFragment extends DashboardFragment {
|
||||
sir.xmlResId = R.xml.accounts_dashboard_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(
|
||||
context, null /* parent */, null /* authorities*/);
|
||||
}
|
||||
};
|
||||
}
|
@@ -32,11 +32,6 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
@@ -51,6 +46,14 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
public class WorkSoundPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, OnPreferenceChangeListener, LifecycleObserver,
|
||||
OnResume, OnPause {
|
||||
@@ -96,10 +99,8 @@ public class WorkSoundPreferenceController extends AbstractPreferenceController
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY);
|
||||
if (mWorkPreferenceCategory != null) {
|
||||
mWorkPreferenceCategory.setVisible(isAvailable());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,6 +158,18 @@ public class WorkSoundPreferenceController extends AbstractPreferenceController
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNonIndexableKeys(List<String> keys) {
|
||||
if (isAvailable()) {
|
||||
return;
|
||||
}
|
||||
keys.add(KEY_WORK_CATEGORY);
|
||||
keys.add(KEY_WORK_USE_PERSONAL_SOUNDS);
|
||||
keys.add(KEY_WORK_NOTIFICATION_RINGTONE);
|
||||
keys.add(KEY_WORK_PHONE_RINGTONE);
|
||||
keys.add(KEY_WORK_ALARM_RINGTONE);
|
||||
}
|
||||
|
||||
// === Phone & notification ringtone ===
|
||||
|
||||
private boolean shouldShowRingtoneSettings() {
|
||||
|
@@ -159,6 +159,7 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
final List<String> niks = super.getNonIndexableKeys(context);
|
||||
niks.add(KEY_ADD_USER_FROM_LOCK_SCREEN);
|
||||
niks.add(KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE);
|
||||
niks.add(KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER);
|
||||
return niks;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user