Loading src/com/android/settings/core/PreferenceControllerListHelper.java +8 −2 Original line number Diff line number Diff line Loading @@ -67,14 +67,20 @@ public class PreferenceControllerListHelper { try { controller = BasePreferenceController.createInstance(context, controllerName); } catch (IllegalStateException e) { Log.d(TAG, "Could not find Context-only controller for pref: " + controllerName); final String key = metadata.getString(METADATA_KEY); if (TextUtils.isEmpty(key)) { Log.w(TAG, "Controller requires key but it's not defined in xml: " + controllerName); continue; } Log.d(TAG, "Could not find Context-only controller for pref: " + key); controller = BasePreferenceController.createInstance(context, controllerName, key); try { controller = BasePreferenceController.createInstance(context, controllerName, key); } catch (IllegalStateException e2) { Log.w(TAG, "Cannot instantiate controller from reflection: " + controllerName); continue; } } controllers.add(controller); } Loading src/com/android/settings/fuelgauge/BatterySaverController.java +3 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.fuelgauge; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.provider.Settings; import android.support.annotation.VisibleForTesting; Loading Loading @@ -119,7 +120,8 @@ public class BatterySaverController extends TogglePreferenceController mBatterySaverPref.setSummary(getSummary()); } private final ContentObserver mObserver = new ContentObserver(new Handler()) { private final ContentObserver mObserver = new ContentObserver( new Handler(Looper.getMainLooper())) { @Override public void onChange(boolean selfChange) { updateSummary(); Loading src/com/android/settings/fuelgauge/PowerUsageSummary.java +0 −9 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.os.BatteryStats; import android.os.Bundle; import android.provider.SearchIndexableResource; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.text.format.Formatter; import android.util.SparseArray; Loading @@ -33,17 +32,14 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.TextView; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.Settings.HighPowerApplicationsActivity; import com.android.settings.SettingsActivity; import com.android.settings.Utils; import com.android.settings.applications.LayoutPreference; import com.android.settings.applications.manageapplications.ManageApplications; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.display.BatteryPercentagePreferenceController; import com.android.settings.fuelgauge.anomaly.Anomaly; Loading @@ -56,7 +52,6 @@ import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.utils.PowerUtil; import com.android.settingslib.utils.StringUtil; Loading Loading @@ -242,11 +237,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList KEY_BATTERY_TIP, (SettingsActivity) getActivity(), this /* fragment */, this /* BatteryTipListener */); controllers.add(mBatteryTipPreferenceController); BatterySaverController batterySaverController = new BatterySaverController(context); controllers.add(batterySaverController); controllers.add(new BatteryPercentagePreferenceController(context)); lifecycle.addObserver(batterySaverController); return controllers; } Loading src/com/android/settings/search/BaseSearchIndexProvider.java +4 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,10 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { ((BasePreferenceController) controller).updateNonIndexableKeys( nonIndexableKeys); } else { throw new IllegalStateException(controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName()); Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the key non-indexable"); nonIndexableKeys.add(controller.getPreferenceKey()); } } return nonIndexableKeys; Loading tests/robotests/res/xml-mcc998/location_settings.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="fake_title_key" android:title="screen_title" settings:controller="com.android.settings.slices.FakePreferenceController"> <Preference android:key="key" android:title="title" android:icon="@drawable/ic_android" android:summary="summary" settings:controller="com.android.settings.core.BadPreferenceController"/> </PreferenceScreen> No newline at end of file Loading
src/com/android/settings/core/PreferenceControllerListHelper.java +8 −2 Original line number Diff line number Diff line Loading @@ -67,14 +67,20 @@ public class PreferenceControllerListHelper { try { controller = BasePreferenceController.createInstance(context, controllerName); } catch (IllegalStateException e) { Log.d(TAG, "Could not find Context-only controller for pref: " + controllerName); final String key = metadata.getString(METADATA_KEY); if (TextUtils.isEmpty(key)) { Log.w(TAG, "Controller requires key but it's not defined in xml: " + controllerName); continue; } Log.d(TAG, "Could not find Context-only controller for pref: " + key); controller = BasePreferenceController.createInstance(context, controllerName, key); try { controller = BasePreferenceController.createInstance(context, controllerName, key); } catch (IllegalStateException e2) { Log.w(TAG, "Cannot instantiate controller from reflection: " + controllerName); continue; } } controllers.add(controller); } Loading
src/com/android/settings/fuelgauge/BatterySaverController.java +3 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.fuelgauge; import android.content.Context; import android.database.ContentObserver; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.provider.Settings; import android.support.annotation.VisibleForTesting; Loading Loading @@ -119,7 +120,8 @@ public class BatterySaverController extends TogglePreferenceController mBatterySaverPref.setSummary(getSummary()); } private final ContentObserver mObserver = new ContentObserver(new Handler()) { private final ContentObserver mObserver = new ContentObserver( new Handler(Looper.getMainLooper())) { @Override public void onChange(boolean selfChange) { updateSummary(); Loading
src/com/android/settings/fuelgauge/PowerUsageSummary.java +0 −9 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.os.BatteryStats; import android.os.Bundle; import android.provider.SearchIndexableResource; import android.support.annotation.VisibleForTesting; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.text.format.Formatter; import android.util.SparseArray; Loading @@ -33,17 +32,14 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.widget.TextView; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.Settings.HighPowerApplicationsActivity; import com.android.settings.SettingsActivity; import com.android.settings.Utils; import com.android.settings.applications.LayoutPreference; import com.android.settings.applications.manageapplications.ManageApplications; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.display.BatteryPercentagePreferenceController; import com.android.settings.fuelgauge.anomaly.Anomaly; Loading @@ -56,7 +52,6 @@ import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.utils.PowerUtil; import com.android.settingslib.utils.StringUtil; Loading Loading @@ -242,11 +237,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList KEY_BATTERY_TIP, (SettingsActivity) getActivity(), this /* fragment */, this /* BatteryTipListener */); controllers.add(mBatteryTipPreferenceController); BatterySaverController batterySaverController = new BatterySaverController(context); controllers.add(batterySaverController); controllers.add(new BatteryPercentagePreferenceController(context)); lifecycle.addObserver(batterySaverController); return controllers; } Loading
src/com/android/settings/search/BaseSearchIndexProvider.java +4 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,10 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { ((BasePreferenceController) controller).updateNonIndexableKeys( nonIndexableKeys); } else { throw new IllegalStateException(controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName()); Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the key non-indexable"); nonIndexableKeys.add(controller.getPreferenceKey()); } } return nonIndexableKeys; Loading
tests/robotests/res/xml-mcc998/location_settings.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:key="fake_title_key" android:title="screen_title" settings:controller="com.android.settings.slices.FakePreferenceController"> <Preference android:key="key" android:title="title" android:icon="@drawable/ic_android" android:summary="summary" settings:controller="com.android.settings.core.BadPreferenceController"/> </PreferenceScreen> No newline at end of file