Merge "Revert "Settings search - Navigate user to exact page""
This commit is contained in:
committed by
Android (Google) Code Review
commit
244afa02d2
@@ -1,20 +0,0 @@
|
||||
com.android.settings.backup.ToggleBackupSettingFragment
|
||||
com.android.settings.applications.RunningServices
|
||||
com.android.settings.applications.ConvertToFbe
|
||||
com.android.settings.applications.appops.BackgroundCheckSummary
|
||||
com.android.settings.fuelgauge.InactiveApps
|
||||
com.android.settings.ResetNetwork
|
||||
com.android.settings.MasterClear
|
||||
com.android.settings.applications.manageapplications.ManageApplications
|
||||
com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionLocation
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionMicrophone
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionCamera
|
||||
com.android.settings.vpn2.VpnSettings
|
||||
com.android.settings.security.CryptKeeperSettings
|
||||
com.android.settings.TrustedCredentialsSettings
|
||||
com.android.settings.UserCredentialsSettings
|
||||
com.android.settings.applications.defaultapps.DefaultAutofillPicker
|
||||
com.android.phone.NetworkSelectSetting
|
||||
com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment
|
||||
com.android.settings.nfc.AndroidBeam
|
||||
@@ -17,6 +17,7 @@ com.android.settings.applications.AppLaunchSettings
|
||||
com.android.settings.applications.AppStorageSettings
|
||||
com.android.settings.applications.ConfirmConvertToFbe
|
||||
com.android.settings.applications.ProcessStatsDetail
|
||||
com.android.settings.applications.ProcessStatsSummary
|
||||
com.android.settings.applications.ProcessStatsUi
|
||||
com.android.settings.applications.RunningServices
|
||||
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
|
||||
@@ -25,6 +26,7 @@ com.android.settings.applications.UsageAccessDetails
|
||||
com.android.settings.backup.ToggleBackupSettingFragment
|
||||
com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment
|
||||
com.android.settings.bluetooth.BluetoothDeviceDetailsFragment
|
||||
com.android.settings.bluetooth.BluetoothPairingDetail
|
||||
com.android.settings.bluetooth.DevicePickerFragment
|
||||
com.android.settings.dashboard.profileselector.ProfileSelectAccountFragment
|
||||
com.android.settings.dashboard.profileselector.ProfileSelectManageApplications
|
||||
@@ -32,19 +34,24 @@ com.android.settings.dashboard.profileselector.ProfileSelectLocationFragment
|
||||
com.android.settings.datausage.AppDataUsage
|
||||
com.android.settings.datausage.DataUsageList
|
||||
com.android.settings.datausage.DataUsageSummary
|
||||
com.android.settings.datetime.timezone.TimeZoneSettings
|
||||
com.android.settings.development.compat.PlatformCompatDashboard
|
||||
com.android.settings.deviceinfo.PrivateVolumeSettings
|
||||
com.android.settings.deviceinfo.PublicVolumeSettings
|
||||
com.android.settings.deviceinfo.StorageProfileFragment
|
||||
com.android.settings.deviceinfo.legal.ModuleLicensesDashboard
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionCamera
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionLocation
|
||||
com.android.settings.enterprise.ApplicationListFragment$AdminGrantedPermissionMicrophone
|
||||
com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages
|
||||
com.android.settings.enterprise.EnterpriseSetDefaultAppsListFragment
|
||||
com.android.settings.fuelgauge.AdvancedPowerUsageDetail
|
||||
com.android.settings.fuelgauge.InactiveApps
|
||||
com.android.settings.fuelgauge.RestrictedAppDetails
|
||||
com.android.settings.IccLockSettings
|
||||
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
|
||||
com.android.settings.inputmethod.KeyboardLayoutPickerFragment
|
||||
com.android.settings.inputmethod.SpellCheckersSettings
|
||||
com.android.settings.location.LocationPersonalSettings
|
||||
com.android.settings.location.LocationWorkProfileSettings
|
||||
com.android.settings.network.ApnEditor
|
||||
@@ -81,7 +88,10 @@ com.android.settings.wifi.ChangeWifiStateDetails
|
||||
com.android.settings.wifi.calling.WifiCallingSettingsForSub
|
||||
com.android.settings.wifi.details.WifiNetworkDetailsFragment
|
||||
com.android.settings.wifi.dpp.WifiNetworkListFragment
|
||||
com.android.settings.wifi.p2p.WifiP2pSettings
|
||||
com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings
|
||||
com.android.settings.wifi.WifiInfo
|
||||
com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessDetails
|
||||
com.android.settings.wifi.details2.WifiNetworkDetailsFragment2
|
||||
com.android.settings.wifi.savedaccesspoints2.SavedAccessPointsWifiSettings2
|
||||
com.android.settings.dashboard.profileselector.ProfileSelectRecentLocationRequestFragment
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(mContext);
|
||||
|
||||
assertThat(niks).containsAllOf(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
||||
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
||||
KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.android.settings.core.BasePreferenceControllerSignatureInspector;
|
||||
import com.android.settings.core.instrumentation.InstrumentableFragmentCodeInspector;
|
||||
import com.android.settings.search.FragmentSearchIndexableCodeInspector;
|
||||
import com.android.settings.search.SearchIndexProviderCodeInspector;
|
||||
import com.android.settings.slices.SliceControllerInXmlCodeInspector;
|
||||
|
||||
@@ -72,9 +71,4 @@ public class CodeInspectionTest {
|
||||
public void runLifecycleObserverInspection() {
|
||||
new LifecycleObserverCodeInspector(mClasses).run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runFragmentIndexableInspection() throws Exception {
|
||||
new FragmentSearchIndexableCodeInspector(mClasses).run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_FRAGMENT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settings.core.codeinspection.CodeInspector;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.search.SearchIndexableData;
|
||||
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link CodeInspector} to ensure preferences with fragments implement search components correctly.
|
||||
*/
|
||||
public class FragmentSearchIndexableCodeInspector extends CodeInspector {
|
||||
|
||||
private final String mErrorNonIndexFragments =
|
||||
"The following fragments were used by 'android:fragment=Fragment_Class_Name' in "
|
||||
+ "corresponding caller preference Xml. This preference won't be searchable, "
|
||||
+ "the fragment should implement SearchIndexable for Settings Search. If it "
|
||||
+ "should not be searchable, add the fragment's classname to "
|
||||
+ "grandfather_fragment_not_searchable. Fragments:\n";
|
||||
|
||||
private final Context mContext;
|
||||
private final List<String> mXmlDeclaredFragments = new ArrayList<>();
|
||||
private final List<String> mGrandfatherNotSearchIndesable = new ArrayList<>();
|
||||
|
||||
public FragmentSearchIndexableCodeInspector(List<Class<?>> classes) throws Exception {
|
||||
super(classes);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
|
||||
initDeclaredFragments();
|
||||
initializeGrandfatherList(mGrandfatherNotSearchIndesable,
|
||||
"grandfather_fragment_not_searchable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Class<?> clazz : mClasses) {
|
||||
if (!isConcreteSettingsClass(clazz)) {
|
||||
// Only care about non-abstract classes.
|
||||
continue;
|
||||
}
|
||||
if (!InstrumentedPreferenceFragment.class.isAssignableFrom(clazz)) {
|
||||
// Only care about InstrumentedPreferenceFragment
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
clazz.getField("SEARCH_INDEX_DATA_PROVIDER");
|
||||
mXmlDeclaredFragments.remove(clazz.getName());
|
||||
continue;
|
||||
} catch (NoSuchFieldException e) {
|
||||
}
|
||||
|
||||
if (SearchIndexable.class.isAssignableFrom(clazz)) {
|
||||
mXmlDeclaredFragments.remove(clazz.getName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
mXmlDeclaredFragments.removeAll(mGrandfatherNotSearchIndesable);
|
||||
|
||||
final String missingFragmentError =
|
||||
buildErrorMessage(mErrorNonIndexFragments, mXmlDeclaredFragments);
|
||||
|
||||
assertWithMessage(missingFragmentError).that(mXmlDeclaredFragments).isEmpty();
|
||||
}
|
||||
|
||||
private String buildErrorMessage(String errorSummary, List<String> errorClasses) {
|
||||
final StringBuilder error = new StringBuilder(errorSummary);
|
||||
for (String c : errorClasses) {
|
||||
error.append(c).append("\n");
|
||||
}
|
||||
return error.toString();
|
||||
}
|
||||
|
||||
private void initDeclaredFragments() throws IOException, XmlPullParserException {
|
||||
final List<Integer> xmlResources = getIndexableXml();
|
||||
for (int xmlResId : xmlResources) {
|
||||
final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
|
||||
xmlResId, PreferenceXmlParserUtils.MetadataFlag.FLAG_NEED_FRAGMENT);
|
||||
for (Bundle bundle : metadata) {
|
||||
final String fragmentClassName = bundle.getString(METADATA_FRAGMENT);
|
||||
if (TextUtils.isEmpty(fragmentClassName)) {
|
||||
continue;
|
||||
}
|
||||
if (!mXmlDeclaredFragments.contains(fragmentClassName)) {
|
||||
mXmlDeclaredFragments.add(fragmentClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
// We definitely have some fragments in xml, so assert not-empty here as a proxy to
|
||||
// make sure the parser didn't fail
|
||||
assertThat(mXmlDeclaredFragments).isNotEmpty();
|
||||
}
|
||||
|
||||
private List<Integer> getIndexableXml() {
|
||||
final List<Integer> xmlResSet = new ArrayList<>();
|
||||
|
||||
final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(
|
||||
mContext).getSearchFeatureProvider().getSearchIndexableResources()
|
||||
.getProviderValues();
|
||||
|
||||
for (SearchIndexableData bundle : bundles) {
|
||||
Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
|
||||
|
||||
if (provider == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<SearchIndexableResource> resources = provider.getXmlResourcesToIndex(mContext,
|
||||
true);
|
||||
|
||||
if (resources == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SearchIndexableResource resource : resources) {
|
||||
// Add '0's anyway. It won't break the test.
|
||||
xmlResSet.add(resource.xmlResId);
|
||||
}
|
||||
}
|
||||
return xmlResSet;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user