Update DeviceModelPreferenceController
- Added serial number to the dialog for about phone v2 - prefixed model to the preference summary for about phone v2 Bug: 36458278 Test: make RunSettingsRoboTests -j40 Change-Id: Ic2950adcecf940ad8c9256688dc70b662ad5f0d6
This commit is contained in:
@@ -49,10 +49,11 @@ import java.util.List;
|
||||
|
||||
public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
||||
|
||||
public static final String DEVICE_INFO_V2_FEATURE_FLAG = "device_info_v2";
|
||||
|
||||
private static final String LOG_TAG = "DeviceInfoSettings";
|
||||
|
||||
private static final String KEY_LEGAL_CONTAINER = "legal_container";
|
||||
private static final String DEVICE_INFO_V2_FEATURE_FLAG = "device_info_v2";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -127,7 +128,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
||||
|
||||
// SIM status
|
||||
|
||||
// Model & hardware
|
||||
controllers.add(new DeviceModelPreferenceController(context, fragment));
|
||||
|
||||
// IMEI
|
||||
|
||||
|
@@ -21,7 +21,10 @@ 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.DeviceInfoSettings;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.DeviceInfoUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -48,7 +51,12 @@ public class DeviceModelPreferenceController extends AbstractPreferenceControlle
|
||||
super.displayPreference(screen);
|
||||
final Preference pref = screen.findPreference(KEY_DEVICE_MODEL);
|
||||
if (pref != null) {
|
||||
pref.setSummary(getDeviceModel());
|
||||
if (FeatureFlagUtils.isEnabled(DeviceInfoSettings.DEVICE_INFO_V2_FEATURE_FLAG)) {
|
||||
pref.setSummary(mContext.getResources().getString(R.string.model_summary,
|
||||
getDeviceModel()));
|
||||
} else {
|
||||
pref.setSummary(getDeviceModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,15 +18,18 @@ package com.android.settings.deviceinfo;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Build;
|
||||
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.DeviceInfoSettings;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
@@ -54,6 +57,15 @@ public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
|
||||
// Model
|
||||
setText(content, R.id.model_label, R.id.model_value,
|
||||
DeviceModelPreferenceController.getDeviceModel());
|
||||
|
||||
// Serial number
|
||||
if (FeatureFlagUtils.isEnabled(DeviceInfoSettings.DEVICE_INFO_V2_FEATURE_FLAG)) {
|
||||
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);
|
||||
}
|
||||
|
||||
// Hardware rev
|
||||
setText(content, R.id.hardware_rev_label, R.id.hardware_rev_value,
|
||||
SystemProperties.get("ro.boot.hardware.revision"));
|
||||
@@ -77,4 +89,9 @@ public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
|
||||
valueView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
String getSerialNumber() {
|
||||
return Build.getSerial();
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,10 @@ import com.android.settingslib.deviceinfo.AbstractSerialNumberPreferenceControll
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
Reference in New Issue
Block a user