Merge "Data plan setting in SystemUI quick settings." into oc-mr1-dev
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index 81ec6a7..4e728f6 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -19,13 +19,14 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.os.SystemProperties;
import android.service.quicksettings.Tile;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
-
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.net.DataUsageController;
@@ -38,7 +39,6 @@
import com.android.systemui.qs.CellTileView;
import com.android.systemui.qs.CellTileView.SignalIcon;
import com.android.systemui.qs.QSHost;
-import com.android.systemui.qs.SignalTileView;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
@@ -46,8 +46,17 @@
/** Quick settings tile: Cellular **/
public class CellularTile extends QSTileImpl<SignalState> {
- static final Intent CELLULAR_SETTINGS = new Intent().setComponent(new ComponentName(
- "com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
+ private static final ComponentName CELLULAR_SETTING_COMPONENT = new ComponentName(
+ "com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity");
+ private static final ComponentName DATA_PLAN_CELLULAR_COMPONENT = new ComponentName(
+ "com.android.settings", "com.android.settings.Settings$DataPlanUsageSummaryActivity");
+
+ private static final Intent CELLULAR_SETTINGS =
+ new Intent().setComponent(CELLULAR_SETTING_COMPONENT);
+ private static final Intent DATA_PLAN_CELLULAR_SETTINGS =
+ new Intent().setComponent(DATA_PLAN_CELLULAR_COMPONENT);
+
+ private static final String ENABLE_SETTINGS_DATA_PLAN = "enable.settings.data.plan";
private final NetworkController mController;
private final DataUsageController mDataController;
@@ -90,7 +99,7 @@
@Override
public Intent getLongClickIntent() {
- return CELLULAR_SETTINGS;
+ return getCellularSettingIntent(mContext);
}
@Override
@@ -103,7 +112,9 @@
if (mDataController.isMobileDataSupported()) {
showDetail(true);
} else {
- mActivityStarter.postStartActivityDismissingKeyguard(CELLULAR_SETTINGS, 0);
+ mActivityStarter
+ .postStartActivityDismissingKeyguard(getCellularSettingIntent(mContext),
+ 0 /* delay */);
}
}
@@ -240,7 +251,28 @@
public void setMobileDataEnabled(boolean enabled) {
mDetailAdapter.setMobileDataEnabled(enabled);
}
- };
+ }
+
+ static Intent getCellularSettingIntent(Context context) {
+ // TODO(b/62349208): We should replace feature flag check below with data plans
+ // availability check. If the data plans are available we display the data plans usage
+ // summary otherwise we display data usage summary without data plans.
+ boolean isDataPlanFeatureEnabled =
+ SystemProperties.getBoolean(ENABLE_SETTINGS_DATA_PLAN, false /* default */);
+ context.getPackageManager()
+ .setComponentEnabledSetting(
+ DATA_PLAN_CELLULAR_COMPONENT,
+ isDataPlanFeatureEnabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+ context.getPackageManager()
+ .setComponentEnabledSetting(
+ CELLULAR_SETTING_COMPONENT,
+ isDataPlanFeatureEnabled ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP);
+ return isDataPlanFeatureEnabled ? DATA_PLAN_CELLULAR_SETTINGS : CELLULAR_SETTINGS;
+ }
private final class CellularDetailAdapter implements DetailAdapter {
@@ -258,7 +290,7 @@
@Override
public Intent getSettingsIntent() {
- return CELLULAR_SETTINGS;
+ return getCellularSettingIntent(mContext);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
index b796451..8b62beb 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
@@ -14,18 +14,16 @@
package com.android.systemui.qs.tiles;
-import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.service.quicksettings.Tile;
import android.widget.Switch;
-
-import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.R;
-import com.android.systemui.qs.QSHost;
import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.DataSaverController;
@@ -57,9 +55,8 @@
@Override
public Intent getLongClickIntent() {
- return CellularTile.CELLULAR_SETTINGS;
+ return CellularTile.getCellularSettingIntent(mContext);
}
-
@Override
protected void handleClick() {
if (mState.value
@@ -73,12 +70,7 @@
dialog.setTitle(com.android.internal.R.string.data_saver_enable_title);
dialog.setMessage(com.android.internal.R.string.data_saver_description);
dialog.setPositiveButton(com.android.internal.R.string.data_saver_enable_button,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- toggleDataSaver();
- }
- });
+ (OnClickListener) (dialogInterface, which) -> toggleDataSaver());
dialog.setNegativeButton(com.android.internal.R.string.cancel, null);
dialog.setShowForAllUsers(true);
dialog.show();
@@ -126,4 +118,4 @@
public void onDataSaverChanged(boolean isDataSaving) {
refreshState(isDataSaving);
}
-}
\ No newline at end of file
+}