|
发表于 2021-11-4 09:52:03
2430 浏览 0 回复
android 6.0内置存储作假显示
本帖最后由 jiangyajun 于 2021-11-5 15:29 编辑
1.添加全局变量persist.sys.rom作为要修改的rom值
- diff --git a/build/tools/buildinfo.sh b/build/tools/buildinfo.sh
- index 5c199b8..610b9d5 100755
- --- a/build/tools/buildinfo.sh
- +++ b/build/tools/buildinfo.sh
- @@ -55,5 +55,5 @@ if [ -n "$BUILD_THUMBPRINT" ] ; then
- echo "ro.build.thumbprint=$BUILD_THUMBPRINT"
- fi
- echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
- -
- +echo "persist.sys.rom=64"
- echo "# end build properties"
复制代码
2。修改TextView源码替换安兔兔显示的存储值
- diff --git a/frameworks/base/core/java/android/widget/TextView.java b/frameworks/base/core/java/android/widget/TextView.java
- old mode 100644
- new mode 100755
- index 59bfe9d..7ee2a62
- --- a/frameworks/base/core/java/android/widget/TextView.java
- +++ b/frameworks/base/core/java/android/widget/TextView.java
- @@ -3950,8 +3950,29 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
- if (!(mText instanceof Editable)) {
- setText(mText, BufferType.EDITABLE);
- }
- -
- +
- ((Editable) mText).append(text, start, end);
- + //add by jyj
- + String textstring;
- + if(mContext.getPackageName().equals("com.antutu.ABenchMark") && (text != "")){
- + //android.util.Log.i("TextView","===text==="+text+"getid()=="+getId());
- + textstring = getText().toString();
- + android.util.Log.i("TextView","===StringBuilder==="+textstring);
- + if(textstring.trim().toLowerCase().contains("gb")){
- + int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
- + android.util.Log.i("TextView","===rom==="+rom);
- + if(rom==0)return;
- + //textstring = textstring.trim().toLowerCase();
- + float total = Float.parseFloat(textstring.substring(textstring.indexOf("/")+1,textstring.indexOf("G")));
- + if(total<5)return;
- + float avilab = Float.parseFloat(textstring.substring(0,textstring.indexOf("/")));
- + float value = total-avilab;
- + android.util.Log.i("TextView","===text==="+String.valueOf(rom-(total-avilab))+"/"+String.valueOf(total)+"GB");
- + setText(String.valueOf(rom-(total-avilab))+"/"+String.valueOf(rom)+"GB");
- + }
- + }
- +
- + //end by jyj
- }
- private void updateTextColors() {
复制代码
3.修改settings里的存储值
- diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
- old mode 100644
- new mode 100755
- index b82728a..e5105cc
- --- a/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
- +++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
- @@ -227,8 +227,20 @@ 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,
- - Formatter.formatFileSize(context, totalBytes)));
- + //modify by jyj
- + //mSummary.setSummary(getString(R.string.storage_volume_used,
- + //Formatter.formatFileSize(context, totalBytes)));
- + int rom = android.os.SystemProperties.getInt("persist.sys.rom",0);
- + if(rom!=0){
- + mSummary.setSummary(getString(R.string.storage_volume_used,
- + "64GB"));
- + android.util.Log.i("statfs","usedBytes=="+TextUtils.expandTemplate(getText(R.string.storage_size_large),
- + result.value, result.units));
- + android.util.Log.i("statfs","totalBytes=="+getString(R.string.storage_volume_used,
- + Formatter.formatFileSize(context, totalBytes)));
- + }
- + //end
- +
- mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
- 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);
|
|