AI手机网,短视频直播 硬改改机 一键新机 群控软件 刷机定制

 找回密码
 立即注册
搜索
查看: 1969|回复: 0

安卓源码--修改存储大小-android手机存储8G\16G显示修改

[复制链接]
发表于 2018-11-13 10:01:50 | 显示全部楼层 |阅读模式
MTK

Android 7.0

80N

一)FileManager
1.vendor/mediatek/proprietary/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoAdapter.java

import java.util.ArrayList;
import java.util.List;

+// add for 8GB display at 20161013
+import android.os.SystemProperties;
+import android.util.Log;
+import android.os.Environment;
+import android.os.StatFs;
+import java.io.File;

public class FileInfoAdapter extends BaseAdapter {
     private static final String TAG = "FileInfoAdapter";
+       
+        // add for 8GB display at 20161013
+        private static final long SIZE_3GB = 3145728;
+        private static final long SIZE_7GB = 7340032;

     private static final int DEFAULT_SECONDARY_SIZE_TEXT_COLOR = 0xff414141;
     private static final int DEFAULT_PRIMARY_TEXT_COLOR = Color.BLACK;
@@ -319,6 +329,12 @@ public class FileInfoAdapter extends BaseAdapter {
         if (fileInfo.isDirectory()) {
             if (MountPointManager.getInstance().isMountPoint(fileInfo.getFileAbsolutePath())) {
                 StringBuilder sb = new StringBuilder();
+                               
+                                // add for 8GB display at 20161013
+                                long totalSize0 = MountPointManager.getInstance().getMountPointTotalSpace(fileInfo.getFileAbsolutePath());
+                                long totalSize1 = totalSize0 / 1024 ;
+                                Log.d("gqt666","totalSize1 = "+totalSize1);
+
                 String freeSpaceString = FileUtils.sizeToString(MountPointManager.getInstance().getMountPointFreeSpace(fileInfo.getFileAbsolutePath()));
                 String totalSpaces = FileUtils.sizeToString(MountPointManager.getInstance().getMountPointTotalSpace(fileInfo.getFileAbsolutePath()));
                 LogUtils.d(TAG, "setSizeText, file name = " + fileInfo.getFileName()
@@ -329,7 +345,23 @@ public class FileInfoAdapter extends BaseAdapter {
                 sb.append(mResources.getString(R.string.free_space)).append(" ");
                 sb.append(freeSpaceString).append(" \n");
                 sb.append(mResources.getString(R.string.total_space)).append(" ");
-                sb.append(totalSpaces).append(" ");
+                                // add for 8GB display at 20161013
+                                if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")||SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                                        if(getRomTotalSize().equals(totalSpaces)){
+                                                if(totalSize1 < SIZE_3GB){
+                                                        sb.append(mResources.getString(R.string.total_space_4GB)).append(" ");
+                                                }else if(totalSize1 < SIZE_7GB){
+                                                        sb.append(mResources.getString(R.string.total_space_8GB)).append(" ");
+                                                }else {
+                                                        sb.append(mResources.getString(R.string.total_space_16GB)).append(" ");
+                                                }
+                                        }else{
+                                                sb.append(totalSpaces).append(" ");
+                                        }
+                                }else{
+                                        sb.append(totalSpaces).append(" ");
+                                }
+                                // add end
                 textView.setText(sb.toString());
                 textView.setVisibility(View.VISIBLE);
             } else {
@@ -345,6 +377,16 @@ public class FileInfoAdapter extends BaseAdapter {
         }
     }

+        // add for 8GB display at 20161114
+        public String getRomTotalSize(){
+                File path=Environment.getDataDirectory();
+                StatFs statFs=new StatFs(path.getPath());
+                long blockSize=statFs.getBlockSizeLong();
+                long tatalBlocks= statFs.getBlockCountLong();
+                return FileUtils.sizeToString(blockSize*tatalBlocks);
+        }
+        // add end
+
     private void setIcon(FileViewHolder viewHolder, FileInfo fileInfo, int viewDirection) {
         Bitmap icon = IconManager.getInstance().getIcon(mResources, fileInfo, mService, viewDirection);

2.vendor/mediatek/proprietary/packages/apps/FileManager/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
-<resources>
+<resources xmlns:xliff="urnasis:names:tc:xliff:document:1.2">

     <string name="app_name">File Manager</string>
     <!-- Dialog title -->
@@ -126,4 +126,11 @@
     <!-- <string name="msg_change_name">Operation failed, please use a different name.</string> -->
     <!-- <string name="edit">Edit</string> -->

+        <!-- 20170424 -->
+        <string name="total_space_4GB">"4.00GB"</string>
+        <string name="total_space_8GB">"8.00GB"</string>
+        <string name="total_space_16GB">"16.00GB"</string>
+        <string name="ringtone_menu">Use as ringtone</string>
+        <string name="ringtone_set">\"<xliff:g id="name" example="Alarm Bell">%s</xliff:g>\" set as phone ringtone.</string>
+
</resources>

二)Setting
3.packages/apps/Settings/res/values/strings.xml

        <string name="dynamic_hide_navbar_title">navigation bar</string>
        <string name="dynamic_hide_navbar_summary">navigation bar can be hidden</string>
        <!--end-->
+   
+    <!-- add begin for 8GB 16GB display at 20170717 -->
+    <string name="storage_volume_used_16GB">"Used of 16.00GB"</string>
+    <string name="storage_volume_custom_total_16GB">"Total used of 16.00GB"</string>
+    <string name="storage_volume_summary_internal_16GB">"<xliff:g id="used" example="1.2GB">%1$s</xliff:g> used of 16.00GB"</string>
       
+    <string name="storage_volume_used_8GB">"Used of 8.00GB"</string>
+    <string name="storage_volume_custom_total_8GB">"Total used of 8.00GB"</string>
+    <string name="storage_volume_summary_internal_8GB">"<xliff:g id="used" example="1.2GB">%1$s</xliff:g> used of 8.00GB"</string>
+    <!-- end -->
</resources>

4.packages/apps/Settings/src/com/android/settings/applications/ProcessStatsSummary.java
import com.android.settings.applications.ProcStatsData.MemInfo;
import com.android.settings.dashboard.SummaryLoader;

+//add for 8GB 16GB display at 20170717
+import android.os.SystemProperties;
+
public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenceClickListener {

     private static final String KEY_STATUS_HEADER = "status_header";
@@ -92,7 +95,14 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
         mSummaryPref.setRatios(usedRatio, 0, 1 - usedRatio);

         mPerformance.setSummary(memString);
-        mTotalMemory.setSummary(totalString);
+                //add for 8GB 16GB display at 20170717

+                if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                        mTotalMemory.setSummary("2,0 GB");
+                }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                        mTotalMemory.setSummary("1,0 GB");
+                }else{
+                        mTotalMemory.setSummary(totalString);
+                }               
         mAverageUsed.setSummary(Utils.formatPercentage((long) usedRam, (long) totalRam));
         mFree.setSummary(freeString);
         String durationString = getString(sDurationLabels[mDurationIndex]);

5.packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
import com.mediatek.settings.UtilsExt;
import com.mediatek.settings.ext.IStorageSettingsExt;

+//add for 8GB 16GB display at 20170717
+import android.os.SystemProperties;
+
+
import java.io.File;
import java.util.HashMap;
import java.util.List;
@@ -244,8 +248,19 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
         final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
         mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
                 result.value, result.units));
