Android6.0存储中加入总内存和系统内存项

阅读数:651

平台下patches/packages/apps/Settings/里面

1.存储中加入总内存和系统内存项

在 res/values-zh-rCN/strings.xml 中添加

[java] view plaincopy
  1. <string name="write_settings_description" msgid="6868293938839954623">"此权限允许应用修改系统设置。"</string>
  2. <string name="write_settings_on" msgid="8230580416068832239">"允许"</string>
  3. <string name="write_settings_off" msgid="5156104383386336233">"不允许"</string>
  4. +    <string name="storage_detail_system">"系统内存"</string>
  5. +    <string name="storage_detail_total">"总内存"</string>
  6. </resources>

在 /res/values-zh-rTW/strings.xml 中添加

[java] view plaincopy
  1. <string name="write_settings_description" msgid="6868293938839954623">"這項權限允許應用程式修改系統設定。"</string>
  2. <string name="write_settings_on" msgid="8230580416068832239">"可"</string>
  3. <string name="write_settings_off" msgid="5156104383386336233">"否"</string>
  4. +    <string name="storage_detail_system">"系统内存"</string>
  5. +    <string name="storage_detail_total">"总内存"</string>
  6. </resources>
[java] view plaincopy

在 /res/values/strings.xml 中添加

[java] view plaincopy
  1. <string name="write_settings_on">Yes</string>
  2. <!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->
  3. <string name="write_settings_off">No</string>
  4. +    <string name="storage_detail_total">"Total Data"</string>
  5. +    <string name="storage_detail_system">System Data</string>
  6. </resources>

/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java 中添加

[java] view plaincopy
  1. import android.content.Context;
  2. import android.content.DialogInterface;
  3. import android.content.Intent;
  4. +import java.text.DecimalFormat;
  5. import android.content.pm.IPackageDataObserver;
  6. import android.content.pm.PackageInfo;
  7. import android.content.pm.PackageManager;
  8. @@ -118,6 +119,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
  9. private int mItemPoolIndex;
  10. private Preference mExplore;
  11. +    private Preference storage_detail_system;
  12. +    private Preference storage_detail_total;
  13. private boolean isVolumeValid() {
  14. return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
  15. @@ -159,6 +162,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
  16. mCurrentUser = mUserManager.getUserInfo(UserHandle.myUserId());
  17. mExplore = buildAction(R.string.storage_menu_explore);
  18. +        storage_detail_system = buildAction(R.string.storage_detail_system);
  19. +        storage_detail_total  =  buildAction(R.string.storage_detail_total);
  20. setHasOptionsMenu(true);
  21. }
  22. @@ -216,6 +221,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
  23. addItem(screen, R.string.storage_detail_cached, null, UserHandle.USER_NULL);
  24. if (showShared) {
  25. +            addPreference(screen, storage_detail_system);
  26. +            addPreference(screen, storage_detail_total);
  27. addPreference(screen, mExplore);
  28. }
  29. @@ -224,13 +231,28 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
  30. final long freeBytes = file.getFreeSpace();
  31. final long usedBytes = totalBytes - freeBytes;
  32. -        final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
  33. -        mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  34. -                result.value, result.units));
  35. -        mSummary.setSummary(getString(R.string.storage_volume_used,
  36. -                Formatter.formatFileSize(context, totalBytes)));
  37. -        mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
  38. -
  39. +        if(showShared) {
  40. +            final long  systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);
  41. +            Log.d("zhongyeqing","systemBytes = "+systemBytes);
  42. +            final BytesResult systemresult = Formatter.formatBytes(getResources(), systemBytes, 0);
  43. +            storage_detail_system.setSummary(systemresult.value+systemresult.units);
  44. +            storage_detail_total.setSummary("8.0 GB");
  45. +
  46. +            final BytesResult result = Formatter.formatBytes(getResources(), systemBytes+usedBytes, 0);
  47. +            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  48. +                        result.value, result.units));
  49. +            mSummary.setSummary(getString(R.string.storage_volume_used,
  50. +                        Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))));
  51. +            mSummary.setPercent((int) (((systemBytes+usedBytes) * 100) / (float) (8.0 * 1024 * 1024 * 1024)));
  52. +
  53. +        }else{
  54. +            final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
  55. +            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  56. +                        result.value, result.units));
  57. +            mSummary.setSummary(getString(R.string.storage_volume_used,
  58. +                        Formatter.formatFileSize(context, totalBytes)));
  59. +            mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
  60. +        }
  61. mMeasure.forceMeasure();
  62. }

