Enable some settings pages to use paralleled-loading method
- Here these pages include AppInfoDashboardFragment, ConnectedDeviceDashboardFragment,
DevelopmentSettingsDashboardFragment, NetworkDashboardFragment, ConfigureNotificationSettings.
- The TimeSpentInAppPreferenceController use the LiveDataController.
Fixes: 135299529
Bug: 137558156
Test: compilation
Change-Id: I455a16536c9966184f1b2bd81d1f1217f3e09f9d
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index a1736b2..9931f35 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -64,6 +64,7 @@
<Preference
android:key="connection_preferences"
android:title="@string/connected_device_connections_title"
+ android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment"
settings:allowDividerAbove="true"
settings:controller="com.android.settings.connecteddevice.AdvancedConnectedDeviceController"/>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 6dcc125..bed838c 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -38,6 +38,7 @@
<Preference
android:key="bug_report_handler"
android:title="@string/bug_report_handler_title"
+ android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.bugreporthandler.BugReportHandlerPicker" />
<Preference
@@ -64,6 +65,7 @@
<ListPreference
android:key="hdcp_checking"
android:title="@string/hdcp_checking_title"
+ android:summary="@string/summary_placeholder"
android:dialogTitle="@string/hdcp_checking_dialog_title"
android:entries="@array/hdcp_checking_titles"
android:entryValues="@array/hdcp_checking_values" />
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 8b1f96f..dff6d6d 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -138,7 +138,10 @@
public void onAttach(Context context) {
super.onAttach(context);
final String packageName = getPackageName();
- use(TimeSpentInAppPreferenceController.class).setPackageName(packageName);
+ final TimeSpentInAppPreferenceController timeSpentInAppPreferenceController = use(
+ TimeSpentInAppPreferenceController.class);
+ timeSpentInAppPreferenceController.setPackageName(packageName);
+ timeSpentInAppPreferenceController.initLifeCycleOwner(this);
use(AppDataUsagePreferenceController.class).setParentFragment(this);
final AppInstallerInfoPreferenceController installer =
@@ -285,6 +288,11 @@
return controllers;
}
+ @Override
+ protected boolean isParalleledControllers() {
+ return true;
+ }
+
void addToCallbackList(Callback callback) {
if (callback != null) {
mCallbacks.add(callback);
diff --git a/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java b/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
index b1bbd06..27d9026 100644
--- a/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceController.java
@@ -29,13 +29,15 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.applications.ApplicationFeatureProvider;
-import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.LiveDataController;
import com.android.settings.overlay.FeatureFactory;
import java.util.List;
-public class TimeSpentInAppPreferenceController extends BasePreferenceController {
-
+/**
+ * To Retrieve the time consumption of the application.
+ */
+public class TimeSpentInAppPreferenceController extends LiveDataController {
@VisibleForTesting
static final Intent SEE_TIME_IN_APP_TEMPLATE = new Intent(Settings.ACTION_APP_USAGE_SETTINGS);
@@ -85,7 +87,7 @@
}
@Override
- public CharSequence getSummary() {
+ protected CharSequence getSummaryTextInBackground() {
return mAppFeatureProvider.getTimeSpentInApp(mPackageName);
}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index ce980e0..5dd769d 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -50,6 +50,11 @@
}
@Override
+ protected boolean isParalleledControllers() {
+ return true;
+ }
+
+ @Override
public int getHelpResource() {
return R.string.help_url_connected_devices;
}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 878d442..7da58a7 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -361,6 +361,11 @@
return mPreferenceControllers;
}
+ @Override
+ protected boolean isParalleledControllers() {
+ return true;
+ }
+
private void registerReceivers() {
LocalBroadcastManager.getInstance(getContext())
.registerReceiver(mEnableAdbReceiver, new IntentFilter(
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index ad3df33..db704ae 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -86,6 +86,11 @@
this /* fragment */, this /* mobilePlanHost */);
}
+ @Override
+ protected boolean isParalleledControllers() {
+ return true;
+ }
+
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Lifecycle lifecycle, MetricsFeatureProvider metricsFeatureProvider, Fragment fragment,
MobilePlanPreferenceHost mobilePlanHost) {
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 0a9a5b1..6801a80 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -90,6 +90,11 @@
return buildPreferenceControllers(context, app, this);
}
+ @Override
+ protected boolean isParalleledControllers() {
+ return true;
+ }
+
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Application app, Fragment host) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceControllerTest.java
index e1da707..7750256 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/TimeSpentInAppPreferenceControllerTest.java
@@ -119,8 +119,8 @@
}
@Test
- public void getSummary_shouldQueryAppFeatureProvider() {
- mController.getSummary();
+ public void getSummaryTextInBackground_shouldQueryAppFeatureProvider() {
+ mController.getSummaryTextInBackground();
verify(mFeatureFactory.applicationFeatureProvider).getTimeSpentInApp(
nullable(String.class));