-        mSummary.setSummary(getString(R.string.storage_volume_used,
+                // mSummary.setSummary(getString(R.string.storage_volume_used,
+                //            Formatter.formatFileSize(context, totalBytes)));
+               
+                // add begin for 8GB 16GB display at 20170717
+                if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                        mSummary.setSummary(getString(R.string.storage_volume_used_16GB));
+                }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                        mSummary.setSummary(getString(R.string.storage_volume_used_8GB));
+                }else{
+                        mSummary.setSummary(getString(R.string.storage_volume_used,
                 Formatter.formatFileSize(context, totalBytes)));
+                }
+                //add end
         mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
         mExt.updateCustomizedPrivateSettingsPlugin(screen, mVolume);
         mMeasure.forceMeasure();

6.packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.drawer.SettingsDrawerActivity;

+// add begin for 8GB 16GB display at 20170717
+import android.os.SystemProperties;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
@@ -232,9 +235,20 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
         final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);
         mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
                 result.value, result.units));
-        mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
-                Formatter.formatFileSize(context, privateTotalBytes)));
-        mExt.updateCustomizedStorageSettingsPlugin(mInternalCategory);
+        //mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
+        //        Formatter.formatFileSize(context, privateTotalBytes)));
+               
+                // add begin for 8GB 16GB display at 20170717
+                if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                        mInternalSummary.setSummary(getString(R.string.storage_volume_custom_total_16GB));
+                }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                        mInternalSummary.setSummary(getString(R.string.storage_volume_custom_total_8GB));
+                }else{
+                        mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
+                                    Formatter.formatFileSize(context, privateTotalBytes)));
+                }
+                //add end
+
         if (mInternalCategory.getPreferenceCount() > 0) {
             getPreferenceScreen().addPreference(mInternalCategory);
         }

