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

 
-
+
 
     File Manager
     
@@ -126,4 +126,11 @@
     
     
 
+	
+	"4.00GB"
+	"8.00GB"
+	"16.00GB"
+	Use as ringtone
+	\"%s\" set as phone ringtone.
+
 

二)Setting

3.packages/apps/Settings/res/values/strings.xml

 	navigation bar
 	navigation bar can be hidden
 	
+    
+    
+    "Used of 16.00GB"
+    "Total used of 16.00GB"
+    "%1$s used of 16.00GB"
 	
+    "Used of 8.00GB"
+    "Total used of 8.00GB"
+    "%1$s used of 8.00GB"
+    
 

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),


你可能感兴趣的:(MTK随记)