android手机存储8G\16G显示修改

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="urn:oasis: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),


评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

旧时旅人

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

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

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

打赏作者

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

抵扣说明:

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

余额充值