搜索

28

主题

32

帖子

322

积分

中级会员

Rank: 3Rank: 3

积分
322
发表于 2021-11-4 09:52:03 2049 浏览 0 回复

android 6.0内置存储作假显示

本帖最后由 jiangyajun 于 2021-11-5 15:29 编辑

1.添加全局变量persist.sys.rom作为要修改的rom值
  1. diff --git a/build/tools/buildinfo.sh b/build/tools/buildinfo.sh
  2. index 5c199b8..610b9d5 100755
  3. --- a/build/tools/buildinfo.sh
  4. +++ b/build/tools/buildinfo.sh
  5. @@ -55,5 +55,5 @@ if [ -n "$BUILD_THUMBPRINT" ] ; then
  6.    echo "ro.build.thumbprint=$BUILD_THUMBPRINT"
  7. fi
  8. echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
  9. -
  10. +echo "persist.sys.rom=64"
  11. echo "# end build properties"
复制代码



2。修改TextView源码替换安兔兔显示的存储值

  1. diff --git a/frameworks/base/core/java/android/widget/TextView.java b/frameworks/base/core/java/android/widget/TextView.java
  2. old mode 100644
  3. new mode 100755
  4. index 59bfe9d..7ee2a62
  5. --- a/frameworks/base/core/java/android/widget/TextView.java
  6. +++ b/frameworks/base/core/java/android/widget/TextView.java
  7. @@ -3950,8 +3950,29 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
  8.          if (!(mText instanceof Editable)) {
  9.              setText(mText, BufferType.EDITABLE);
  10.          }
  11. -
  12. +               
  13.          ((Editable) mText).append(text, start, end);
  14. +               //add by jyj
  15. +               String textstring;
  16. +               if(mContext.getPackageName().equals("com.antutu.ABenchMark") && (text != "")){
  17. +                       //android.util.Log.i("TextView","===text==="+text+"getid()=="+getId());
  18. +                       textstring = getText().toString();
  19. +                       android.util.Log.i("TextView","===StringBuilder==="+textstring);
  20. +                       if(textstring.trim().toLowerCase().contains("gb")){
  21. +                               int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
  22. +                               android.util.Log.i("TextView","===rom==="+rom);
  23. +                               if(rom==0)return;
  24. +                               //textstring = textstring.trim().toLowerCase();
  25. +                               float total = Float.parseFloat(textstring.substring(textstring.indexOf("/")+1,textstring.indexOf("G")));
  26. +                               if(total<5)return;
  27. +                               float avilab = Float.parseFloat(textstring.substring(0,textstring.indexOf("/")));
  28. +                               float value = total-avilab;
  29. +                               android.util.Log.i("TextView","===text==="+String.valueOf(rom-(total-avilab))+"/"+String.valueOf(total)+"GB");
  30. +                               setText(String.valueOf(rom-(total-avilab))+"/"+String.valueOf(rom)+"GB");
  31. +                       }
  32. +               }
  33. +               
  34. +               //end by jyj
  35.      }

  36.      private void updateTextColors() {
复制代码




3.修改settings里的存储值
  1. diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
  2. old mode 100644
  3. new mode 100755
  4. index b82728a..e5105cc
  5. --- a/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
  6. +++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
  7. @@ -227,8 +227,20 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
  8.          final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
  9.          mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),
  10.                  result.value, result.units));
  11. -        mSummary.setSummary(getString(R.string.storage_volume_used,
  12. -                Formatter.formatFileSize(context, totalBytes)));
  13. +               //modify by jyj         
  14. +        //mSummary.setSummary(getString(R.string.storage_volume_used,
  15. +                //Formatter.formatFileSize(context, totalBytes)));
  16. +               int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
  17. +               if(rom!=0){
  18. +                       mSummary.setSummary(getString(R.string.storage_volume_used,
  19. +                "64GB"));
  20. +                       android.util.Log.i("statfs","usedBytes=="+TextUtils.expandTemplate(getText(R.string.storage_size_large),
  21. +                                       result.value, result.units));
  22. +                       android.util.Log.i("statfs","totalBytes=="+getString(R.string.storage_volume_used,
  23. +                                       Formatter.formatFileSize(context, totalBytes)));
  24. +               }
  25. +               //end   
  26. +      
  27.          mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));

  28.          mMeasure.forceMeasure();
复制代码
diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java b/packages/apps/Settings/src/com/android/settings/deviceinfo/
old mode 100644
new mode 100755
index 42be1fb..832f2ec
--- a/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -220,9 +220,13 @@ 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)));
-
+        //mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
+                //Formatter.formatFileSize(context, privateTotalBytes)));
+               int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
+               if(rom!=0){
+                       mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,
+                rom+"GB"));
+               }      
         if (mInternalCategory.getPreferenceCount() > 0) {
             getPreferenceScreen().addPreference(mInternalCategory);
         }