/src/com/android/settings/deviceinfo/PublicVolumeSettings.java 中添加

[java] view plaincopy
  1. final long freeBytes = file.getFreeSpace();
  2. final long usedBytes = totalBytes - freeBytes;
  3. -            final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
  4. -            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  5. -                    result.value, result.units));
  6. -            mSummary.setSummary(getString(R.string.storage_volume_used,
  7. -                    Formatter.formatFileSize(context, totalBytes)));
  8. -            mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
  9. +            if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.getId())) {
  10. +                final long  systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);
  11. +                final BytesResult result = Formatter.formatBytes(getResources(), systemBytes+usedBytes, 0);
  12. +                mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  13. +                            result.value, result.units));
  14. +                mSummary.setSummary(getString(R.string.storage_volume_used,
  15. +                            Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024)))+"---");
  16. +                mSummary.setPercent((int) (((usedBytes+systemBytes) * 100) / (float)(8.0 * 1024 * 1024 * 1024)));
  17. +            }else{
  18. +                final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
  19. +                mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  20. +                            result.value, result.units));
  21. +                mSummary.setSummary(getString(R.string.storage_volume_used,
  22. +                            Formatter.formatFileSize(context, totalBytes)));
  23. +                mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
  24. +            }
  25. }
  26. if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {

/src/com/android/settings/deviceinfo/StorageSettings.java 中添加

[java] view plaincopy
  1. </pre><pre name="code" class="java">int privateCount = 0;
  2. long privateUsedBytes = 0;
  3. long privateTotalBytes = 0;
  4. +        long  systemBytes = 0;
  5. final List<VolumeInfo> volumes = mStorageManager.getVolumes();
  6. Collections.sort(volumes, VolumeInfo.getDescriptionComparator());
  7. @@ -178,6 +179,9 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
  8. final File path = vol.getPath();
  9. privateUsedBytes += path.getTotalSpace() - path.getFreeSpace();
  10. privateTotalBytes += path.getTotalSpace();
  11. +                    if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())){
  12. +                        systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - privateTotalBytes);
  13. +                    }
  14. }
  15. } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
  16. mExternalCategory.addPreference(
  17. @@ -217,12 +221,28 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
  18. }
  19. }
  20. -        final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);
  21. -        mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  22. -                result.value, result.units));
  23. -        mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
  24. -                Formatter.formatFileSize(context, privateTotalBytes)));
  25. +        /* Vanzo:zhongyeqing on: Wed, 12 Oct 2016 23:08:22 +0800
  26. +        * TODO: replace this line with your comment
  27. +        if (systemBytes != 0){
  28. +        */
  29. +        // End of Vanzo: zhongyeqing
  30. +            final BytesResult result = Formatter.formatBytes(getResources(),systemBytes+privateUsedBytes, 0);
  31. +            mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  32. +                        result.value, result.units));
  33. +            //mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,"8.0 GB"));
  34. +            mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
  35. +                        Formatter.formatFileSize(context, privateTotalBytes+systemBytes)));
  36. +        /* Vanzo:zhongyeqing on: Wed, 12 Oct 2016 23:08:17 +0800
  37. +        * TODO: replace this line with your comment
  38. +        }else{
  39. +            final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);
  40. +            mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
  41. +                        Formatter.formatFileSize(context, privateTotalBytes)));
  42. +
  43. +        }
  44. +        */
  45. +        // End of Vanzo: zhongyeqing
  46. if (mInternalCategory.getPreferenceCount() > 0) {
  47. getPreferenceScreen().addPreference(mInternalCategory);
  48. }

