[MTK]设置 --> 关于手机中添加CPU、RAM、Phone storage、Resolution4个item

设置 --> 关于手机 

中添加CPU、RAM、Phone storage、Resolution4个item

1.alps/packages/apps/Settings/res/values/strings.xml

@@ -7029,5 +7029,13 @@
        <string name="call_dialing_smart_summary">call,the palm of the phone distance sensor position for two seconds, the phone automatically answer the call</string>
        <string name="title_smart_gesture">Smart Gesture</string>
        <!-- add end -->
+       
+    <!-- add -->
+    <string name="cpu_model">Processor</string>
+    <string name="ram_display">Runs memory</string>
+    <string name="storage_display">Phone storage</string>
+    <string name="all_storage">Total capacity: </string>
+    <string name="available_storage">Available space: </string>
+    <string name="resolution_display">Resolution</string>
 
 </resources>

2.alps/packages/apps/Settings/res/xml/device_info_settings.xml

@@ -89,7 +89,31 @@
                 style="?android:preferenceInformationStyle"
                 android:title="@string/firmware_version"
                 android:summary="@string/device_info_default"/>
+                               
+               <!-- CPU -->
+        <Preference android:key="cpu_model"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/cpu_model"
+                android:summary="@string/device_info_default"/>
+                               
+               <!-- RAM -->
+        <Preference android:key="ram_display"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/ram_display"
+                android:summary="@string/device_info_default"/>        
+                               
+               <!-- Phone storage -->
+        <Preference android:key="storage_display"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/storage_display"
+                android:summary="@string/device_info_default"/>                                
 
+               <!-- Resolution -->
+        <Preference android:key="resolution_display"
+                style="?android:preferenceInformationStyle"
+                android:title="@string/resolution_display"
+                android:summary="@string/device_info_default"/>
+                               
         <!-- Security patch level -->
         <Preference android:key="security_patch"
                 style="?android:preferenceInformationStyle"
3.alps/packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java

@@ -65,6 +65,13 @@ import android.content.SharedPreferences;
 import android.content.pm.PackageInfo;
 //fota end
 import android.os.SystemProperties
+//add 
+import android.app.ActivityManager;
+import android.app.ActivityManager.MemoryInfo;
+import android.text.format.Formatter;
+import android.os.Environment;
+import java.io.File;
+import android.os.StatFs;
 
 
 public class DeviceInfoSettings extends SettingsPreferenceFragment implements Indexable {
@@ -89,6 +96,13 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
     private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid";
     private static final String KEY_DEVICE_FEEDBACK = "device_feedback";
     private static final String KEY_SAFETY_LEGAL = "safetylegal";
+       // add lizonglin
+       private static final String KEY_CPU_MODEL = "cpu_model";
+       private static final String KEY_RAM_DISPLAY = "ram_display";
+       private static final String KEY_STORAGE_DISPLAY = "storage_display";
+       private static final String KEY_RESOLUTION_DISPLAY = "resolution_display";
+       //end 
+       
 
     static final int TAPS_TO_BE_A_DEVELOPER = 7;
 
@@ -131,6 +145,22 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
             getPreferenceScreen().removePreference(findPreference(KEY_SECURITY_PATCH));
 
         }
+               
+               //add 
+               if (SystemProperties.get("ro.add_pref_aboutphone").equals("1")) {
+                       setStringSummary(KEY_CPU_MODEL, "Quad_Core_ARMv7");
+                       setStringSummary(KEY_RAM_DISPLAY, this.getTotalMemory());
+                       String storage1 = getResources().getString(R.string.all_storage);
+               
+               //add 
+               if (SystemProperties.get("ro.add_pref_aboutphone").equals("1")) {
+                       setStringSummary(KEY_CPU_MODEL, "Quad_Core_ARMv7");
+                       setStringSummary(KEY_RAM_DISPLAY, this.getTotalMemory());
+                       String storage1 = getResources().getString(R.string.all_storage);
+                       String storage2 = getResources().getString(R.string.available_storage);
+                       setStringSummary(KEY_STORAGE_DISPLAY, storage2 + getRomAvailableSize() + "\n" + storage1 + this.getRomTotalSize());
+                       setStringSummary(KEY_RESOLUTION_DISPLAY, "720×1280");
+               } else {
+                       getPreferenceScreen().removePreference(findPreference(KEY_CPU_MODEL));
+                       getPreferenceScreen().removePreference(findPreference(KEY_RAM_DISPLAY));
+                       getPreferenceScreen().removePreference(findPreference(KEY_STORAGE_DISPLAY));
+                       getPreferenceScreen().removePreference(findPreference(KEY_RESOLUTION_DISPLAY));
+               }
+               //end
         setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband");
         setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + getMsvSuffix());
         setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID);
@@ -595,5 +625,57 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
         return (String) pm.getApplicationLabel(appInfo);
     }
     //fota end
+       
+       //add 
+       /**
+    * get the ram Memory
+    * @return
+    */
+       private String getTotalMemory() {
+               String str1 = "/proc/meminfo";
+               String str2;
+               String[] arrayOfString;
+               long initial_memory = 0;
+               try {
+                       FileReader localFileReader = new FileReader(str1);
+                       BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);
+                       str2 = localBufferedReader.readLine();
+                       arrayOfString = str2.split("\\s+");
+                       for (String num : arrayOfString) {
+                               Log.i(str2, num + "\t");
+                       }
+                       initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024; 
+                       localBufferedReader.close();
+               } catch (IOException e) {
+                       
+               }
+               return Formatter.formatFileSize(getContext(), initial_memory);
+       }
+
+       /**
+    * get the Total Memory
+    * @return
+    */
+    public String getRomTotalSize(){
+        File path=Environment.getDataDirectory();
+        StatFs statFs=new StatFs(path.getPath());
+        long blockSize=statFs.getBlockSizeLong();
+        long tatalBlocks= statFs.getBlockCountLong();
+        return Formatter.formatFileSize(getContext(), blockSize*tatalBlocks);
+    }
+
+       /**
+    * get the Available Memory
+    * @return
+    */
+    private String getRomAvailableSize(){
+        File path=Environment.getDataDirectory();
+        StatFs statFs=new StatFs(path.getPath());
+        long blockSize=statFs.getBlockSizeLong();
+        long availableBlocks=statFs.getAvailableBlocksLong();
+        return Formatter.formatFileSize(getContext(), blockSize*availableBlocks);
+    }
+       //end
+
 }



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

旧时旅人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值