Make model & hardware UI full screen.

Bug: 112427717
Test: robotests
Change-Id: I9f1edb0ab377aff142b57d86f4fa218b755356b1
This commit is contained in:
Fan Zhang
2019-02-25 13:36:38 -08:00
parent e0a722e130
commit 8ae1514299
14 changed files with 335 additions and 291 deletions

View File

@@ -1,91 +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.app.Dialog;
import android.app.settings.SettingsEnums;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
public static final String TAG = "HardwareInfo";
@Override
public int getMetricsCategory() {
return SettingsEnums.DIALOG_SETTINGS_HARDWARE_INFO;
}
public static HardwareInfoDialogFragment newInstance() {
final HardwareInfoDialogFragment fragment = new HardwareInfoDialogFragment();
return fragment;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setTitle(R.string.hardware_info)
.setPositiveButton(android.R.string.ok, null);
final View content = LayoutInflater.from(builder.getContext())
.inflate(R.layout.dialog_hardware_info, null /* parent */);
// Model
setText(content, R.id.model_label, R.id.model_value,
DeviceModelPreferenceController.getDeviceModel());
// Serial number
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,
SystemProperties.get("ro.boot.hardware.revision"));
return builder.setView(content).create();
}
@VisibleForTesting
void setText(View content, int labelViewId, int valueViewId, String value) {
if (content == null) {
return;
}
final View labelView = content.findViewById(labelViewId);
final TextView valueView = content.findViewById(valueViewId);
if (!TextUtils.isEmpty(value)) {
labelView.setVisibility(View.VISIBLE);
valueView.setVisibility(View.VISIBLE);
valueView.setText(value);
} else {
labelView.setVisibility(View.GONE);
valueView.setVisibility(View.GONE);
}
}
@VisibleForTesting
String getSerialNumber() {
return Build.getSerial();
}
}

View File

@@ -17,11 +17,8 @@ package com.android.settings.deviceinfo;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -31,21 +28,14 @@ import com.android.settingslib.DeviceInfoUtils;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
public class DeviceModelPreferenceController extends BasePreferenceController {
public class HardwareInfoPreferenceController extends BasePreferenceController {
private static final String TAG = "DeviceModelPrefCtrl";
private Fragment mHost;
public DeviceModelPreferenceController(Context context, String key) {
public HardwareInfoPreferenceController(Context context, String key) {
super(context, key);
}
public void setHost(Fragment fragment) {
mHost = fragment;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
@@ -54,7 +44,7 @@ public class DeviceModelPreferenceController extends BasePreferenceController {
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
@@ -62,21 +52,6 @@ public class DeviceModelPreferenceController extends BasePreferenceController {
return mContext.getResources().getString(R.string.model_summary, getDeviceModel());
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
return false;
}
final HardwareInfoDialogFragment fragment = HardwareInfoDialogFragment.newInstance();
fragment.show(mHost.getFragmentManager(), HardwareInfoDialogFragment.TAG);
return true;
}
@Override
public boolean isSliceable() {
return true;
}
public static String getDeviceModel() {
FutureTask<String> msvSuffixTask = new FutureTask<>(() -> DeviceInfoUtils.getMsvSuffix());

View File

@@ -31,7 +31,6 @@ import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.deviceinfo.BluetoothAddressPreferenceController;
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
import com.android.settings.deviceinfo.DeviceModelPreferenceController;
import com.android.settings.deviceinfo.DeviceNamePreferenceController;
import com.android.settings.deviceinfo.FccEquipmentIdPreferenceController;
import com.android.settings.deviceinfo.FeedbackPreferenceController;
@@ -41,7 +40,6 @@ import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController;
import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
import com.android.settings.deviceinfo.UptimePreferenceController;
import com.android.settings.deviceinfo.WifiMacAddressPreferenceController;
import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceController;
import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController;
import com.android.settings.deviceinfo.simstatus.SimStatusPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -77,7 +75,6 @@ public class MyDeviceInfoFragment extends DashboardFragment
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(DeviceModelPreferenceController.class).setHost(this /* parent */);
use(ImeiInfoPreferenceController.class).setHost(this /* parent */);
use(DeviceNamePreferenceController.class).setHost(this /* parent */);
mBuildNumberPreferenceController = use(BuildNumberPreferenceController.class);

View File

@@ -0,0 +1,42 @@
/*
* 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.deviceinfo.hardwareinfo;
import android.content.Context;
import com.android.settings.deviceinfo.HardwareInfoPreferenceController;
public class DeviceModelPreferenceController extends HardwareInfoPreferenceController {
public DeviceModelPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
final int availability = super.getAvailabilityStatus();
if (availability == AVAILABLE_UNSEARCHABLE) {
return AVAILABLE;
}
return availability;
}
@Override
public boolean isSliceable() {
return true;
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.deviceinfo.hardwareinfo;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
@SearchIndexable
public class HardwareInfoFragment extends DashboardFragment {
public static final String TAG = "HardwareInfo";
@Override
public int getMetricsCategory() {
return SettingsEnums.DIALOG_SETTINGS_HARDWARE_INFO;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.hardware_info;
}
@Override
protected String getLogTag() {
return TAG;
}
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.hardware_info;
result.add(sir);
return result;
}
@Override
protected boolean isPageSearchEnabled(Context context) {
return context.getResources().getBoolean(R.bool.config_show_device_model);
}
};
}

View File

@@ -0,0 +1,46 @@
/*
* 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.deviceinfo.hardwareinfo;
import android.content.Context;
import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class HardwareRevisionPreferenceController extends BasePreferenceController {
public HardwareRevisionPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return true;
}
@Override
public CharSequence getSummary() {
return SystemProperties.get("ro.boot.hardware.revision");
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.deviceinfo.hardwareinfo;
import android.content.Context;
import android.os.Build;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class SerialNumberPreferenceController extends BasePreferenceController {
public SerialNumberPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return true;
}
@Override
public CharSequence getSummary() {
return Build.getSerial();
}
}