在 /src/com/android/settings/deviceinfo/StorageVolumePreference.java 中

[java] view plaincopy
  1. final long freeBytes = path.getFreeSpace();
  2. final long totalBytes = path.getTotalSpace();
  3. final long usedBytes = totalBytes - freeBytes;
  4. +            final long systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);
  5. final String used = Formatter.formatFileSize(context, usedBytes);
  6. +            final String usedSystem = Formatter.formatFileSize(context, usedBytes+systemBytes);
  7. final String total = Formatter.formatFileSize(context, totalBytes);
  8. +            /* Vanzo:zhongyeqing on: Mon, 15 Aug 2016 14:40:17 +0800
  9. +             * TODO: replace this line with your comment
  10. setSummary(context.getString(R.string.storage_volume_summary, used, total));
  11. if (totalBytes != 0) {
  12. mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
  13. }
  14. -
  15. +            */
  16. +            if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.getId())) {
  17. +                setSummary(context.getString(R.string.storage_volume_summary, usedSystem, "8.0 GB"));
  18. +                if (totalBytes != 0) {
  19. +                    mUsedPercent = (int) (((usedBytes+systemBytes) * 100) / (float) (8.0 * 1024 * 1024 * 1024));
  20. +                }
  21. +            } else {
  22. +                setSummary(context.getString(R.string.storage_volume_summary, used, total));
  23. +                if (totalBytes != 0) {
  24. +                    mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
  25. +                }
  26. +            }
  27. +            // End of Vanzo: zhongyeqing
  28. if (freeBytes < mStorageManager.getStorageLowBytes(path)) {
  29. mColor = StorageSettings.COLOR_WARNING;
  30. icon = context.getDrawable(R.drawable.ic_warning_24dp);

2.下述代码为西语下 存储    和  内存 中的 , 改为 .
/src/com/android/settings/applications/ProcessStatsSummary.java  中

[java] view plaincopy
  1. double freeRam = memInfo.realFreeRam;
  2. BytesResult usedResult = Formatter.formatBytes(context.getResources(), (long) usedRam,
  3. Formatter.FLAG_SHORTER);
  4. -        String totalString = Formatter.formatShortFileSize(context, (long) totalRam);
  5. +        String totalString = (Formatter.formatShortFileSize(context, (long) totalRam)).replace(",",".");
  6. String freeString = Formatter.formatShortFileSize(context, (long) freeRam);

/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java 中

[java] view plaincopy
  1. private void updatePreference(StorageItemPreference pref, long size) {
  2. -        pref.setSummary(Formatter.formatFileSize(getActivity(), size));
  3. +        pref.setSummary((Formatter.formatFileSize(getActivity(), size)).replace(",","."));
  4. }

再在第一段代码的基础上:

[java] view plaincopy
  1. storage_detail_system.setSummary(systemresult.value+systemresult.units);

变为

[java] view plaincopy
  1. storage_detail_system.setSummary((systemresult.value+systemresult.units).replace(",","."));
[java] view plaincopy
  1. result.value, result.units));
[java] view plaincopy
  1. 变为
[java] view plaincopy
  1. <pre name="code" class="java">(result.value).replace(",","."), result.units));
[java] view plaincopy
[java] view plaincopy
  1. <pre name="code" class="java">Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))));

变为

[java] view plaincopy
  1. <pre name="code" class="java">(Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))).replace(",",".")));

