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

Commit f5747827 authored by Rashed Abdel-Tawab's avatar Rashed Abdel-Tawab Committed by Joey Rizzoli
Browse files

settings: Add platform and RAM to "Model & Hardware" dialogue

This seems kinda empty... Fill it with fun stuff

Change-Id: Ia43cb31b7567bed07f2b8a1d8637de4e66320c90
parent 6f678e05
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -53,5 +53,33 @@
            android:paddingBottom="24dp"
            android:textAppearance="@android:style/TextAppearance.Material.Body2" />

        <TextView
            android:id="@+id/hardware_plat_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@android:style/TextAppearance.Material.Body1"
            android:textColor="?android:attr/textColorSecondary"
            android:text="@string/platform_revision" />
        <TextView
            android:id="@+id/hardware_plat_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="24dp"
            android:textAppearance="@android:style/TextAppearance.Material.Body2" />

        <TextView
            android:id="@+id/hardware_ram_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@android:style/TextAppearance.Material.Body1"
            android:textColor="?android:attr/textColorSecondary"
            android:text="@string/total_ram" />
        <TextView
            android:id="@+id/hardware_ram_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="24dp"
            android:textAppearance="@android:style/TextAppearance.Material.Body2" />

    </LinearLayout>
</ScrollView>
+7 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2012-2016 The CyanogenMod Project
     Copyright (C) 2017      The LineageOS Project
     Copyright (C) 2017-2018 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -26,6 +26,12 @@
    <!-- [CHAR LIMIT=NONE] Device Info screen. Okay we get it, stop pressing, you already have it on -->
    <string name="show_dev_already_cm">No need, you have already enabled development settings.</string>

    <!-- Hardware info -->
    <!-- Label for device's hardware platform value [CHAR LIMIT=40] -->
    <string name="platform_revision">Platform</string>
    <!-- Label for device's hardware ram size [CHAR LIMIT=40] -->
    <string name="total_ram">Total RAM</string>

    <!-- Launch Dev Tools -->
    <string name="development_tools_title">Development tools</string>

+27 −0
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package com.android.settings.deviceinfo;

import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting;
@@ -30,6 +32,8 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;

import java.text.DecimalFormat;

public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {

    public static final String TAG = "HardwareInfo";
@@ -58,6 +62,29 @@ public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
        setText(content, R.id.hardware_rev_label, R.id.hardware_rev_value,
                SystemProperties.get("ro.boot.hardware.revision"));

        // Platform
        setText(content, R.id.hardware_plat_label, R.id.hardware_plat_value,
                SystemProperties.get("ro.board.platform"));

        // RAM
        ActivityManager actManager = (ActivityManager) builder.getContext().getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
        actManager.getMemoryInfo(memInfo);
        DecimalFormat ramDecimalForm = new DecimalFormat("#.#");
        long totRam = memInfo.totalMem;
        double kb = (double)totRam / 1024.0;
        double mb = (double)totRam / 1048576.0;
        double gb = (double)totRam / 1073741824.0;
        String ramString = "";
        if (gb > 1) {
            ramString = ramDecimalForm.format(gb).concat(" GB");
        } else if (mb > 1) {
            ramString = ramDecimalForm.format(mb).concat(" MB");
        } else {
            ramString = ramDecimalForm.format(kb).concat(" KB");
        }
        setText(content, R.id.hardware_ram_label, R.id.hardware_ram_value, ramString);

        return builder.setView(content).create();
    }