Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ae15142 authored by Fan Zhang's avatar Fan Zhang
Browse files

Make model & hardware UI full screen.

Bug: 112427717
Test: robotests
Change-Id: I9f1edb0ab377aff142b57d86f4fa218b755356b1
parent e0a722e1
Loading
Loading
Loading
Loading
+0 −65
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  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.
  -->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="24dp">

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/model_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/model_info" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/model_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/serial_number_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/status_serial_number" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/serial_number_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/hardware_rev_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/hardware_revision" />
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/hardware_rev_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>
</ScrollView>
 No newline at end of file
+52 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="hardware_info_screen"
    android:title="@string/hardware_info"
    settings:keywords="@string/keywords_model_and_hardware">

    <!-- Model -->
    <Preference
        android:key="hardware_info_device_model"
        android:title="@string/model_info"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.DeviceModelPreferenceController"
        settings:enableCopying="true"/>

    <!-- SerialNumber -->
    <Preference
        android:key="hardware_info_device_serial"
        android:title="@string/status_serial_number"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.SerialNumberPreferenceController"
        settings:enableCopying="true"/>

    <!-- Hardware revision -->
    <Preference
        android:key="hardware_info_device_revision"
        android:title="@string/hardware_revision"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.hardwareinfo.HardwareRevisionPreferenceController"
        settings:enableCopying="true"/>

</PreferenceScreen>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,8 @@
        settings:keywords="@string/keywords_model_and_hardware"
        android:summary="@string/summary_placeholder"
        settings:allowDynamicSummaryInSlice="true"
        settings:controller="com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
        android:fragment="com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFragment"
        settings:controller="com.android.settings.deviceinfo.HardwareInfoPreferenceController"/>

    <!-- IMEI -->
    <Preference
+0 −91
Original line number Diff line number Diff line
/*
 * 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();
    }
}
+3 −28
Original line number Diff line number Diff line
@@ -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());

Loading