7.packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreference.java
import java.io.File;

+// add begin for 8GB 16GB display at 20170717
+import android.util.Log;
+import android.os.SystemProperties;
+
/**
  * Preference line representing a single {@link VolumeInfo}, possibly including
  * quick actions like unmounting.
@@ -74,7 +78,23 @@ public class StorageVolumePreference extends Preference {

             final String used = Formatter.formatFileSize(context, usedBytes);
             final String total = Formatter.formatFileSize(context, totalBytes);
-            setSummary(context.getString(R.string.storage_volume_summary, used, total));
+
+                        // add begin for 8GB 16GB display at 20170717
+                        if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                                if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.getId())) {
+                                        setSummary(context.getString(R.string.storage_volume_summary_internal_16GB, used));
+                                }else{
+                                        setSummary(context.getString(R.string.storage_volume_summary, used, total));
+                                }
+                        }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                                                if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.getId())) {
+                                                        setSummary(context.getString(R.string.storage_volume_summary_internal_8GB, used));
+                                                }else{
+                                                        setSummary(context.getString(R.string.storage_volume_summary, used, total));
+                                                }
+                        }else {
+                                setSummary(context.getString(R.string.storage_volume_summary, used, total));
+                        }
             if (totalBytes > 0) {
                 mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
             }

由于7.0和6.0 Setting主界面布局有差距 增加以下:
8.packages/apps/Settings/src/com/android/settings/applications/ProcessStatsSummary.java

@@ -148,8 +148,19 @@ public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenc
                 MemInfo memInfo = statsManager.getMemInfo();
                 String usedResult = Formatter.formatShortFileSize(mContext,
                         (long) memInfo.realUsedRam);
-                String totalResult = Formatter.formatShortFileSize(mContext,
+                               // add begin for 8GB 16GB display at 20170717
+                String totalResult = "";
+                               if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                                               totalResult = Formatter.formatShortFileSize(mContext,
+                        Long.parseLong("2147483648"));
+                                       }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                                               totalResult = Formatter.formatShortFileSize(mContext,
+                        (long) 1073741824);
+                                       }else{
+                                               totalResult = Formatter.formatShortFileSize(mContext,
                         (long) memInfo.realTotalRam);
+                                       }
+                               //end
                 mSummaryLoader.setSummary(this, mContext.getString(R.string.memory_summary,
                         usedResult, totalResult));
             }

9.packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -538,7 +538,20 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
                     continue;
                 }
                 privateUsedBytes += path.getTotalSpace() - path.getFreeSpace();
-                privateTotalBytes += path.getTotalSpace();
+                               // add begin for 8GB 16GB display at 20170717
+                               if(info.getType() == VolumeInfo.TYPE_PRIVATE){
+                                       if(SystemProperties.get("ro.storage_show_system_space_16").equals("1")){
+                                               privateTotalBytes += Long.parseLong("17179869184");
+                                       }else if(SystemProperties.get("ro.storage_show_system_space_8").equals("1")){
+                                               privateTotalBytes += Long.parseLong("8589934592");
+                                       }else{
+                                               privateTotalBytes += path.getTotalSpace();
+                                       }
+                               }else{
+                                       privateTotalBytes += path.getTotalSpace();
+                               }
+                               //end
+               
             }
             mLoader.setSummary(this, mContext.getString(R.string.storage_summary,
                     Formatter.formatFileSize(mContext, privateUsedBytes),

---------------------


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

技术交流售后群

QQ|小黑屋|手机版|站点找错-建议|AI手机网 |Sitemap



GMT+8, 2024-4-26 04:16 , Processed in 0.138465 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表