Merge "Clean up Contextual Wifi card" into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 26386c5..8ec5b3d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2864,11 +2864,10 @@
</activity>
<activity
- android:name="Settings$DevelopmentSettingsDashboardActivity"
+ android:name="Settings$DevelopmentSettingsActivity"
android:label="@string/development_settings_title"
android:icon="@drawable/ic_settings_development"
- android:exported="true"
- android:enabled="false">
+ android:exported="true">
<intent-filter android:priority="1">
<action android:name="android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
<action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
@@ -2879,35 +2878,8 @@
<action android:name="com.android.settings.action.SETTINGS" />
<action android:name="com.android.intent.action.SHOW_CONTRAST_DIALOG" />
</intent-filter>
- <meta-data android:name="com.android.settings.order" android:value="-40"/>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.system" />
- <meta-data android:name="com.android.settings.summary"
- android:resource="@string/summary_empty"/>
- <meta-data android:name="com.android.settings.icon"
- android:resource="@drawable/ic_settings_development" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.development.DevelopmentSettingsDashboardFragment" />
- <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
- android:value="@string/menu_key_system"/>
- <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
- android:value="true" />
- </activity>
-
- <!-- The opposite of DevelopmentSettingsActivity, it's no-op and only enabled when the real
- activity is disabled to be CTS compliant. -->
- <activity
- android:name=".development.DevelopmentSettingsDisabledActivity"
- android:icon="@drawable/ic_settings_development"
- android:label="@string/development_settings_title"
- android:excludeFromRecents="true"
- android:exported="true"
- android:theme="@style/Transparent">
- <intent-filter android:priority="-1">
- <action android:name="android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
- <action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
</activity>
<activity
@@ -4231,11 +4203,6 @@
android:value="@string/menu_key_system"/>
</activity-alias>
- <provider
- android:name=".dashboard.SummaryProvider"
- android:authorities="${applicationId}.dashboard.SummaryProvider">
- </provider>
-
<activity android:name=".backup.UserBackupSettingsActivity"
android:label="@string/privacy_settings_title"
android:exported="true"
diff --git a/res/values/config.xml b/res/values/config.xml
index 73ee108..c30a047 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -349,9 +349,6 @@
Fetch resource from overlay package directly if this is set. -->
<string name="config_regulatory_info_overlay_package_name" translatable="false" />
- <!-- Whether to show a preference item for mobile plan -->
- <bool name="config_show_mobile_plan">true</bool>
-
<!-- Whether none security option is hide or not (country specific). -->
<bool name="config_hide_none_security_option">false</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4a35932..8dca8d0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3453,9 +3453,6 @@
<!-- Wireless controls, item title to go into the network settings -->
<string name="network_settings_title">Mobile network</string>
- <!-- Mobile plan [CHAR LIMIT=35]-->
- <string name="manage_mobile_plan_title" translatable="true">Mobile plan</string>
-
<!-- SMS Application [CHAR LIMIT=35]-->
<string name="sms_application_title" translatable="true">SMS app</string>
<string name="sms_change_default_dialog_title" translatable="true">Change SMS app?</string>
@@ -3469,18 +3466,6 @@
<!-- Wifi Assistant request message. This message asks the user if it is okay for an app to become the Wifi Assistant. [CHAR LIMIT=100] -->
<string name="network_scorer_change_active_no_previous_dialog_text">Use <xliff:g id="new_app">%s</xliff:g> to manage your network connections?</string>
- <!-- The SIM operator is not known [CHAR_ LIMIT=50]-->
- <string name="mobile_unknown_sim_operator" translatable="true">Unknown SIM operator</string>
-
- <!-- There is no mobile provisiong website for the operator which is the firat parameter [CHAR_ LIMIT=50]-->
- <string name="mobile_no_provisioning_url"><xliff:g id="operator">%1$s</xliff:g> has no known provisioning website</string>
-
- <!-- Ask user to insert a SIM card [CHAR_ LIMIT=50]-->
- <string name="mobile_insert_sim_card" translatable="true">Please insert SIM card and restart</string>
-
- <!-- Ask user to connect to the internet [CHAR_ LIMIT=50]-->
- <string name="mobile_connect_to_internet" translatable="true">Please connect to the internet</string>
-
<!-- Location settings screen, sub category for recent location requests [CHAR LIMIT=42] -->
<string name="location_category_recent_location_requests">Recent location requests</string>
diff --git a/res/xml/network_provider_internet.xml b/res/xml/network_provider_internet.xml
index b055ea3..8e9d45d 100644
--- a/res/xml/network_provider_internet.xml
+++ b/res/xml/network_provider_internet.xml
@@ -59,15 +59,6 @@
settings:userRestriction="no_airplane_mode"/>
<com.android.settingslib.RestrictedPreference
- android:key="manage_mobile_plan"
- android:title="@string/manage_mobile_plan_title"
- android:persistent="false"
- android:order="19"
- settings:userRestriction="no_config_mobile_networks"
- settings:isPreferenceVisible="@bool/config_show_sim_info"
- settings:useAdminDisabledSummary="true" />
-
- <com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.network.tether.TetherSettings"
android:key="tether_settings"
android:title="@string/tether_settings_title_all"
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 54dc195..a2cb8fa 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -100,6 +100,11 @@
android:fragment="com.android.settings.users.UserSettings"
settings:controller="com.android.settings.users.MultiUserPreferenceController"/>
+ <com.android.settings.spa.preference.ComposePreference
+ android:key="developer_options"
+ android:order="-40"
+ settings:controller="com.android.settings.system.DeveloperOptionsController"/>
+
<Preference
android:key="reset_dashboard"
android:title="@string/reset_dashboard_title"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 49b2174..64e3244 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -134,7 +134,7 @@
public static class HighPowerApplicationsActivity extends SettingsActivity { /* empty */ }
public static class BackgroundCheckSummaryActivity extends SettingsActivity { /* empty */ }
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
- public static class DevelopmentSettingsDashboardActivity extends SettingsActivity { /* empty */ }
+ public static class DevelopmentSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityDetailsSettingsActivity extends SettingsActivity { /* empty */ }
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3b0dd40..27a87f3 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -48,7 +48,6 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
@@ -70,7 +69,6 @@
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
-import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.drawer.DashboardCategory;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -174,8 +172,6 @@
private CharSequence mInitialTitle;
private int mInitialTitleResId;
- private BroadcastReceiver mDevelopmentSettingsListener;
-
private boolean mBatteryPresent = true;
private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
@Override
@@ -614,15 +610,6 @@
super.onResume();
setActionBarStatus();
- mDevelopmentSettingsListener = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- updateTilesList();
- }
- };
- LocalBroadcastManager.getInstance(this).registerReceiver(mDevelopmentSettingsListener,
- new IntentFilter(DevelopmentSettingsEnabler.DEVELOPMENT_SETTINGS_CHANGED_ACTION));
-
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
updateTilesList();
@@ -631,8 +618,6 @@
@Override
protected void onPause() {
super.onPause();
- LocalBroadcastManager.getInstance(this).unregisterReceiver(mDevelopmentSettingsListener);
- mDevelopmentSettingsListener = null;
unregisterReceiver(mBatteryInfoReceiver);
}
@@ -781,13 +766,6 @@
Utils.isBandwidthControlEnabled(), isAdmin)
|| somethingChanged;
- final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
- && !Utils.isMonkeyRunning();
- somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
- Settings.DevelopmentSettingsDashboardActivity.class.getName()),
- showDev, isAdmin)
- || somethingChanged;
-
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Settings.WifiDisplaySettingsActivity.class.getName()),
WifiDisplaySettings.isAvailable(this), isAdmin)
diff --git a/src/com/android/settings/dashboard/SummaryProvider.java b/src/com/android/settings/dashboard/SummaryProvider.java
deleted file mode 100644
index cd388b9..0000000
--- a/src/com/android/settings/dashboard/SummaryProvider.java
+++ /dev/null
@@ -1,78 +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.dashboard;
-
-import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-
-import com.android.settings.backup.BackupSettingsHelper;
-
-/** Provide preference summary for injected items. */
-public class SummaryProvider extends ContentProvider {
- private static final String BACKUP = "backup";
- private static final String USER = "user";
-
- @Override
- public Bundle call(String method, String uri, Bundle extras) {
- final Bundle bundle = new Bundle();
- switch (method) {
- case BACKUP:
- bundle.putString(META_DATA_PREFERENCE_SUMMARY,
- new BackupSettingsHelper(getContext()).getSummary());
- break;
- default:
- throw new IllegalArgumentException("Unknown Uri format: " + uri);
- }
- return bundle;
- }
-
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getType(Uri uri) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 9c8c186..4c8b2dc 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -47,6 +47,7 @@
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -230,6 +231,12 @@
getActivity().finish();
return;
}
+ Context context = requireContext();
+ if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)) {
+ Toast.makeText(context, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT)
+ .show();
+ finish();
+ }
}
@Override
diff --git a/src/com/android/settings/development/DevelopmentSettingsDisabledActivity.java b/src/com/android/settings/development/DevelopmentSettingsDisabledActivity.java
deleted file mode 100644
index 9ea24da..0000000
--- a/src/com/android/settings/development/DevelopmentSettingsDisabledActivity.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 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.development;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.Toast;
-
-import com.android.settings.R;
-
-public class DevelopmentSettingsDisabledActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Toast.makeText(this, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT).show();
- finish();
- }
-}
diff --git a/src/com/android/settings/network/MobilePlanPreferenceController.java b/src/com/android/settings/network/MobilePlanPreferenceController.java
deleted file mode 100644
index fcca5e6..0000000
--- a/src/com/android/settings/network/MobilePlanPreferenceController.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2016 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.network;
-
-import static android.content.Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.os.UserHandle.myUserId;
-import static android.os.UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
-
-import static com.android.settingslib.RestrictedLockUtilsInternal.hasBaseUserRestriction;
-
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.Utils;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnCreate;
-import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
-
-import java.util.List;
-
-public class MobilePlanPreferenceController extends AbstractPreferenceController
- implements PreferenceControllerMixin, LifecycleObserver, OnCreate, OnSaveInstanceState {
-
- public interface MobilePlanPreferenceHost {
- void showMobilePlanMessageDialog();
- }
-
- public static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
-
- private static final String TAG = "MobilePlanPrefContr";
- static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
- private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
-
- private final UserManager mUserManager;
- private final boolean mIsSecondaryUser;
- private final MobilePlanPreferenceHost mHost;
-
- private ConnectivityManager mCm;
- private TelephonyManager mTm;
-
- private String mMobilePlanDialogMessage;
-
- public MobilePlanPreferenceController(Context context,
- MobilePlanPreferenceHost host) {
- super(context);
- mHost = host;
- mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- mIsSecondaryUser = !mUserManager.isAdminUser();
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (mHost != null && KEY_MANAGE_MOBILE_PLAN.equals(preference.getKey())) {
- mMobilePlanDialogMessage = null;
- onManageMobilePlanClick();
- return true;
- }
- return false;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- if (savedInstanceState != null) {
- mMobilePlanDialogMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
- }
- Log.d(TAG, "onCreate: mMobilePlanDialogMessage=" + mMobilePlanDialogMessage);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- if (!TextUtils.isEmpty(mMobilePlanDialogMessage)) {
- outState.putString(SAVED_MANAGE_MOBILE_PLAN_MSG, mMobilePlanDialogMessage);
- }
- }
-
- public String getMobilePlanDialogMessage() {
- return mMobilePlanDialogMessage;
- }
-
- public void setMobilePlanDialogMessage(String messasge) {
- mMobilePlanDialogMessage = messasge;
- }
-
- @Override
- public boolean isAvailable() {
- final boolean isPrefAllowedOnDevice = mContext.getResources().getBoolean(
- com.android.settings.R.bool.config_show_mobile_plan);
- final boolean isPrefAllowedForUser = !mIsSecondaryUser
- && !Utils.isWifiOnly(mContext)
- && !hasBaseUserRestriction(mContext, DISALLOW_CONFIG_MOBILE_NETWORKS, myUserId());
- return isPrefAllowedForUser && isPrefAllowedOnDevice;
- }
- @Override
- public String getPreferenceKey() {
- return KEY_MANAGE_MOBILE_PLAN;
- }
-
- private void onManageMobilePlanClick() {
- Resources resources = mContext.getResources();
- NetworkInfo ni = mCm.getActiveNetworkInfo();
- if (mTm.hasIccCard() && (ni != null)) {
- // Check for carrier apps that can handle provisioning first
- Intent provisioningIntent = new Intent(Intent.ACTION_CARRIER_SETUP);
- List<String> carrierPackages =
- mTm.getCarrierPackageNamesForIntent(provisioningIntent);
- if (carrierPackages != null && !carrierPackages.isEmpty()) {
- if (carrierPackages.size() != 1) {
- Log.w(TAG, "Multiple matching carrier apps found, launching the first.");
- }
- provisioningIntent.setPackage(carrierPackages.get(0));
- mContext.startActivity(provisioningIntent);
- return;
- }
-
- // Get provisioning URL
- String url = mTm.getMobileProvisioningUrl();
- if (!TextUtils.isEmpty(url)) {
- Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
- Intent.CATEGORY_APP_BROWSER);
- intent.setData(Uri.parse(url));
- intent.setFlags(FLAG_ACTIVITY_BROUGHT_TO_FRONT | FLAG_ACTIVITY_NEW_TASK);
- try {
- mContext.startActivity(intent);
- } catch (ActivityNotFoundException e) {
- Log.w(TAG, "onManageMobilePlanClick: startActivity failed" + e);
- }
- } else {
- // No provisioning URL
- String operatorName = mTm.getSimOperatorName();
- if (TextUtils.isEmpty(operatorName)) {
- // Use NetworkOperatorName as second choice in case there is no
- // SPN (Service Provider Name on the SIM). Such as with T-mobile.
- operatorName = mTm.getNetworkOperatorName();
- if (TextUtils.isEmpty(operatorName)) {
- mMobilePlanDialogMessage =
- resources.getString(R.string.mobile_unknown_sim_operator);
- } else {
- mMobilePlanDialogMessage = resources.getString(
- R.string.mobile_no_provisioning_url, operatorName);
- }
- } else {
- mMobilePlanDialogMessage =
- resources.getString(R.string.mobile_no_provisioning_url, operatorName);
- }
- }
- } else if (mTm.hasIccCard() == false) {
- // No sim card
- mMobilePlanDialogMessage = resources.getString(R.string.mobile_insert_sim_card);
- } else {
- // NetworkInfo is null, there is no connection
- mMobilePlanDialogMessage = resources.getString(R.string.mobile_connect_to_internet);
- }
- if (!TextUtils.isEmpty(mMobilePlanDialogMessage)) {
- Log.d(TAG, "onManageMobilePlanClick: message=" + mMobilePlanDialogMessage);
- if (mHost != null) {
- mHost.showMobilePlanMessageDialog();
- } else {
- Log.d(TAG, "Missing host fragment, cannot show message dialog.");
- }
- }
- }
-}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 4790c65..4fcbacf 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -15,27 +15,19 @@
*/
package com.android.settings.network;
-import static com.android.settings.network.MobilePlanPreferenceController.MANAGE_MOBILE_PLAN_DIALOG_ID;
-
-import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.util.Log;
-import androidx.appcompat.app.AlertDialog;
-import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import com.android.settings.R;
import com.android.settings.SettingsDumpService;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
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.search.SearchIndexable;
@@ -44,7 +36,7 @@
@SearchIndexable
public class NetworkDashboardFragment extends DashboardFragment implements
- MobilePlanPreferenceHost, OnActivityResultListener {
+ OnActivityResultListener {
private static final String TAG = "NetworkDashboardFrag";
@@ -84,15 +76,12 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getSettingsLifecycle(), mMetricsFeatureProvider,
- this /* fragment */, this /* mobilePlanHost */, this /* LifecycleOwner */);
+ return buildPreferenceControllers(context, getSettingsLifecycle(),
+ this /* LifecycleOwner */);
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- Lifecycle lifecycle, MetricsFeatureProvider metricsFeatureProvider, Fragment fragment,
- MobilePlanPreferenceHost mobilePlanHost, LifecycleOwner lifecycleOwner) {
- final MobilePlanPreferenceController mobilePlanPreferenceController =
- new MobilePlanPreferenceController(context, mobilePlanHost);
+ Lifecycle lifecycle, LifecycleOwner lifecycleOwner) {
final InternetPreferenceController internetPreferenceController =
new InternetPreferenceController(context, lifecycle, lifecycleOwner);
@@ -102,7 +91,6 @@
new PrivateDnsPreferenceController(context);
if (lifecycle != null) {
- lifecycle.addObserver(mobilePlanPreferenceController);
lifecycle.addObserver(vpnPreferenceController);
lifecycle.addObserver(privateDnsPreferenceController);
}
@@ -113,7 +101,6 @@
controllers.add(new TetherPreferenceController(context, lifecycle));
controllers.add(vpnPreferenceController);
controllers.add(new ProxyPreferenceController(context));
- controllers.add(mobilePlanPreferenceController);
if (internetPreferenceController != null) {
controllers.add(internetPreferenceController);
}
@@ -126,36 +113,6 @@
return controllers;
}
- @Override
- public void showMobilePlanMessageDialog() {
- showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID);
- }
-
- @Override
- public Dialog onCreateDialog(int dialogId) {
- Log.d(TAG, "onCreateDialog: dialogId=" + dialogId);
- switch (dialogId) {
- case MANAGE_MOBILE_PLAN_DIALOG_ID:
- final MobilePlanPreferenceController controller =
- use(MobilePlanPreferenceController.class);
- return new AlertDialog.Builder(getActivity())
- .setMessage(controller.getMobilePlanDialogMessage())
- .setCancelable(false)
- .setPositiveButton(com.android.internal.R.string.ok,
- (dialog, id) -> controller.setMobilePlanDialogMessage(null))
- .create();
- }
- return super.onCreateDialog(dialogId);
- }
-
- @Override
- public int getDialogMetricsCategory(int dialogId) {
- if (MANAGE_MOBILE_PLAN_DIALOG_ID == dialogId) {
- return SettingsEnums.DIALOG_MANAGE_MOBILE_PLAN;
- }
- return 0;
- }
-
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -173,20 +130,7 @@
public List<AbstractPreferenceController> createPreferenceControllers(Context
context) {
return buildPreferenceControllers(context, null /* lifecycle */,
- null /* metricsFeatureProvider */, null /* fragment */,
- null /* mobilePlanHost */, null /* LifecycleOwner */);
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
-
- MobilePlanPreferenceController mppc =
- new MobilePlanPreferenceController(context, null);
- if (!mppc.isAvailable()) {
- keys.add(MobilePlanPreferenceController.KEY_MANAGE_MOBILE_PLAN);
- }
- return keys;
+ null /* LifecycleOwner */);
}
};
}
diff --git a/src/com/android/settings/system/DeveloperOptionsController.kt b/src/com/android/settings/system/DeveloperOptionsController.kt
new file mode 100644
index 0000000..fe7fb4d
--- /dev/null
+++ b/src/com/android/settings/system/DeveloperOptionsController.kt
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2023 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.system
+
+import android.app.settings.SettingsEnums
+import android.content.Context
+import android.os.Build
+import android.os.UserManager
+import android.provider.Settings
+import androidx.annotation.VisibleForTesting
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.res.vectorResource
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.android.settings.R
+import com.android.settings.core.SubSettingLauncher
+import com.android.settings.development.DevelopmentSettingsDashboardFragment
+import com.android.settings.spa.preference.ComposePreferenceController
+import com.android.settingslib.spa.widget.preference.PreferenceModel
+import com.android.settingslib.spa.widget.ui.SettingsIcon
+import com.android.settingslib.spaprivileged.model.enterprise.Restrictions
+import com.android.settingslib.spaprivileged.settingsprovider.settingsGlobalBooleanFlow
+import com.android.settingslib.spaprivileged.template.preference.RestrictedPreference
+
+class DeveloperOptionsController(context: Context, preferenceKey: String) :
+ ComposePreferenceController(context, preferenceKey) {
+
+ override fun getAvailabilityStatus() = AVAILABLE
+
+ private val isDevelopmentSettingsEnabledFlow = context.settingsGlobalBooleanFlow(
+ name = Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
+ defaultValue = Build.IS_ENG,
+ )
+
+ @Composable
+ override fun Content() {
+ val isDevelopmentSettingsEnabled by isDevelopmentSettingsEnabledFlow
+ .collectAsStateWithLifecycle(initialValue = false)
+ if (isDevelopmentSettingsEnabled) {
+ DeveloperOptionsPreference()
+ }
+ }
+
+ @VisibleForTesting
+ @Composable
+ fun DeveloperOptionsPreference() {
+ RestrictedPreference(
+ model = object : PreferenceModel {
+ override val title =
+ stringResource(com.android.settingslib.R.string.development_settings_title)
+ override val icon = @Composable {
+ SettingsIcon(ImageVector.vectorResource(R.drawable.ic_settings_development))
+ }
+ override val onClick = {
+ SubSettingLauncher(mContext).apply {
+ setDestination(DevelopmentSettingsDashboardFragment::class.qualifiedName)
+ setSourceMetricsCategory(SettingsEnums.SETTINGS_SYSTEM_CATEGORY)
+ }.launch()
+ }
+ },
+ restrictions = Restrictions(keys = listOf(UserManager.DISALLOW_DEBUGGING_FEATURES)),
+ )
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 2c9fb99..49777bc 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -59,6 +59,7 @@
import java.util.HashSet;
import java.util.Set;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowEntityHeaderController.class, ShadowDeviceConfig.class})
public class AdvancedBluetoothDetailsHeaderControllerTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
index 8ac56dc..1904cb5 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
@@ -50,6 +50,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -62,6 +63,7 @@
import org.robolectric.annotation.Config;
import org.robolectric.fakes.RoboMenu;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
com.android.settings.testutils.shadow.ShadowUserManager.class,
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
index 6f02753..4c58cd2 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPermissionActivityTest.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -32,6 +33,7 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
+@Ignore("b/313014781")
@RunWith(RobolectricTestRunner.class)
public class BluetoothPermissionActivityTest {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
index 50c82d3..88ace91 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
@@ -33,6 +33,7 @@
import com.android.settingslib.widget.FooterPreference;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -82,6 +83,7 @@
assertThat(TextUtils.equals(mFooterPreference.getTitle(), text)).isTrue();
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOffScanningOff() {
Settings.Global.putInt(mContext.getContentResolver(),
@@ -91,6 +93,7 @@
assertThat(mFooterPreference.getTitle()).isEqualTo(BLUETOOTH_INFO_STRING);
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOnScanningOff() {
Settings.Global.putInt(mContext.getContentResolver(),
@@ -100,6 +103,7 @@
assertThat(mFooterPreference.getTitle()).isEqualTo(BLUETOOTH_INFO_STRING);
}
+ @Ignore("b/313014781")
@Test
public void updateText_bluetoothOnScanningOn() {
Settings.Global.putInt(mContext.getContentResolver(),
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java
deleted file mode 100644
index 6b4068d..0000000
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDisabledActivityTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2017 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.development;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import com.android.settings.R;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowToast;
-
-@RunWith(RobolectricTestRunner.class)
-public class DevelopmentSettingsDisabledActivityTest {
-
- @Test
- public void launchActivity_shouldShowToast() {
- Robolectric.setupActivity(DevelopmentSettingsDisabledActivity.class);
-
- final Context context = RuntimeEnvironment.application;
- assertThat(ShadowToast.getTextOfLatestToast())
- .isEqualTo(context.getString(R.string.dev_settings_disabled_warning));
- }
-}
diff --git a/tests/spa_unit/src/com/android/settings/system/DeveloperOptionsControllerTest.kt b/tests/spa_unit/src/com/android/settings/system/DeveloperOptionsControllerTest.kt
new file mode 100644
index 0000000..8707065
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/system/DeveloperOptionsControllerTest.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2023 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.system
+
+import android.content.Context
+import android.content.Intent
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.compose.ui.test.onNodeWithText
+import androidx.compose.ui.test.performClick
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.SettingsActivity
+import com.android.settings.development.DevelopmentSettingsDashboardFragment
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.doNothing
+import org.mockito.kotlin.spy
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+
+@RunWith(AndroidJUnit4::class)
+class DeveloperOptionsControllerTest {
+ @get:Rule
+ val composeTestRule = createComposeRule()
+
+ private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
+ doNothing().whenever(mock).startActivity(any())
+ }
+
+ private val controller = DeveloperOptionsController(context, TEST_KEY)
+
+ @Test
+ fun title_isDisplayed() {
+ composeTestRule.setContent {
+ controller.DeveloperOptionsPreference()
+ }
+
+ composeTestRule.onNodeWithText(
+ context.getString(com.android.settingslib.R.string.development_settings_title)
+ ).assertIsDisplayed()
+ }
+
+ @Test
+ fun onClick_launchDevelopmentSettingsDashboardFragment() {
+ composeTestRule.setContent {
+ controller.DeveloperOptionsPreference()
+ }
+
+ composeTestRule.onNodeWithText(
+ context.getString(com.android.settingslib.R.string.development_settings_title)
+ ).performClick()
+
+ val intent = argumentCaptor<Intent> {
+ verify(context).startActivity(capture())
+ }.firstValue
+ assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
+ .isEqualTo(DevelopmentSettingsDashboardFragment::class.qualifiedName)
+ }
+
+ private companion object {
+ const val TEST_KEY = "test_key"
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
deleted file mode 100644
index 9b38e5b..0000000
--- a/tests/unit/src/com/android/settings/network/MobilePlanPreferenceControllerTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 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.network;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.ResourcesUtils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class MobilePlanPreferenceControllerTest {
-
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = ApplicationProvider.getApplicationContext();
- }
-
- @Test
- public void testNoProvisionStringFormattedCorrectly() {
- final String operator = "test_operator";
-
- assertThat(
- ResourcesUtils.getResourcesString(mContext, "mobile_no_provisioning_url", operator))
- .contains(operator);
- }
-}