diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml deleted file mode 100644 index af1fb70c814..00000000000 --- a/res/xml/device_info_settings.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 74ce5d054c9..7e32e5e06e5 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -16,36 +16,29 @@ package com.android.settings; -import static com.android.settings.core.FeatureFlags.DEVICE_INFO_V2; - import android.app.Activity; import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.provider.SearchIndexableResource; -import android.telephony.TelephonyManager; -import android.util.FeatureFlagUtils; import android.support.annotation.VisibleForTesting; +import android.telephony.TelephonyManager; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.SummaryLoader; -import com.android.settings.deviceinfo.BasebandVersionPreferenceController; import com.android.settings.deviceinfo.BluetoothAddressPreferenceController; import com.android.settings.deviceinfo.BuildNumberPreferenceController; import com.android.settings.deviceinfo.DeviceModelPreferenceController; import com.android.settings.deviceinfo.FccEquipmentIdPreferenceController; import com.android.settings.deviceinfo.FeedbackPreferenceController; -import com.android.settings.deviceinfo.FirmwareVersionPreferenceController; import com.android.settings.deviceinfo.ImsStatusPreferenceController; import com.android.settings.deviceinfo.IpAddressPreferenceController; -import com.android.settings.deviceinfo.KernelVersionPreferenceController; import com.android.settings.deviceinfo.ManualPreferenceController; import com.android.settings.deviceinfo.PhoneNumberPreferenceController; import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController; import com.android.settings.deviceinfo.SafetyInfoPreferenceController; -import com.android.settings.deviceinfo.SecurityPatchPreferenceController; import com.android.settings.deviceinfo.WifiMacAddressPreferenceController; import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceControllerV2; import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceControllerV2; @@ -84,21 +77,19 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { public void onCreate(Bundle icicle) { super.onCreate(icicle); final Bundle arguments = getArguments(); - if (FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2)) { - // Do not override initial expand children count if we come from - // search (EXTRA_FRAGMENT_ARG_KEY is set) - we need to display every if entry point - // is search. - if (arguments == null - || !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) { + // Do not override initial expand children count if we come from + // search (EXTRA_FRAGMENT_ARG_KEY is set) - we need to display every if entry point + // is search. + if (arguments == null + || !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) { - // Increase the number of children when the device contains more than 1 sim. - final TelephonyManager telephonyManager = (TelephonyManager) getSystemService( - Context.TELEPHONY_SERVICE); - final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT, - SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount()) - + NON_SIM_PREFERENCES_COUNT; - getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren); - } + // Increase the number of children when the device contains more than 1 sim. + final TelephonyManager telephonyManager = (TelephonyManager) getSystemService( + Context.TELEPHONY_SERVICE); + final int numberOfChildren = Math.max(SIM_PREFERENCES_COUNT, + SIM_PREFERENCES_COUNT * telephonyManager.getPhoneCount()) + + NON_SIM_PREFERENCES_COUNT; + getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren); } } @@ -119,8 +110,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { @Override protected int getPreferenceScreenResId() { - return FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2) - ? R.xml.device_info_settings_v2 : R.xml.device_info_settings; + return R.xml.device_info_settings_v2; } @Override @@ -156,57 +146,23 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { private static List buildPreferenceControllers(Context context, Activity activity, Fragment fragment, Lifecycle lifecycle) { - if (FeatureFlagUtils.isEnabled(context, DEVICE_INFO_V2)) { - final List controllers = new ArrayList<>(); - // Device name - - controllers.add(new PhoneNumberPreferenceController(context)); - - controllers.add(new SimStatusPreferenceControllerV2(context, fragment)); - - controllers.add(new DeviceModelPreferenceController(context, fragment)); - - controllers.add(new ImeiInfoPreferenceControllerV2(context, fragment)); - - controllers.add(new FirmwareVersionPreferenceControllerV2(context, fragment)); - - controllers.add(new ImsStatusPreferenceController(context, lifecycle)); - - controllers.add(new IpAddressPreferenceController(context, lifecycle)); - - controllers.add(new WifiMacAddressPreferenceController(context, lifecycle)); - - controllers.add(new BluetoothAddressPreferenceController(context, lifecycle)); - - controllers.add(new RegulatoryInfoPreferenceController(context)); - - controllers.add(new SafetyInfoPreferenceController(context)); - - controllers.add(new ManualPreferenceController(context)); - - controllers.add(new FeedbackPreferenceController(fragment, context)); - - controllers.add(new FccEquipmentIdPreferenceController(context)); - - controllers.add( - new BuildNumberPreferenceController(context, activity, fragment, lifecycle)); - - return controllers; - } - final List controllers = new ArrayList<>(); - controllers.add( - new BuildNumberPreferenceController(context, activity, fragment, lifecycle)); + controllers.add(new PhoneNumberPreferenceController(context)); + controllers.add(new SimStatusPreferenceControllerV2(context, fragment)); + controllers.add(new DeviceModelPreferenceController(context, fragment)); + controllers.add(new ImeiInfoPreferenceControllerV2(context, fragment)); + controllers.add(new FirmwareVersionPreferenceControllerV2(context, fragment)); + controllers.add(new ImsStatusPreferenceController(context, lifecycle)); + controllers.add(new IpAddressPreferenceController(context, lifecycle)); + controllers.add(new WifiMacAddressPreferenceController(context, lifecycle)); + controllers.add(new BluetoothAddressPreferenceController(context, lifecycle)); + controllers.add(new RegulatoryInfoPreferenceController(context)); + controllers.add(new SafetyInfoPreferenceController(context)); controllers.add(new ManualPreferenceController(context)); controllers.add(new FeedbackPreferenceController(fragment, context)); - controllers.add(new KernelVersionPreferenceController(context)); - controllers.add(new BasebandVersionPreferenceController(context)); - controllers.add(new FirmwareVersionPreferenceController(context, lifecycle)); - controllers.add(new RegulatoryInfoPreferenceController(context)); - controllers.add(new DeviceModelPreferenceController(context, fragment)); - controllers.add(new SecurityPatchPreferenceController(context)); controllers.add(new FccEquipmentIdPreferenceController(context)); - controllers.add(new SafetyInfoPreferenceController(context)); + controllers.add( + new BuildNumberPreferenceController(context, activity, fragment, lifecycle)); return controllers; } @@ -220,8 +176,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable { public List getXmlResourcesToIndex( Context context, boolean enabled) { final SearchIndexableResource sir = new SearchIndexableResource(context); - sir.xmlResId = FeatureFlagUtils.isEnabled(context, DEVICE_INFO_V2) - ? R.xml.device_info_settings_v2 : R.xml.device_info_settings; + sir.xmlResId = R.xml.device_info_settings_v2; return Arrays.asList(sir); } diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index ff0f59f47b1..93149528380 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -148,9 +148,6 @@ public class Settings extends SettingsActivity { public static class ApnEditorActivity extends SettingsActivity { /* empty */ } public static class ChooseAccountActivity extends SettingsActivity { /* empty */ } public static class IccLockSettingsActivity extends SettingsActivity { /* empty */ } - public static class ImeiInformationActivity extends SettingsActivity { /* empty */ } - public static class SimStatusActivity extends SettingsActivity { /* empty */ } - public static class StatusActivity extends SettingsActivity { /* empty */ } public static class TestingSettingsActivity extends SettingsActivity { /* empty */ } public static class WifiAPITestActivity extends SettingsActivity { /* empty */ } public static class WifiInfoActivity extends SettingsActivity { /* empty */ } diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java index 197876fcb17..7b39bdbb9c7 100644 --- a/src/com/android/settings/core/FeatureFlags.java +++ b/src/com/android/settings/core/FeatureFlags.java @@ -20,7 +20,6 @@ package com.android.settings.core; * This class keeps track of all feature flags in Settings. */ public class FeatureFlags { - public static final String DEVICE_INFO_V2 = "device_info_v2"; public static final String SEARCH_V2 = "settings_search_v2"; public static final String SUGGESTIONS_V2 = "new_settings_suggestion"; public static final String APP_INFO_V2 = "settings_app_info_v2"; diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java index ecef57e70c3..acb20d55c4f 100644 --- a/src/com/android/settings/core/gateway/SettingsGateway.java +++ b/src/com/android/settings/core/gateway/SettingsGateway.java @@ -65,12 +65,9 @@ import com.android.settings.datausage.DataUsageList; import com.android.settings.datausage.DataUsageSummary; import com.android.settings.deletionhelper.AutomaticStorageManagerSettings; import com.android.settings.development.DevelopmentSettingsDashboardFragment; -import com.android.settings.deviceinfo.ImeiInformation; import com.android.settings.deviceinfo.PrivateVolumeForget; import com.android.settings.deviceinfo.PrivateVolumeSettings; import com.android.settings.deviceinfo.PublicVolumeSettings; -import com.android.settings.deviceinfo.SimStatus; -import com.android.settings.deviceinfo.Status; import com.android.settings.deviceinfo.StorageDashboardFragment; import com.android.settings.deviceinfo.StorageSettings; import com.android.settings.display.NightDisplaySettings; @@ -235,9 +232,6 @@ public class SettingsGateway { ManagedProfileSettings.class.getName(), ChooseAccountActivity.class.getName(), IccLockSettings.class.getName(), - ImeiInformation.class.getName(), - SimStatus.class.getName(), - Status.class.getName(), TestingSettings.class.getName(), WifiAPITest.class.getName(), WifiInfo.class.getName(), diff --git a/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java b/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java deleted file mode 100644 index 06ed87228e9..00000000000 --- a/src/com/android/settings/deviceinfo/BasebandVersionPreferenceController.java +++ /dev/null @@ -1,58 +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.deviceinfo; - -import android.content.Context; -import android.os.SystemProperties; -import android.support.v7.preference.Preference; - -import com.android.settings.R; -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.deviceinfo.firmwareversion.BasebandVersionDialogController; -import com.android.settingslib.Utils; -import com.android.settingslib.core.AbstractPreferenceController; - -/** - * deprecated in favor of {@link BasebandVersionDialogController} - */ -@Deprecated -public class BasebandVersionPreferenceController extends AbstractPreferenceController implements - PreferenceControllerMixin { - - private static final String BASEBAND_PROPERTY = "gsm.version.baseband"; - private static final String KEY_BASEBAND_VERSION = "baseband_version"; - - public BasebandVersionPreferenceController(Context context) { - super(context); - } - - @Override - public boolean isAvailable() { - return !Utils.isWifiOnly(mContext); - } - - @Override - public String getPreferenceKey() { - return KEY_BASEBAND_VERSION; - } - - @Override - public void updateState(Preference preference) { - super.updateState(preference); - preference.setSummary(SystemProperties.get(BASEBAND_PROPERTY, - mContext.getResources().getString(R.string.device_info_default))); - } -} diff --git a/src/com/android/settings/deviceinfo/BatteryInfoPreferenceController.java b/src/com/android/settings/deviceinfo/BatteryInfoPreferenceController.java deleted file mode 100644 index b5c12f71af1..00000000000 --- a/src/com/android/settings/deviceinfo/BatteryInfoPreferenceController.java +++ /dev/null @@ -1,110 +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.deviceinfo; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.support.annotation.VisibleForTesting; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; - -import com.android.settings.Utils; -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.fuelgauge.PowerUsageSummary; -import com.android.settingslib.core.AbstractPreferenceController; -import com.android.settingslib.core.lifecycle.Lifecycle; -import com.android.settingslib.core.lifecycle.LifecycleObserver; -import com.android.settingslib.core.lifecycle.events.OnStart; -import com.android.settingslib.core.lifecycle.events.OnStop; - -/** - * Deprecated in About Phone V2 - * Information in this preference is available in {@link PowerUsageSummary} - */ -@Deprecated -public class BatteryInfoPreferenceController extends AbstractPreferenceController - implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop { - - @VisibleForTesting - static final IntentFilter BATTERY_INFO_RECEIVER_INTENT_FILTER = - new IntentFilter(Intent.ACTION_BATTERY_CHANGED); - @VisibleForTesting - static final String KEY_BATTERY_STATUS = "battery_status"; - @VisibleForTesting - static final String KEY_BATTERY_LEVEL = "battery_level"; - - @VisibleForTesting - BroadcastReceiver mBatteryInfoReceiver; - private Preference mBatteryStatus; - private Preference mBatteryLevel; - - - public BatteryInfoPreferenceController(Context context, Lifecycle lifecycle) { - super(context); - mBatteryInfoReceiver = new BatteryInfoReceiver(context); - if (lifecycle != null) { - lifecycle.addObserver(this); - } - } - - @Override - public boolean isAvailable() { - return true; - } - - @Override - public String getPreferenceKey() { - return null; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - mBatteryLevel = screen.findPreference(KEY_BATTERY_LEVEL); - mBatteryStatus = screen.findPreference(KEY_BATTERY_STATUS); - } - - @Override - public void onStart() { - mContext.registerReceiver(mBatteryInfoReceiver, BATTERY_INFO_RECEIVER_INTENT_FILTER); - } - - @Override - public void onStop() { - mContext.unregisterReceiver(mBatteryInfoReceiver); - } - - private class BatteryInfoReceiver extends BroadcastReceiver { - - private final Context mContext; - - public BatteryInfoReceiver(Context context) { - mContext = context; - } - - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (Intent.ACTION_BATTERY_CHANGED.equals(action)) { - mBatteryLevel.setSummary(Utils.getBatteryPercentage(intent)); - mBatteryStatus.setSummary(Utils.getBatteryStatus(mContext.getResources(), intent)); - } - } - } -} diff --git a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java index 7934ad7ced2..ee069da23a0 100644 --- a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java +++ b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java @@ -21,10 +21,8 @@ import android.os.Build; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; import android.text.TextUtils; -import android.util.FeatureFlagUtils; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.DeviceInfoUtils; import com.android.settingslib.core.AbstractPreferenceController; @@ -51,12 +49,8 @@ public class DeviceModelPreferenceController extends AbstractPreferenceControlle super.displayPreference(screen); final Preference pref = screen.findPreference(KEY_DEVICE_MODEL); if (pref != null) { - if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.DEVICE_INFO_V2)) { - pref.setSummary(mContext.getResources().getString(R.string.model_summary, - getDeviceModel())); - } else { - pref.setSummary(getDeviceModel()); - } + pref.setSummary(mContext.getResources().getString(R.string.model_summary, + getDeviceModel())); } } diff --git a/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java deleted file mode 100644 index 8c9a2f1a4ee..00000000000 --- a/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceController.java +++ /dev/null @@ -1,118 +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.deviceinfo; - -import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.os.SystemClock; -import android.os.UserHandle; -import android.os.UserManager; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; -import android.text.TextUtils; -import android.util.Log; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceControllerV2; -import com.android.settingslib.RestrictedLockUtils; -import com.android.settingslib.core.AbstractPreferenceController; -import com.android.settingslib.core.lifecycle.Lifecycle; -import com.android.settingslib.core.lifecycle.LifecycleObserver; -import com.android.settingslib.core.lifecycle.events.OnResume; - -/** - * deprecated in favor of {@link FirmwareVersionPreferenceControllerV2} - */ -@Deprecated -public class FirmwareVersionPreferenceController extends AbstractPreferenceController implements - PreferenceControllerMixin, LifecycleObserver, OnResume { - - private static final String TAG = "FirmwareVersionPref"; - private static final String KEY_FIRMWARE_VERSION = "firmware_version"; - - private final UserManager mUserManager; - - private RestrictedLockUtils.EnforcedAdmin mFunDisallowedAdmin; - private boolean mFunDisallowedBySystem; - - private long[] mHits = new long[3]; - - public FirmwareVersionPreferenceController(Context context, Lifecycle lifecycle) { - super(context); - mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); - if (lifecycle != null) { - lifecycle.addObserver(this); - } - } - - @Override - public boolean isAvailable() { - return true; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - final Preference pref = screen.findPreference(KEY_FIRMWARE_VERSION); - if (pref != null) { - pref.setSummary(Build.VERSION.RELEASE); - } - } - - @Override - public String getPreferenceKey() { - return KEY_FIRMWARE_VERSION; - } - - @Override - public void onResume() { - mFunDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced( - mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId()); - mFunDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction( - mContext, UserManager.DISALLOW_FUN, UserHandle.myUserId()); - } - - @Override - public boolean handlePreferenceTreeClick(Preference preference) { - if (!TextUtils.equals(preference.getKey(), KEY_FIRMWARE_VERSION)) { - return false; - } - System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1); - mHits[mHits.length - 1] = SystemClock.uptimeMillis(); - if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) { - if (mUserManager.hasUserRestriction(UserManager.DISALLOW_FUN)) { - if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) { - RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, - mFunDisallowedAdmin); - } - Log.d(TAG, "Sorry, no fun for you!"); - return false; - } - - final Intent intent = new Intent(Intent.ACTION_MAIN) - .setClassName( - "android", com.android.internal.app.PlatLogoActivity.class.getName()); - try { - mContext.startActivity(intent); - return true; - } catch (Exception e) { - Log.e(TAG, "Unable to start activity " + intent.toString()); - } - } - return false; - } -} diff --git a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java index 26f1ac2b53e..6169b44fe5a 100644 --- a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java +++ b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java @@ -23,14 +23,12 @@ import android.os.Bundle; import android.os.SystemProperties; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; -import android.util.FeatureFlagUtils; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; import com.android.internal.logging.nano.MetricsProto; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; public class HardwareInfoDialogFragment extends InstrumentedDialogFragment { @@ -59,12 +57,7 @@ public class HardwareInfoDialogFragment extends InstrumentedDialogFragment { DeviceModelPreferenceController.getDeviceModel()); // Serial number - if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DEVICE_INFO_V2)) { - setText(content, R.id.serial_number_label, R.id.serial_number_value, getSerialNumber()); - } else { - content.findViewById(R.id.serial_number_label).setVisibility(View.GONE); - content.findViewById(R.id.serial_number_value).setVisibility(View.GONE); - } + setText(content, R.id.serial_number_label, R.id.serial_number_value, getSerialNumber()); // Hardware rev setText(content, R.id.hardware_rev_label, R.id.hardware_rev_value, diff --git a/src/com/android/settings/deviceinfo/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/ImeiInfoPreferenceController.java deleted file mode 100644 index 456dbfcce15..00000000000 --- a/src/com/android/settings/deviceinfo/ImeiInfoPreferenceController.java +++ /dev/null @@ -1,42 +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.deviceinfo; - -import android.content.Context; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceControllerV2; -import com.android.settingslib.deviceinfo.AbstractSimStatusImeiInfoPreferenceController; - -/** - * deprecated in favour of {@link ImeiInfoPreferenceControllerV2} - */ -@Deprecated -public class ImeiInfoPreferenceController extends AbstractSimStatusImeiInfoPreferenceController - implements PreferenceControllerMixin { - - private static final String KEY_IMEI_INFO = "imei_info"; - - public ImeiInfoPreferenceController(Context context) { - super(context); - } - - @Override - public String getPreferenceKey() { - return KEY_IMEI_INFO; - } -} diff --git a/src/com/android/settings/deviceinfo/ImeiInformation.java b/src/com/android/settings/deviceinfo/ImeiInformation.java deleted file mode 100644 index 9f38f1b01bd..00000000000 --- a/src/com/android/settings/deviceinfo/ImeiInformation.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2014 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.deviceinfo; - -import android.content.Context; -import android.os.Bundle; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; -import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; -import android.text.Spannable; -import android.text.SpannableStringBuilder; -import android.text.Spanned; -import android.text.TextUtils; - -import android.text.style.TtsSpan; -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.telephony.Phone; -import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.PhoneFactory; -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceControllerV2; - -/** - * deprecated in favor of {@link ImeiInfoPreferenceControllerV2} - */ -@Deprecated -public class ImeiInformation extends SettingsPreferenceFragment { - - private static final String KEY_PRL_VERSION = "prl_version"; - private static final String KEY_MIN_NUMBER = "min_number"; - private static final String KEY_MEID_NUMBER = "meid_number"; - private static final String KEY_ICC_ID = "icc_id"; - private static final String KEY_IMEI = "imei"; - private static final String KEY_IMEI_SV = "imei_sv"; - - private SubscriptionManager mSubscriptionManager; - private boolean isMultiSIM = false; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mSubscriptionManager = SubscriptionManager.from(getContext()); - final TelephonyManager telephonyManager = - (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); - initPreferenceScreen(telephonyManager.getSimCount()); - } - - // Since there are multiple phone for dsds, therefore need to show information for different - // phones. - private void initPreferenceScreen(int slotCount) { - isMultiSIM = (slotCount > 1); - for (int slotId = 0; slotId < slotCount; slotId ++) { - addPreferencesFromResource(R.xml.device_info_phone_status); - setPreferenceValue(slotId); - setNewKey(slotId); - } - } - - private void setPreferenceValue(int phoneId) { - final Phone phone = PhoneFactory.getPhone(phoneId); - - if (phone != null) { - if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) { - setSummaryText(KEY_MEID_NUMBER, phone.getMeid()); - setSummaryText(KEY_MIN_NUMBER, phone.getCdmaMin()); - - if (getResources().getBoolean(R.bool.config_msid_enable)) { - findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number); - } - - setSummaryText(KEY_PRL_VERSION, phone.getCdmaPrlVersion()); - - if (phone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) { - // Show ICC ID and IMEI for LTE device - setSummaryText(KEY_ICC_ID, phone.getIccSerialNumber()); - setSummaryTextAsDigit(KEY_IMEI, phone.getImei()); - setSummaryTextAsDigit(KEY_IMEI_SV, phone.getDeviceSvn()); - } else { - // device is not GSM/UMTS, do not display GSM/UMTS features - // check Null in case no specified preference in overlay xml - removePreferenceFromScreen(KEY_IMEI_SV); - removePreferenceFromScreen(KEY_IMEI); - removePreferenceFromScreen(KEY_ICC_ID); - } - } else { - setSummaryTextAsDigit(KEY_IMEI, phone.getImei()); - setSummaryTextAsDigit(KEY_IMEI_SV, phone.getDeviceSvn()); - // device is not CDMA, do not display CDMA features - // check Null in case no specified preference in overlay xml - removePreferenceFromScreen(KEY_PRL_VERSION); - removePreferenceFromScreen(KEY_MEID_NUMBER); - removePreferenceFromScreen(KEY_MIN_NUMBER); - removePreferenceFromScreen(KEY_ICC_ID); - } - } - } - - // Modify the preference key with prefix "_", so new added information preference can be set - // related phone information. - private void setNewKey(int slotId) { - final PreferenceScreen prefScreen = getPreferenceScreen(); - final int count = prefScreen.getPreferenceCount(); - for (int i = 0; i < count; i++) { - Preference pref = prefScreen.getPreference(i); - String key = pref.getKey(); - if (!key.startsWith("_")){ - key = "_" + key + String.valueOf(slotId); - pref.setKey(key); - updateTitle(pref, slotId); - } - } - } - - private void updateTitle(Preference pref, int slotId) { - if (pref != null) { - String title = pref.getTitle().toString(); - if (isMultiSIM) { - // Slot starts from 1, slotId starts from 0 so plus 1 - title += " " + getResources().getString(R.string.slot_number, slotId + 1); - } - pref.setTitle(title); - } - } - - private void setSummaryText(String key, String text) { - setSummaryText(key, text, false /* forceDigit */); - } - - private void setSummaryTextAsDigit(String key, String text) { - setSummaryText(key, text, true /* forceDigit */); - } - - private void setSummaryText(String key, CharSequence text, boolean forceDigit) { - final Preference preference = findPreference(key); - - if (TextUtils.isEmpty(text)) { - text = getResources().getString(R.string.device_info_default); - } else if (forceDigit && TextUtils.isDigitsOnly(text)) { - final Spannable spannable = new SpannableStringBuilder(text); - final TtsSpan span = new TtsSpan.DigitsBuilder(text.toString()).build(); - spannable.setSpan(span, 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - text = spannable; - } - - if (preference != null) { - preference.setSummary(text); - } - } - - /** - * Removes the specified preference, if it exists. - * @param key the key for the Preference item - */ - private void removePreferenceFromScreen(String key) { - final Preference preference = findPreference(key); - if (preference != null) { - getPreferenceScreen().removePreference(preference); - } - } - - @Override - public int getMetricsCategory() { - return MetricsEvent.DEVICEINFO_IMEI_INFORMATION; - } -} diff --git a/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java b/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java deleted file mode 100644 index 9b0120e7e77..00000000000 --- a/src/com/android/settings/deviceinfo/SecurityPatchPreferenceController.java +++ /dev/null @@ -1,81 +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.deviceinfo; - -import android.content.Context; -import android.content.pm.PackageManager; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; -import android.text.TextUtils; -import android.util.Log; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.deviceinfo.firmwareversion.SecurityPatchLevelDialogController; -import com.android.settingslib.DeviceInfoUtils; -import com.android.settingslib.core.AbstractPreferenceController; - -/** - * deprecated in favor of {@link SecurityPatchLevelDialogController} - */ -@Deprecated -public class SecurityPatchPreferenceController extends AbstractPreferenceController implements - PreferenceControllerMixin { - - private static final String KEY_SECURITY_PATCH = "security_patch"; - private static final String TAG = "SecurityPatchPref"; - - private final String mPatch; - private final PackageManager mPackageManager; - - public SecurityPatchPreferenceController(Context context) { - super(context); - mPackageManager = mContext.getPackageManager(); - mPatch = DeviceInfoUtils.getSecurityPatch(); - } - - @Override - public boolean isAvailable() { - return !TextUtils.isEmpty(mPatch); - } - - @Override - public String getPreferenceKey() { - return KEY_SECURITY_PATCH; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - final Preference pref = screen.findPreference(KEY_SECURITY_PATCH); - if (pref != null) { - pref.setSummary(mPatch); - } - } - - @Override - public boolean handlePreferenceTreeClick(Preference preference) { - if (!TextUtils.equals(preference.getKey(), KEY_SECURITY_PATCH)) { - return false; - } - if (mPackageManager.queryIntentActivities(preference.getIntent(), 0).isEmpty()) { - // Don't send out the intent to stop crash - Log.w(TAG, "Stop click action on " + KEY_SECURITY_PATCH + ": " - + "queryIntentActivities() returns empty"); - return true; - } - return false; - } -} diff --git a/src/com/android/settings/deviceinfo/SerialNumberPreferenceController.java b/src/com/android/settings/deviceinfo/SerialNumberPreferenceController.java deleted file mode 100644 index e466bbfb057..00000000000 --- a/src/com/android/settings/deviceinfo/SerialNumberPreferenceController.java +++ /dev/null @@ -1,39 +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.deviceinfo; - -import android.content.Context; -import android.os.Build; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settingslib.deviceinfo.AbstractSerialNumberPreferenceController; - -/** - * Preference controller for displaying device serial number. Wraps {@link Build#getSerial()}. - * - * deprecated because this preference is no longer used in About Phone V2 - */ -@Deprecated -public class SerialNumberPreferenceController extends - AbstractSerialNumberPreferenceController implements - PreferenceControllerMixin { - public SerialNumberPreferenceController(Context context) { - super(context); - } - - // This space intentionally left blank -} diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java deleted file mode 100644 index dad44190a29..00000000000 --- a/src/com/android/settings/deviceinfo/SimStatus.java +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (C) 2014 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.deviceinfo; - -import static android.content.Context.CARRIER_CONFIG_SERVICE; -import static android.content.Context.TELEPHONY_SERVICE; - -import android.Manifest; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Resources; -import android.os.Bundle; -import android.os.PersistableBundle; -import android.os.UserHandle; -import android.os.UserManager; -import android.support.v7.preference.Preference; -import android.telephony.CarrierConfigManager; -import android.telephony.CellBroadcastMessage; -import android.telephony.PhoneStateListener; -import android.telephony.ServiceState; -import android.telephony.SignalStrength; -import android.telephony.SubscriptionInfo; -import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; -import android.widget.TabHost; -import android.widget.TabHost.OnTabChangeListener; -import android.widget.TabHost.TabContentFactory; -import android.widget.TabHost.TabSpec; -import android.widget.TabWidget; - -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.telephony.Phone; -import com.android.internal.telephony.PhoneConstantConversions; -import com.android.internal.telephony.PhoneFactory; -import com.android.settings.R; -import com.android.settings.SettingsPreferenceFragment; -import com.android.settings.Utils; -import com.android.settingslib.DeviceInfoUtils; - -import java.util.List; - - -/** - * Display the following information - * # Phone Number - * # Network - * # Roaming - * # Device Id (IMEI in GSM and MEID in CDMA) - * # Network type - * # Operator info (area update info cell broadcast) - * # Signal Strength - * - * deprecated in favor of {@link com.android.settings.deviceinfo.simstatus.SimStatusDialogFragment} - */ -@Deprecated -public class SimStatus extends SettingsPreferenceFragment { - private static final String TAG = "SimStatus"; - - private static final String KEY_DATA_STATE = "data_state"; - private static final String KEY_SERVICE_STATE = "service_state"; - private static final String KEY_OPERATOR_NAME = "operator_name"; - private static final String KEY_ROAMING_STATE = "roaming_state"; - private static final String KEY_NETWORK_TYPE = "network_type"; - private static final String KEY_LATEST_AREA_INFO = "latest_area_info"; - private static final String KEY_PHONE_NUMBER = "number"; - private static final String KEY_SIGNAL_STRENGTH = "signal_strength"; - private static final String KEY_IMEI = "imei"; - private static final String KEY_IMEI_SV = "imei_sv"; - private static final String KEY_ICCID = "iccid"; - - static private final String CB_AREA_INFO_RECEIVED_ACTION = - "com.android.cellbroadcastreceiver.CB_AREA_INFO_RECEIVED"; - - static private final String GET_LATEST_CB_AREA_INFO_ACTION = - "com.android.cellbroadcastreceiver.GET_LATEST_CB_AREA_INFO"; - - static private final String CELL_BROADCAST_RECEIVER_APP = "com.android.cellbroadcastreceiver"; - - private TelephonyManager mTelephonyManager; - private CarrierConfigManager mCarrierConfigManager; - private Phone mPhone = null; - private Resources mRes; - private Preference mSignalStrength; - private SubscriptionInfo mSir; - private boolean mShowLatestAreaInfo; - private boolean mShowICCID; - - // Default summary for items - private String mDefaultText; - - private TabHost mTabHost; - private TabWidget mTabWidget; - private ListView mListView; - private List mSelectableSubInfos; - - private PhoneStateListener mPhoneStateListener; - - // Once the cell broadcast configuration is moved into telephony framework, - private final BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (CB_AREA_INFO_RECEIVED_ACTION.equals(action)) { - Bundle extras = intent.getExtras(); - if (extras == null) { - return; - } - CellBroadcastMessage cbMessage = (CellBroadcastMessage) extras.get("message"); - if (cbMessage != null && mSir.getSubscriptionId() == cbMessage.getSubId()) { - String latestAreaInfo = cbMessage.getMessageBody(); - updateAreaInfo(latestAreaInfo); - } - } - } - }; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); - mCarrierConfigManager = (CarrierConfigManager) getSystemService(CARRIER_CONFIG_SERVICE); - - mSelectableSubInfos = SubscriptionManager.from(getContext()) - .getActiveSubscriptionInfoList(); - - addPreferencesFromResource(R.xml.device_info_sim_status); - - mRes = getResources(); - mDefaultText = mRes.getString(R.string.device_info_default); - // Note - missing in zaku build, be careful later... - mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - if (mSelectableSubInfos == null) { - mSir = null; - } else { - mSir = mSelectableSubInfos.size() > 0 ? mSelectableSubInfos.get(0) : null; - - if (mSelectableSubInfos.size() > 1) { - View view = inflater.inflate(R.layout.icc_lock_tabs, container, false); - final ViewGroup prefs_container = (ViewGroup) view.findViewById( - R.id.prefs_container); - Utils.prepareCustomPreferencesList(container, view, prefs_container, false); - View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState); - prefs_container.addView(prefs); - - mTabHost = (TabHost) view.findViewById(android.R.id.tabhost); - mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs); - mListView = (ListView) view.findViewById(android.R.id.list); - - mTabHost.setup(); - mTabHost.setOnTabChangedListener(mTabListener); - mTabHost.clearAllTabs(); - - for (int i = 0; i < mSelectableSubInfos.size(); i++) { - mTabHost.addTab(buildTabSpec(String.valueOf(i), - String.valueOf(mSelectableSubInfos.get(i).getDisplayName()))); - } - return view; - } - } - return super.onCreateView(inflater, container, savedInstanceState); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - updatePhoneInfos(); - } - - @Override - public int getMetricsCategory() { - return MetricsEvent.DEVICEINFO_SIM_STATUS; - } - - @Override - public void onResume() { - super.onResume(); - if (mPhone != null) { - updatePreference(); - - updateSignalStrength(mPhone.getSignalStrength()); - updateServiceState(mPhone.getServiceState()); - updateDataState(); - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_DATA_CONNECTION_STATE - | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS - | PhoneStateListener.LISTEN_SERVICE_STATE); - if (mShowLatestAreaInfo) { - getContext().registerReceiver(mAreaInfoReceiver, - new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION), - Manifest.permission.RECEIVE_EMERGENCY_BROADCAST, null); - // Ask CellBroadcastReceiver to broadcast the latest area info received - Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION); - getLatestIntent.setPackage(CELL_BROADCAST_RECEIVER_APP); - getContext().sendBroadcastAsUser(getLatestIntent, UserHandle.ALL, - Manifest.permission.RECEIVE_EMERGENCY_BROADCAST); - } - } - } - - @Override - public void onPause() { - super.onPause(); - - if (mPhone != null) { - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_NONE); - } - if (mShowLatestAreaInfo) { - getContext().unregisterReceiver(mAreaInfoReceiver); - } - } - - /** - * Removes the specified preference, if it exists. - * @param key the key for the Preference item - */ - private void removePreferenceFromScreen(String key) { - Preference pref = findPreference(key); - if (pref != null) { - getPreferenceScreen().removePreference(pref); - } - } - - private void setSummaryText(String key, String text) { - if (TextUtils.isEmpty(text)) { - text = mDefaultText; - } - // some preferences may be missing - final Preference preference = findPreference(key); - if (preference != null) { - preference.setSummary(text); - } - } - - private void updateNetworkType() { - // Whether EDGE, UMTS, etc... - String networktype = null; - final int subId = mSir.getSubscriptionId(); - final int actualDataNetworkType = mTelephonyManager.getDataNetworkType( - mSir.getSubscriptionId()); - final int actualVoiceNetworkType = mTelephonyManager.getVoiceNetworkType( - mSir.getSubscriptionId()); - if (TelephonyManager.NETWORK_TYPE_UNKNOWN != actualDataNetworkType) { - networktype = mTelephonyManager.getNetworkTypeName(actualDataNetworkType); - } else if (TelephonyManager.NETWORK_TYPE_UNKNOWN != actualVoiceNetworkType) { - networktype = mTelephonyManager.getNetworkTypeName(actualVoiceNetworkType); - } - - boolean show4GForLTE = false; - try { - Context con = getActivity().createPackageContext("com.android.systemui", 0); - int id = con.getResources().getIdentifier("config_show4GForLTE", - "bool", "com.android.systemui"); - show4GForLTE = con.getResources().getBoolean(id); - } catch (NameNotFoundException e) { - Log.e(TAG, "NameNotFoundException for show4GFotLTE"); - } - - if (networktype != null && networktype.equals("LTE") && show4GForLTE) { - networktype = "4G"; - } - setSummaryText(KEY_NETWORK_TYPE, networktype); - } - - private void updateDataState() { - final int state = - PhoneConstantConversions.convertDataState(mPhone.getDataConnectionState()); - - String display = mRes.getString(R.string.radioInfo_unknown); - - switch (state) { - case TelephonyManager.DATA_CONNECTED: - display = mRes.getString(R.string.radioInfo_data_connected); - break; - case TelephonyManager.DATA_SUSPENDED: - display = mRes.getString(R.string.radioInfo_data_suspended); - break; - case TelephonyManager.DATA_CONNECTING: - display = mRes.getString(R.string.radioInfo_data_connecting); - break; - case TelephonyManager.DATA_DISCONNECTED: - display = mRes.getString(R.string.radioInfo_data_disconnected); - break; - } - - setSummaryText(KEY_DATA_STATE, display); - } - - private void updateServiceState(ServiceState serviceState) { - final int state = serviceState.getState(); - String display = mRes.getString(R.string.radioInfo_unknown); - - switch (state) { - case ServiceState.STATE_IN_SERVICE: - display = mRes.getString(R.string.radioInfo_service_in); - break; - case ServiceState.STATE_OUT_OF_SERVICE: - // Set signal strength to 0 when service state is STATE_OUT_OF_SERVICE - mSignalStrength.setSummary("0"); - case ServiceState.STATE_EMERGENCY_ONLY: - // Set summary string of service state to radioInfo_service_out when - // service state is both STATE_OUT_OF_SERVICE & STATE_EMERGENCY_ONLY - display = mRes.getString(R.string.radioInfo_service_out); - break; - case ServiceState.STATE_POWER_OFF: - display = mRes.getString(R.string.radioInfo_service_off); - // Also set signal strength to 0 - mSignalStrength.setSummary("0"); - break; - } - - setSummaryText(KEY_SERVICE_STATE, display); - - if (serviceState.getRoaming()) { - setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_in)); - } else { - setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_not)); - } - setSummaryText(KEY_OPERATOR_NAME, serviceState.getOperatorAlphaLong()); - } - - private void updateAreaInfo(String areaInfo) { - if (areaInfo != null) { - setSummaryText(KEY_LATEST_AREA_INFO, areaInfo); - } - } - - void updateSignalStrength(SignalStrength signalStrength) { - if (mSignalStrength != null) { - final int state = mPhone.getServiceState().getState(); - - if ((ServiceState.STATE_OUT_OF_SERVICE == state) || - (ServiceState.STATE_POWER_OFF == state)) { - mSignalStrength.setSummary("0"); - return; - } - - int signalDbm = signalStrength.getDbm(); - int signalAsu = signalStrength.getAsuLevel(); - - if (-1 == signalDbm) { - signalDbm = 0; - } - - if (-1 == signalAsu) { - signalAsu = 0; - } - - mSignalStrength.setSummary(mRes.getString(R.string.sim_signal_strength, - signalDbm, signalAsu)); - } - } - - private void updatePreference() { - if (mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { - mShowLatestAreaInfo = Resources.getSystem().getBoolean( - com.android.internal.R.bool.config_showAreaUpdateInfoSettings); - } - PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId( - mSir.getSubscriptionId()); - mShowICCID = carrierConfig.getBoolean( - CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL); - - - // If formattedNumber is null or empty, it'll display as "Unknown". - setSummaryText(KEY_PHONE_NUMBER, - DeviceInfoUtils.getFormattedPhoneNumber(getContext(), mSir)); - setSummaryText(KEY_IMEI, mPhone.getImei()); - setSummaryText(KEY_IMEI_SV, mPhone.getDeviceSvn()); - - if (!mShowICCID) { - removePreferenceFromScreen(KEY_ICCID); - } else { - // Get ICCID, which is SIM serial number - String iccid = mTelephonyManager.getSimSerialNumber(mSir.getSubscriptionId()); - setSummaryText(KEY_ICCID, iccid); - } - - if (!mShowLatestAreaInfo) { - removePreferenceFromScreen(KEY_LATEST_AREA_INFO); - } - - boolean hideSignalStrength = carrierConfig.getBoolean( - CarrierConfigManager.KEY_HIDE_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL); - if (hideSignalStrength) { - removePreferenceFromScreen(KEY_SIGNAL_STRENGTH); - } - } - - private void updatePhoneInfos() { - if (mSir != null) { - // TODO: http://b/23763013 - final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId( - mSir.getSubscriptionId())); - if (UserManager.get(getContext()).isAdminUser() - && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) { - if (phone == null) { - Log.e(TAG, "Unable to locate a phone object for the given Subscription ID."); - return; - } - - mPhone = phone; - // To avoid register multiple listeners when user changes the tab. - if (mPhoneStateListener != null && mTelephonyManager != null) { - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_NONE); - mPhoneStateListener = null; - } - mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) { - @Override - public void onDataConnectionStateChanged(int state) { - updateDataState(); - updateNetworkType(); - } - - @Override - public void onSignalStrengthsChanged(SignalStrength signalStrength) { - updateSignalStrength(signalStrength); - } - - @Override - public void onServiceStateChanged(ServiceState serviceState) { - updateServiceState(serviceState); - } - }; - } - } - } - private OnTabChangeListener mTabListener = new OnTabChangeListener() { - @Override - public void onTabChanged(String tabId) { - final int slotId = Integer.parseInt(tabId); - mSir = mSelectableSubInfos.get(slotId); - - // The User has changed tab; update the SIM information. - updatePhoneInfos(); - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_DATA_CONNECTION_STATE - | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS - | PhoneStateListener.LISTEN_SERVICE_STATE); - updateDataState(); - updateNetworkType(); - updatePreference(); - } - }; - - private TabContentFactory mEmptyTabContent = new TabContentFactory() { - @Override - public View createTabContent(String tag) { - return new View(mTabHost.getContext()); - } - }; - - private TabSpec buildTabSpec(String tag, String title) { - return mTabHost.newTabSpec(tag).setIndicator(title).setContent( - mEmptyTabContent); - } -} diff --git a/src/com/android/settings/deviceinfo/SimStatusPreferenceController.java b/src/com/android/settings/deviceinfo/SimStatusPreferenceController.java deleted file mode 100644 index ca531ea50c6..00000000000 --- a/src/com/android/settings/deviceinfo/SimStatusPreferenceController.java +++ /dev/null @@ -1,42 +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.deviceinfo; - -import android.content.Context; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.deviceinfo.simstatus.SimStatusPreferenceControllerV2; -import com.android.settingslib.deviceinfo.AbstractSimStatusImeiInfoPreferenceController; - -/** - * deprecated in favor of {@link SimStatusPreferenceControllerV2} - */ -@Deprecated -public class SimStatusPreferenceController extends AbstractSimStatusImeiInfoPreferenceController - implements PreferenceControllerMixin { - - private static final String KEY_SIM_STATUS = "sim_status"; - - public SimStatusPreferenceController(Context context) { - super(context); - } - - @Override - public String getPreferenceKey() { - return KEY_SIM_STATUS; - } -} diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java deleted file mode 100644 index 15ad5cf05e0..00000000000 --- a/src/com/android/settings/deviceinfo/Status.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2008 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.deviceinfo; - -import android.content.Context; -import android.provider.SearchIndexableResource; - -import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.settings.DeviceInfoSettings; -import com.android.settings.R; -import com.android.settings.dashboard.DashboardFragment; -import com.android.settings.search.BaseSearchIndexProvider; -import com.android.settingslib.core.AbstractPreferenceController; -import com.android.settingslib.core.lifecycle.Lifecycle; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Fragment for showing device hardware info, such as MAC addresses and serial numbers - * Deprecated in About Phone V2 - * Information on this page is available in {@link DeviceInfoSettings} - */ -@Deprecated -public class Status extends DashboardFragment { - - private static final String TAG = "DeviceStatus"; - - @Override - public int getMetricsCategory() { - return MetricsEvent.DEVICEINFO_STATUS; - } - - @Override - protected String getLogTag() { - return TAG; - } - - @Override - protected int getPreferenceScreenResId() { - return R.xml.device_info_status; - } - - @Override - protected List getPreferenceControllers(Context context) { - return buildPreferenceControllers(context, getLifecycle()); - } - - private static List buildPreferenceControllers(Context context, - Lifecycle lifecycle) { - final List controllers = new ArrayList<>(); - controllers.add(new SerialNumberPreferenceController(context)); - controllers.add(new UptimePreferenceController(context, lifecycle)); - controllers.add(new BluetoothAddressPreferenceController(context, lifecycle)); - controllers.add(new IpAddressPreferenceController(context, lifecycle)); - controllers.add(new WifiMacAddressPreferenceController(context, lifecycle)); - controllers.add(new ImsStatusPreferenceController(context, lifecycle)); - controllers.add(new SimStatusPreferenceController(context)); - controllers.add(new ImeiInfoPreferenceController(context)); - controllers.add(new BatteryInfoPreferenceController(context, lifecycle)); - return controllers; - } - - /** - * For Search. - */ - public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider() { - - @Override - public List getXmlResourcesToIndex( - Context context, boolean enabled) { - final SearchIndexableResource sir = new SearchIndexableResource(context); - sir.xmlResId = R.xml.device_info_status; - return Arrays.asList(sir); - } - - @Override - public List getPreferenceControllers(Context - context) { - return buildPreferenceControllers(context, null /* lifecycle */); - } - }; -} diff --git a/src/com/android/settings/deviceinfo/UptimePreferenceController.java b/src/com/android/settings/deviceinfo/UptimePreferenceController.java deleted file mode 100644 index c25f984ff5e..00000000000 --- a/src/com/android/settings/deviceinfo/UptimePreferenceController.java +++ /dev/null @@ -1,40 +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.deviceinfo; - -import android.content.Context; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settings.fuelgauge.PowerUsageSummary; -import com.android.settingslib.core.lifecycle.Lifecycle; -import com.android.settingslib.deviceinfo.AbstractUptimePreferenceController; - -/** - * Concrete subclass of uptime preference controller - * - * Deprecated in About Phone V2 - * Information in this preference is available in {@link PowerUsageSummary} - */ -@Deprecated -public class UptimePreferenceController extends AbstractUptimePreferenceController - implements PreferenceControllerMixin { - public UptimePreferenceController(Context context, Lifecycle lifecycle) { - super(context, lifecycle); - } - - // This space intentionally left blank -} diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable index eee2add4b6b..a82c9efc996 100644 --- a/tests/robotests/assets/grandfather_not_implementing_indexable +++ b/tests/robotests/assets/grandfather_not_implementing_indexable @@ -1,12 +1,10 @@ com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment -com.android.settings.deviceinfo.SimStatus com.android.settings.deviceinfo.PrivateVolumeForget com.android.settings.inputmethod.SpellCheckersSettings com.android.settings.inputmethod.KeyboardLayoutPickerFragment com.android.settings.fuelgauge.InactiveApps com.android.settings.accessibility.CaptionPropertiesFragment com.android.settings.accessibility.AccessibilitySettingsForSetupWizard -com.android.settings.deviceinfo.ImeiInformation com.android.settings.datausage.DataUsageList com.android.settings.vpn2.AppManagementFragment com.android.settings.vpn2.VpnSettings diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry index 9fd41f23ee8..666b224558a 100644 --- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry +++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry @@ -1,3 +1,2 @@ com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard -com.android.settings.search.indexing.FakeSettingsFragment -com.android.settings.deviceinfo.Status +com.android.settings.search.indexing.FakeSettingsFragment \ No newline at end of file diff --git a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java index 486993d1b7b..09ff9db74fa 100644 --- a/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java +++ b/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java @@ -30,12 +30,9 @@ import android.app.Activity; import android.content.Context; import android.os.Build; import android.os.Bundle; -import android.os.SystemProperties; import android.support.v7.preference.PreferenceScreen; import android.telephony.TelephonyManager; -import android.util.FeatureFlagUtils; -import com.android.settings.core.FeatureFlags; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.SettingsRobolectricTestRunner; @@ -98,8 +95,6 @@ public class DeviceInfoSettingsTest { SettingsShadowSystemProperties.class }) public void getPrefXml_shouldReturnDeviceInfoXml() { - SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2, - "true"); assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.device_info_settings_v2); } @@ -142,8 +137,6 @@ public class DeviceInfoSettingsTest { @Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, SettingsShadowSystemProperties.class}) public void onCreate_singleSim_shouldAddSingleSimCount() { - SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2, - "true"); doReturn(1).when(mTelephonyManager).getPhoneCount(); mSettings.onCreate(null /* icicle */); @@ -156,8 +149,6 @@ public class DeviceInfoSettingsTest { @Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, SettingsShadowSystemProperties.class}) public void onCreate_dualeSim_shouldAddDualSimCount() { - SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2, - "true"); doReturn(2).when(mTelephonyManager).getPhoneCount(); mSettings.onCreate(null /* icicle */); diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java deleted file mode 100644 index f71bae64152..00000000000 --- a/tests/robotests/src/com/android/settings/deviceinfo/BasebandVersionPreferenceControllerTest.java +++ /dev/null @@ -1,86 +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.deviceinfo; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.verify; -import static org.robolectric.shadow.api.Shadow.extract; - -import android.net.ConnectivityManager; -import android.support.v7.preference.Preference; - -import com.android.settings.TestConfig; -import com.android.settings.deviceinfo.firmwareversion.BasebandVersionDialogController; -import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; -import com.android.settings.testutils.shadow.ShadowConnectivityManager; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -/** - * Deprecated in favor of {@link BasebandVersionDialogController} - */ -@Deprecated -@RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, - shadows = ShadowConnectivityManager.class) -public class BasebandVersionPreferenceControllerTest { - - - @Mock - private Preference mPreference; - - private BasebandVersionPreferenceController mController; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mController = new BasebandVersionPreferenceController(RuntimeEnvironment.application); - } - - @Test - public void isAvailable_wifiOnly_shouldReturnFalse() { - ShadowConnectivityManager connectivityManager = - extract(RuntimeEnvironment.application.getSystemService(ConnectivityManager.class)); - connectivityManager.setNetworkSupported(ConnectivityManager.TYPE_MOBILE, false); - assertThat(mController.isAvailable()).isFalse(); - } - - @Test - public void isAvailable_hasMobile_shouldReturnTrue() { - ShadowConnectivityManager connectivityManager = - extract(RuntimeEnvironment.application.getSystemService(ConnectivityManager.class)); - connectivityManager.setNetworkSupported(ConnectivityManager.TYPE_MOBILE, true); - assertThat(mController.isAvailable()).isTrue(); - } - - @Config(shadows = {SettingsShadowSystemProperties.class}) - @Test - public void updateState_shouldLoadFromSysProperty() { - SettingsShadowSystemProperties.set("gsm.version.baseband", "test"); - - mController.updateState(mPreference); - - verify(mPreference).setSummary("test"); - } -} diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java deleted file mode 100644 index 0ccc1391ec1..00000000000 --- a/tests/robotests/src/com/android/settings/deviceinfo/BatteryInfoPreferenceControllerTest.java +++ /dev/null @@ -1,110 +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.deviceinfo; - -import static android.arch.lifecycle.Lifecycle.Event.ON_START; -import static android.arch.lifecycle.Lifecycle.Event.ON_STOP; - -import static com.android.settings.deviceinfo.BatteryInfoPreferenceController - .BATTERY_INFO_RECEIVER_INTENT_FILTER; -import static com.android.settings.deviceinfo.BatteryInfoPreferenceController.KEY_BATTERY_LEVEL; -import static com.android.settings.deviceinfo.BatteryInfoPreferenceController.KEY_BATTERY_STATUS; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.content.Intent; -import android.os.BatteryManager; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; - -import com.android.settings.R; -import com.android.settings.TestConfig; -import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settingslib.core.lifecycle.Lifecycle; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -@RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) -public class BatteryInfoPreferenceControllerTest { - - private Context mContext; - @Mock - private PreferenceScreen mScreen; - - private Preference mBatteryLevel; - private Preference mBatteryStatus; - private Lifecycle mLifecycle; - private BatteryInfoPreferenceController mController; - - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mContext = RuntimeEnvironment.application; - mLifecycle = new Lifecycle(() -> mLifecycle); - mController = new BatteryInfoPreferenceController(mContext, mLifecycle); - mBatteryLevel = new Preference(mContext); - mBatteryStatus = new Preference(mContext); - when(mScreen.findPreference(KEY_BATTERY_STATUS)).thenReturn(mBatteryStatus); - when(mScreen.findPreference(KEY_BATTERY_LEVEL)).thenReturn(mBatteryLevel); - } - - @Test - public void isAlwaysAvailable() { - assertThat(mController.getPreferenceKey()).isNull(); - assertThat(mController.isAvailable()).isTrue(); - } - - @Test - public void runThroughLifecycle_shouldRegisterUnregisterBatteryInfoReceiver() { - final Context context = mock(Context.class); - mController = new BatteryInfoPreferenceController(context, mLifecycle); - mLifecycle.handleLifecycleEvent(ON_START); - mLifecycle.handleLifecycleEvent(ON_STOP); - - verify(context).registerReceiver(mController.mBatteryInfoReceiver, - BATTERY_INFO_RECEIVER_INTENT_FILTER); - verify(context).unregisterReceiver(mController.mBatteryInfoReceiver); - } - - @Test - public void onReceiveBatteryInfoBroadcast_shouldUpdatePreferences() { - mController.displayPreference(mScreen); - final Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED); - intent.putExtra(BatteryManager.EXTRA_LEVEL, 50); - intent.putExtra(BatteryManager.EXTRA_SCALE, 100); - intent.putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING); - - mController.mBatteryInfoReceiver.onReceive(mContext, intent); - - assertThat(mBatteryLevel.getSummary()).isEqualTo("50%"); - assertThat(mBatteryStatus.getSummary()) - .isEqualTo(mContext.getText(R.string.battery_info_status_charging)); - } -} diff --git a/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java index 347ca3ac308..6a5c7fa25f6 100644 --- a/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java @@ -19,6 +19,7 @@ package com.android.settings.deviceinfo; import static com.android.settings.deviceinfo.DeviceModelPreferenceController.getDeviceModel; import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -26,16 +27,12 @@ import static org.mockito.Mockito.when; import android.app.Fragment; import android.content.Context; -import android.os.SystemProperties; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; -import android.util.FeatureFlagUtils; import com.android.settings.R; import com.android.settings.TestConfig; -import com.android.settings.core.FeatureFlags; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; import org.junit.Before; import org.junit.Test; @@ -57,6 +54,7 @@ public class DeviceModelPreferenceControllerTest { @Mock private PreferenceScreen mPreferenceScreen; + private Context mContext; private DeviceModelPreferenceController mController; @@ -76,12 +74,7 @@ public class DeviceModelPreferenceControllerTest { } @Test - @Config(shadows = { - SettingsShadowSystemProperties.class - }) public void displayPref_shouldSetSummary() { - SystemProperties.set(FeatureFlagUtils.FFLAG_OVERRIDE_PREFIX + FeatureFlags.DEVICE_INFO_V2, - "true"); mController.displayPreference(mPreferenceScreen); verify(mPreference).setSummary(mContext.getResources().getString(R.string.model_summary, diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java deleted file mode 100644 index 09b2e7f5f83..00000000000 --- a/tests/robotests/src/com/android/settings/deviceinfo/FirmwareVersionPreferenceControllerTest.java +++ /dev/null @@ -1,74 +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.deviceinfo; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.os.UserManager; -import android.support.v7.preference.Preference; -import android.support.v7.preference.PreferenceScreen; - -import com.android.settings.TestConfig; -import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDialogController; -import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settingslib.core.lifecycle.Lifecycle; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.annotation.Config; - -/** - * Deprecated in favor of {@link FirmwareVersionDialogController} - */ -@Deprecated -@RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) -public class FirmwareVersionPreferenceControllerTest { - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private Context mContext; - @Mock - private Preference mPreference; - @Mock - private PreferenceScreen mPreferenceScreen; - @Mock - private UserManager mUserManager; - private FirmwareVersionPreferenceController mController; - private Lifecycle mLifecycle; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - mLifecycle = new Lifecycle(() -> mLifecycle); - when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); - when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(null); - mController = new FirmwareVersionPreferenceController(mContext, mLifecycle); - when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) - .thenReturn(mPreference); - } - - @Test - public void isAlwaysAvailable() { - assertThat(mController.isAvailable()).isTrue(); - } -}