longrz@xy10:/b1/longrz/MT8735/M0/WTK8735_6TTB_M$ git diff packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreference.java
diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreference.java b/packages/apps/Settings/src/com/android/settings/devicei
old mode 100644
new mode 100755
index 543f7c5..f0b0d4e
--- a/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreference.java
+++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreference.java
@@ -73,7 +73,14 @@ 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 by jyj
+                       int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
+                       if(volume.getType() == VolumeInfo.TYPE_PRIVATE&&rom!=0){
+                               setSummary(context.getString(R.string.storage_volume_summary, used, rom+"GB"));                                 
+                       }else{
+                               setSummary(context.getString(R.string.storage_volume_summary, used, total));
+                       }
+                       //end
             if (totalBytes != 0) {
                 mUsedPercent = (int) ((usedBytes * 100) / totalBytes);
             }



4.修改FileManager的存储值
diff --git a/vendor/mediatek/proprietary/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoAdapter.java b/vendor/mediatek/proprietary/packages/ap
old mode 100644
new mode 100755
index 47b8813..7a03b38
--- a/vendor/mediatek/proprietary/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoAdapter.java
+++ b/vendor/mediatek/proprietary/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoAdapter.java
@@ -326,6 +326,17 @@ public class FileInfoAdapter extends BaseAdapter {
                 LogUtils.d(TAG, "setSizeText, freeSpace = " + MountPointManager.getInstance().getMountPointFreeSpace(fileInfo.getFileAbsolutePath()) + ",tota
                         + MountPointManager.getInstance().getMountPointTotalSpace(fileInfo.getFileAbsolutePath()));

+                               //add by jyj
+                               long freeSpace = MountPointManager.getInstance().getMountPointFreeSpace(fileInfo.getFileAbsolutePath());
+                               long totalSpace = MountPointManager.getInstance().getMountPointTotalSpace(fileInfo.getFileAbsolutePath());
+                               if(fileInfo.getFileAbsolutePath().equals("/storage/emulated/0")){
+                                       int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
+                                       long totalSize = rom*1024L*1024*1024L;
+                                       long freeSize = totalSize-(totalSpace-freeSpace);
+                                       freeSpaceString = FileUtils.sizeToString(freeSize);
+                                       totalSpaces = FileUtils.sizeToString(totalSize);
+                               }
+                               //end
                 sb.append(mResources.getString(R.string.free_space)).append(" ");
                 sb.append(freeSpaceString).append(" \n");
                 sb.append(mResources.getString(R.string.total_space)).append(" ");



5.修改usb链接电脑显示的存储值

diff --git a/frameworks/av/media/mtp/MtpServer.cpp b/frameworks/av/media/mtp/MtpServer.cpp
index 913cd84..58def1b 100755
--- a/frameworks/av/media/mtp/MtpServer.cpp
+++ b/frameworks/av/media/mtp/MtpServer.cpp
@@ -576,8 +576,30 @@ MtpResponseCode MtpServer::doGetStorageInfo() {
     mData.putUInt16(storage->getType());
     mData.putUInt16(storage->getFileSystemType());
     mData.putUInt16(storage->getAccessCapability());
-    mData.putUInt64(storage->getMaxCapacity());
-    mData.putUInt64(storage->getFreeSpace());
+       //add by jyj
+       char prop_value[PROPERTY_VALUE_MAX];
+       int prop_value_int=1;
+       property_get("persist.sys.rom", prop_value, "0");
+       prop_value_int=atoi(prop_value);
+       const char *rpath = "/storage/emulated/0";
+       const char *mpath = storage->getPath();
+       int result = strcmp(rpath,mpath);
+       ALOGD("doGetStorageInfo: MaxCapacity = %ld", storage->getMaxCapacity());
+       ALOGD("doGetStorageInfo: getDescription = %s,result= %d", storage->getPath(),result);
+       ALOGD("doGetStorageInfo: FreeSpace = %ld", storage->getFreeSpace());
+       ALOGD("doGetStorageInfo: romtotal = %ld", prop_value_int*1024*1024*1024);
+       ALOGD("doGetStorageInfo: romfree = %ld", (uint64_t)prop_value_int*1024*1024*1024-(storage->getMaxCapacity()-storage->getFreeSpace()));
+       if(prop_value_int != 0&&result==0){
+               mData.putUInt64((uint64_t)prop_value_int*1024*1024*1024);
+               mData.putUInt64((uint64_t)prop_value_int*1024*1024*1024-(storage->getMaxCapacity()-storage->getFreeSpace()));
+       }else{
+               mData.putUInt64(storage->getMaxCapacity());
+               mData.putUInt64(storage->getFreeSpace());
+       }
+    //mData.putUInt64(storage->getMaxCapacity());
+    //mData.putUInt64(storage->getFreeSpace());
+      
+      
     mData.putUInt32(1024*1024*1024); // Free Space in Objects
     string.set(storage->getDescription());
     mData.putString(string);







回复

使用道具 举报

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

本版积分规则


登录或注册
快速回复 返回顶部 返回列表