Android系统(127)---Android6.0存储中加入总内存和系统内存项和在西语下把,换成.相关推荐

  1. android+桌面歌词,Android6.0系统适配桌面歌词效果

    在360手机助手及各家的音乐播放器软件上,都使用了桌面浮动窗功能,桌面歌词都是在音乐客户端显示在前台时隐藏,在用户把软件切换到后台后显示出来,此效果在Android 6.0以前,大部分都是使用系统的A ...

  2. android闪光灯参数,android6.0中的闪光灯

    在android6.0中,加入了Camera相关新特性,在做开发过程中,遇到闪光灯的操作,如下: 1.导入包: import android.hardware.camera2.CameraManage ...

  3. Android教程 -05 Android6.0权限的管理

    视频为本篇博客知识的讲解,建议采用超清模式观看, 欢迎点击订阅我的优酷 height="498" width="510" src="http://pl ...

  4. Android系统下在te文件中为指定服务添加sepolicy权限

    [正文] 设备在播放视频时有异常,使用Logcat查看日志时发现了如下记录: 04-27 14:01:59.136 2825 2825 E SELinux : avc: denied { find } ...

  5. android fstab文件,[Android6.0][RK3399] fstab 文件格式说明和解析代码跟踪

    Author: Younix Platform: RK3399 OS: Android 6.0 Kernel: 4.4 Version: v2017.04 一.格式说明 以 RK3399 的 Andr ...

  6. [RK3288][Android6.0] 设置中通过Sensor旋转显示画面小结

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 Settings -> Display有个选项控制旋转屏幕时内容是否跟着旋转 这个功能是通过 ...

  7. 【Android】获取当前的app中cpu和内存的百分比 -调研报告

    背景 项目要求获取当前app运行时的cpu和内存状况. 调研 CPU获取 Android实现获取当前的app的cpu实时使用情况的代码 以下是获取当前app的CPU实时使用情况的代码(Java): p ...

  8. Linux/CentOS系统Tomcat 7/8.5/9部署SSL证书,端口为8443能够访问成功,换成443却访问失败

    一.登录阿里云账号,搜索SSL证书,可以购买免费版的证书 二.证书申请过程不再赘述,详细部署过程可以参照 Tomcat 7 版本:https://help.aliyun.com/document_de ...

  9. 声道切换 android,[RK3288][Android6.0] Audio中的单声道到双声道的转换处理过程

    Platform: Rockchip OS: Android 6.0 Kernel: 3.10.92 播放音乐是单声道,硬件用的是双声道. AudioFlinger::PlaybackThread:: ...

最新文章

  1. php好的mvc中index方法,创建一个mvc应用目录架构并创建入口文件index.php
  2. 消息服务发送短信,手机接收不到短信解决思路
  3. 【 FPGA 】四位16进制的数码管动态显示设计
  4. 调试兼容性该注意的的点
  5. 36.Silverlight中播放视频和打印文档【附带源码实例】
  6. 微信小程序支付java视频_【原创】微信小程序支付(普通模式,公众号支付同适用)java后台案例...
  7. 当当网新用户注册界面——界面源码
  8. ngnix 作用(通俗易懂)【转载】
  9. 为什么熊掌号没有了_为什么人类总吃食草动物,很少吃食肉动物?
  10. docker mysql5.7.19_Docker19.03.13下安装Mysql57
  11. 【图像处理】MATLAB:图像分割
  12. Linux 服务器感染kerberods 病毒
  13. 面试题--------4、数据类型
  14. Atitit 歌词成语提取项目 nlp 人工智能项目 目录 1.1. 流程 首先搜集3w成语词库 1 1.2. 歌词常用成语400个 按照拼音排序 1 1.1.流程 首先搜集3w成语词库 放入m
  15. 多系统精密星历下载与分析
  16. 国际科学数据服务平台nbsp;-nbsp;csdb
  17. 数据结构java实验_20172301 《Java软件结构与数据结构》实验一报告
  18. 理解PHP网页运行原理
  19. 8.3 机器人平台设计之arduino与电机驱动
  20. 视觉基础:关于机器视觉、机器学习及人工智能领域

热门文章

  1. TVP5158的多路复用技术
  2. [读书笔记] - 《深度探索C++对象模型》第2章 构造函数语意学
  3. linux 列表看多个文件数量,查看linux默认能最多开启多少个文件数量
  4. c语言编程 排序,C语言编程-9_3 排序
  5. 调试WebApi的一些方法
  6. 线段树和zkw线段树
  7. UVa 1225 Digit Counting 题解
  8. 日期多选插件Kalendae.js
  9. Angular2 依赖注入
  10. jQuery插件_SuperSlide插件(焦点图切换、标签切换、多个slide组合)