手机ROM,RAM作假显示

本文介绍了如何通过修改手机内核代码和应用程序来实现手机ROM和RAM内存大小的虚假显示。具体涉及修改内核文件`/kernel-3.10/fs/statfs.c`中的函数,以及调整Android系统的`ProjectManager.java`来控制不同UI下的内存显示。通过创建和读取特定文件,可以实现内存大小的伪装,从而改变用户在Settings、Manage apps和文件管理器中看到的内存信息。

                                           设置手机存储作假统一切换指令及接口

修改一套UI下的内存显示大小,Rom的显示是由"/system/private/.space"和"/system/private/.spaceinfo"的值控制的

一:电脑端
1.确定电脑端默认Rom大小
a. 打开 /kernel-3.10/fs/statfs.c 。(该文件无法使用项目宏,可做分支)

查看 logonum[] 的值是否为:"/proc/env_logo_id" ,与 /frameworks/base/core/java/android/os/ProjectManager.java中
writeLogoId(int value)方法的文件路径要一样。

b.
注意一下变量 :
static char filepath[] = "/system/private/.space";
static char realfilepath[] = "/system/private/.spaceinfo";
static char logonum[] = "/proc/env_logo_id";

缓存的大小 : static char buf[16];

c.读取logoid的方法 : static int zhanFan_readLogo(char *path)


d.在user_statfs(const char __user *pathname, struct kstatfs *st)函数中修改,包括默认UI或指定UI下的Rom,方法如下

int user_statfs(const char __user *pathname, struct kstatfs *st)
{
    struct path path;
    int error;
    unsigned int lookup_flags = LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT;
retry:
    error = user_path_at(AT_FDCWD, pathname, lookup_flags, &path);
    if (!error) {
        error = vfs_statfs(&path, st);
        path_put(&path);
        if (retry_estale(error, lookup_flags)) {
            lookup_flags |= LOOKUP_REVAL;
            goto retry;
        }
    }


    int type = -1;
    u64 customizedSize128G = 128*1024;
    u64 customizedSize64G = 64*1024;
    u64 customizedSize32G = 32*1024;
    u64 customizedSize16G = 16*1024;
    u64 customizedSize8G = 8*1024;
    u64 customizedSize4G = 4*1024;
    u64 asize = 1024;
    u64 bsize = 4096;
    u64 orgblocks = st->f_blocks;//手机的真实Rom大小
    char *filterpath = "/mnt/shell/emulated";
    if (strcmp(pathname,"/data/log_temp/boot/") != 0){
        printk("zhanfan orgblocks = %lld \n",orgblocks);//真实Rom大小
        printk("zhanfan st->f_bsize = %ld \n",st->f_bsize);//区块大小
        printk("zhanfan st->f_bfree = %lld \n",st->f_bfree);//真实可用Rom大小
        printk("zhanfan st->f_bavail = %lld \n",st->f_bavail);
    }

if (strcmp(pathname,filterpath) == 0
        || strcmp(pathname,"/data") == 0
        || strcmp(pathname,"/data/media") == 0
        || strcmp(pathname,"/storage/sdcard0") == 0){
        zhanFan_getNameByPid(sys_getpid(),cmdlinebuff,pnamebuff,sizeof(cmdlinebuff));
        if (zhanFan_checkPIDName(pnamebuff) && zhanFan_readSpaceFile() != 1 ){
            type = zhanFan_readSpaceFile();  //读取".space"文件,获得数据比较运算,反馈给电脑端作假后的Rom值
            if (type == 4){
                st->f_blocks = (customizedSize4G*asize*asize/bsize);
            }else if (type == 8){
                st->f_blocks = (customizedSize8G*asize*asize/bsize);
            }else if (type == 16){
                st->f_blocks = (customizedSize16G*asize*asize/bsize);
            }else if (type == 32){
                st->f_blocks = (customizedSize32G*asize*asize/bsize);
            }else if (type == 64){
                st->f_blocks = (customizedSize64G*asize*asize/bsize);
            }else if (type == 128){
                st->f_blocks = (customizedSize128G*asize*asize/bsize);
            }else{
                    if( zhanFan_readLogoFile() == -1 || zhanFan_readLogoFile() == 12){//默认UI时logoid为-1  
                        if((st->f_blocks > 0) && (st->f_blocks < (customizedSize4G*asize*asize/bsize))) {//真实Rom在0到4G之间
                            st->f_blocks = (customizedSize4G*asize*asize/bsize);
                        } else if((st->f_blocks > (customizedSize4G*asize*asize/bsize)) && (st->f_blocks < (customizedSize8G*asize*asize/bsize))) {
                            st->f_blocks = (customizedSize8G*asize*asize/bsize);
                        }  
                    } else if(zhanFan_readLogoFile() == 21){//UI_21时 返回16G
                        st->f_blocks = (customizedSize16G*asize*asize/bsize);
                    } else if(zhanFan_readLogoFile() == 22){//UI_22时 返回16G
                        st->f_blocks = (customizedSize64G*asize*asize/bsize);
                    } else {
                        st->f_blocks = (customizedSize8G*asize*asize/bsize);
                    }
                printk("zhanfan st->f_blocks = %lld \n",st->f_blocks);//查看作假Rom的大小
                printk("zhanfan zhanFan_readLogoFile() = %d \n",zhanFan_readLogoFile());//查看logo_id
            }

            u64 result = 0;
            result = st->f_blocks - orgblocks;//作假Rom和真实Rom的差值给可用内存做补指
            st->f_bfree += result;//作假Rom可用内存
            st->f_bavail += result;
        }
    }
    
    以上方法解析: 以上是对可用内存做减法运算,显示可用内存很大
                orgblocks : 手机的真实Rom大小
                zhanFan_readLogoFile() == -1 默认UI时logoid为-1
                
                一下是对可用内存做乘法运算,显示可用内存根据作假总Rom的变化而变化
                /*
                    u64 result = 0;
                    result = st->f_blocks;
                    do_div(result,orgblocks);//算出真实Rom和作假Rom的比值
                    st->f_bfree = st->f_bfree*result;//真实可用Rom乘上比值,获得作假可用Rom
                    st->f_bavail = st->f_bavail*result;
                 */
               
e.
编译 : make kernel
然后 : make bootimage
烧入手机

二:统一切换指令

a.打开/frameworks/base/core/java/android/os/ProjectManager.java
    /**
     * Rom ;文件不存在时,获取各分支或UI 下的Rom默认值大小,
     * 没有文件时,参与统一切换指令的显示方法,
     * 要与/kernel-3.10/fs/statfs.c中各UI的默认值保持一致
     * ROM 1 (真实), 4 (4G),8 (8G) ,16(16G) ,32(32G),64(64G),128(128G) 没文件时读到 8
     *
     */
    private static final String INTERNAL_DIR = "/system/private/";
    private static final String SPACE_FILE_NAME = ".space";
    public static int getRomSpace(){
        byte rom_flag = 0;
        File rom_File = new File(INTERNAL_DIR,SPACE_FILE_NAME);
        //if file not exist,first write
        if(!rom_File.exists()){
            if(FeatureOption.CUSTOM_PROJECT_C && isUi22() ){
                return 128;//返回 默认128G
            } else if(FeatureOption.CUSTOM_PROJECT_B ){
                return 64;//返回 默认64G
            } else if( FeatureOption.CUSTOM_PROJECT_A && isUi13() ) ){
                return 32;//返回 默认32G
            } else if( FeatureOption.CUSTOM_PROJECT_A && isUi17() ){
                return 16;//返回 默认16G
            } else if(FeatureOption.CUSTOM_PROJECT_C && isUi12() ){
                if(getRealBigToailSpace()){//根据判断返回 4G / 8G
                    return 8;//返回 默认8G
                }
                return 4;//返回 默认4G
            }
            return 8;
        }
        try {
            FileInputStream fis = new FileInputStream(rom_File);
            rom_flag = (byte)fis.read();
            fis.close();
        } catch (Exception e) {
            Log.e(TAG,"readRomSpace e " + e.toString());
        }
        Log.e(TAG,"space="+rom_flag);
        return (int)rom_flag;
    }
    
    
    /**
     * getTrueRomValue
     * 是否大于4G 大于时 返回 1 小于4G时 返回 0;
     *
     */
    public static int getTrueRomValue() {
        // 获取可用磁盘大小类
        StatFs statFs = new StatFs(Environment.getDataDirectory().getAbsolutePath());
        // 获取可用区块的个数
        long count = statFs.getBlockCount();
        // 获取区块的大小
        long size = statFs.getBlockSize();
        // 区块大小*可用区块个数 == 可用空间大小
        long totalRom = count * size / 1073741824;
        // Integer.MAX_VALUE 代表int类型数据的最大大小
        // 0x7FFFFFFF
        //
        // 2147483647bytes/1024 = 2096128 KB
        // 2096128KB/1024 = 2047 MB
        // 2047MB = 2G
        if( totalRom > 0 && totalRom < 4 ){
            return 0;
        }
        return 1;
    }
    
    
b.打开/packages/apps/BuiltInData/模块 统一指令Rom

    1.打开/packages/apps/BuiltInData/java/res/values/arrays.xml
        <string-array name="switch_rom_qhd">
            <item>normal</item>
            <item>128G</item>
            <item>64G</item>
            <item>32G</item>
            <item>16G</item>
            <item>8G</item>
            <item>4G</item>
        </string-array>
        <string-array name="switch_rom_values">
            <item>0</item>
            <item>1</item>
            <item>2</item>
            <item>3</item>
            <item>4</item>
            <item>5</item>
            <item>6</item>
        </string-array>
        
        <string-array name="switch_rom_large">
            <item>normal</item>
            <item>128G</item>
            <item>64G</item>
            <item>32G</item>
            <item>16G</item>
            <item>8G</item>
        </string-array>
        <string-array name="switch_rom_values_large">
            <item>0</item>
            <item>1</item>
            <item>2</item>
            <item>3</item>
            <item>4</item>
            <item>5</item>
        </string-array>
       

    2.打开/packages/apps/BuiltInData/java/src/com/android/builtindata/ProjectSwitchMenu.java
    
    在方法protected void onCreate(Bundle savedInstanceState)中
   

        //根据ProjectManager.getTrueRomValue()获取真实Rom是否是大于4G,加载不同的数组,自适应省略4G选项
        if( ProjectManager.getTrueRomValue() ){
            ROMSWITCH_UIQHD_LARGE=mContext.getResources().getTextArray(R.array.switch_rom_large);
            ROMSWITCH_UIQHD_VALUES_LARGE=mContext.getResources().getTextArray(R.array.switch_rom_values_large);
        } else {
            ROMSWITCH_UIQHD=mContext.getResources().getTextArray(R.array.switch_rom_qhd);
            ROMSWITCH_UIQHD_VALUES=mContext.getResources().getTextArray(R.array.switch_rom_values);
        }
        
        //加载数据到romListPreference中
        if(ProjectManager.getTrueRomValue()){
            romListPreference.setEntryValues(ROMSWITCH_UIQHD_VALUES_LARGE);
            romListPreference.setEntries(ROMSWITCH_UIQHD_LARGE);
        } else {
            romListPreference.setEntryValues(ROMSWITCH_UIQHD_VALUES);
            romListPreference.setEntries(ROMSWITCH_UIQHD);
        }
        
        //读取ProjectManager.readRomSpace(),获取需求Rom的值
        int romValues=ProjectManager.readRomSpace();
        romValues=Math.abs(romValues);
        
        if(romValues == 1){//normal 选项,显示1.61GB  /   5.13GB
            romValues=0;
        }else if(romValues==128){//128G选项
            romValues=1;
        }else if(romValues==64){//64G选项
            romValues=2;
        }else if(romValues==32){//32G选项
            romValues=3;
        }else if(romValues==16){//16G选项
            romValues=4;
        }else if(romValues==8){//8G选项
            romValues=5;
        }else if(romValues==4){//4G选项
            romValues=6;
        }else{
            romValues=5;
        }
        //经过转换,匹配数组数据,显示手机当前的Rom大小
        romListPreference.setValue(romValues+"");
        if( ProjectManager.getTrueRomValue() ){
            romListPreference.setSummary(contentString+ROMSWITCH_UIQHD_LARGE[romValues]);
            //Log.d("wangwei log","contentString+ROMSWITCH_UIQHD_LARGE[romValues]"+contentString+ROMSWITCH_UIQHD_LARGE[romValues]);
        } else {
            romListPreference.setSummary(contentString+ROMSWITCH_UIQHD[romValues]);
            //Log.d("wangwei log","contentString+ROMSWITCH_UIQHD[romValues]"+contentString+ROMSWITCH_UIQHD[romValues]);
        }
        
        
    在方法 public boolean onPreferenceChange(Preference mPre, Object objectValues) 中
   
String key = mPre.getKey();
        int values = Integer.parseInt(objectValues.toString());
        currentValues=values;
        if (key.equals(SWITCH_ROM_KEY)) {
            Intent intent;
            switch (values) {//为了拨号盘可以直接输入指令*#*#0270#*#* 直接切换Rom,发广播写文件
            case 0:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0210"));
                break;
            case 1:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION , Uri.parse("android_secret_code://0270"));
                break;
            case 2:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0260"));
                break;
            case 3:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0250"));
                break;
            case 4:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0240"));
                break;
            case 5:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0230"));
                break;
            case 6:
                intent = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://0220"));
                
                break;
            default:
                break;
            }
                sendBroadcast(intent);
                if( ProjectManager.getTrueRomValue() ){
                    romListPreference.setSummary(contentString+ROMSWITCH_UIQHD_LARGE[values]);
                } else {
                    romListPreference.setSummary(contentString+ROMSWITCH_UIQHD[values]);
                }

        }
        
        
        3.打开/packages/apps/BuiltInData/java/src/com/android/builtindata/SwitchBootAnimation.java
            private void saveSpaceFile(int space)
        {
            try
            {
                File space_file = new File("/system/private/", ".space");

                if( !space_file.exists() )
                {
                    space_file.createNewFile();
                }

                byte BufToWrite[] = new byte[1];

                BufToWrite[0] = (byte)space;


                FileOutputStream fos = new FileOutputStream(space_file, false);
                BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fos);
                bufferedOutputStream.write(BufToWrite, 0, BufToWrite.length);
                bufferedOutputStream.flush();
                bufferedOutputStream.close();

            }

            catch (Exception e) {
                Log.e(TAG, "Exception Occured: Trying to write logo id file " + e.toString());
            }

            try {
                Process p = Runtime.getRuntime().exec("chmod 644 " + "/system/private/.space");
                int status = p.waitFor();
                if (status == 0) {
                    Log.e(TAG,"chmod succeed");
                } else {
                    Log.e(TAG,"chmod failed");
                }
            } catch (Exception e) {
                Log.e(TAG,
                        "Exception Occured: Trying to chmod 777 logo id file "
                        + e.toString());
            }
        
            Toast.makeText(mContext,space+"G OK", Toast.LENGTH_SHORT).show();
        }
        
        4.在点击发生后,发广播,给 ".space" 文件写值,并更新romListPreference的显示
        
        5.编模块 : mmm packages/apps/BuiltInData/
        6.使用adb 推送进手机 : adb push out/target/product/gxq6580_weg_l/system/app/BuiltInData/BuiltInData.apk /system/app/BuiltInData/BuiltInData.apk
    
c : 统一指令Ram
        
        1.打开/frameworks/base/core/java/android/os/ProjectManager.java
            
            /**
             * getRamSpace 设置Ram的大小,
             * ram_flag : 0 (真实), 1 (4G),2 (3G) ,3(2G) ,4(1G),5(512M) 没文件时读到 4
             *
             */
            private static final String CUSTOM_RAM_FILE_NAME = ".rammodefile";
            public static int getRamSpace(){
                byte ram_flag = 0;
                File file = new File(INTERNAL_DIR,CUSTOM_RAM_FILE_NAME);
        
                if(!file.exists()){
                    if(FeatureOption.CUSTOM_PROJECT_C && !isUi12() ){
                        return 1;//返回默认 4G
                    } else if(FeatureOption.CUSTOM_PROJECT_B ){
                        return 2;//返回默认 3G
                    } else if( FeatureOption.CUSTOM_PROJECT_A && isUi13() ){
                        return 3;//返回默认 2G

                    } else if(FeatureOption.CUSTOM_PROJECT_C && isUi12() ){
                        if(getTrueRamValue() == 1){//根据真实ram的大小返回 1G / 512M
                            return 4;//返回默认 1G
                        } else if(getTrueRamValue() == 0){
                            return 5;//返回默认 512M
                        }
                    }
                    return 4;
                }
        
                try {
                    FileInputStream fis = new FileInputStream(file);
                    ram_flag = (byte)fis.read();
                    fis.close();
                } catch (Exception e) {
                    Log.e(TAG,"getRAMMode e " + e.toString());
                }
                return (int)ram_flag;
            }
           

           /**
             * getTrueRamValue 获取RAM真实信息
             * ram_flag : Ram为1G时 返回1 Ram为512M时 返回0
             *
             */
            private static MemInfoReader mMemInfoReader;
            public static int getTrueRamValue(){
                if(mMemInfoReader == null){
                    mMemInfoReader = new MemInfoReader();
                    mMemInfoReader.readMemInfo();
                }
                float totalRam = mMemInfoReader.getTotalSize()/((long)(1024*1024));
                if(totalRam > 0 && totalRam <= 512){
                    return 0;//512M
                }else if(totalRam > 512 && totalRam <= 1024){
                    return 1;//1G
                }
                return 0;
            }
            
        1.打开/packages/apps/BuiltInData/java/res/values/arrays.xml
            <string-array name="switch_ram">
                <item>normal</item>
                <item>4G</item>
                <item>3G</item>
                <item>2G</item>
                <item>1G</item>
                <item>512M</item>
            </string-array>
            <string-array name="switch_ram_values">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
            </string-array>
            
            <string-array name="switch_ram_large">
                <item>normal</item>
                <item>4G</item>
                <item>3G</item>
                <item>2G</item>
                <item>1G</item>
            </string-array>
            <string-array name="switch_ram_values_large">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
            </string-array>
    
        2.打开/packages/apps/BuiltInData/java/src/com/android/builtindata/ProjectSwitchMenu.java
            
            //两套数组分别加载数据
            RAMSWITCH_UIQHD=mContext.getResources().getTextArray(R.array.switch_ram);
            RAMSWITCH_UIQHD_LARGE=mContext.getResources().getTextArray(R.array.switch_ram_large);
            RAMSWITCH_UIQHD_VALUES = mContext.getResources().getTextArray(R.array.switch_ram_values);
            RAMSWITCH_UIQHD_VALUES_LARGE = mContext.getResources().getTextArray(R.array.switch_ram_values_large);
            
            在方法private void init()中
            
            //按ProjectManager.getTrueRamValue() == 0 判断 ramListPreference 是否出现有512M 选项的列表
            int ramMode=ProjectManager.getRamSpace();
            ramListPreference.setValue(ramMode+"");
            if(ProjectManager.getTrueRamValue() == 0){
                ramListPreference.setEntryValues(RAMSWITCH_UIQHD_VALUES);
                   ramListPreference.setEntries(RAMSWITCH_UIQHD);
                ramListPreference.setSummary(contentString+RAMSWITCH_UIQHD[ramMode]);
            } else {
                ramListPreference.setEntryValues(RAMSWITCH_UIQHD_VALUES_LARGE);
                   ramListPreference.setEntries(RAMSWITCH_UIQHD_LARGE);
                ramListPreference.setSummary(contentString+RAMSWITCH_UIQHD_LARGE[ramMode]);
            }
            
            在方法onPreferenceChange(Preference mPre, Object objectValues)中
            
            if (key.equals(SWITCH_RAM_KEY)) {
                writeRamInfo(values);
            }
            
            方法writeRamInfo(int size) :
            private static final String CUSTOM_RAM_FILE_NAME = ".rammodefile";
            private static final String INTERNAL_FILE_PATH = "/system/private/";
            /**
             * writeRamInfo 给".rammodefile"文件写入RAM信息
             *
             */
            public static void writeRamInfo(int size){
                byte buf[] = new byte[1];
                buf[0] = (byte)size;
                File file = new File(INTERNAL_FILE_PATH, CUSTOM_RAM_FILE_NAME);
                try {
                    FileOutputStream fos = new FileOutputStream(file, false);
                    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fos);
                    bufferedOutputStream.write(buf, 0, buf.length);
                    bufferedOutputStream.flush();
                    bufferedOutputStream.close();

                    fos.close();
                } catch (Exception e) {
                    Log.e(TAG,
                            "Exception Occured: Trying to write projectName "
                            + e.toString());
                }
                try {
                    Process p = Runtime.getRuntime().exec("chmod 644 " + INTERNAL_FILE_PATH+CUSTOM_RAM_FILE_NAME);
                    int status = p.waitFor();
                    if (status == 0) {
                        //chmod succeed
                        Log.e(TAG,"chmod succeed");
                        Toast.makeText(mContext, "SUCCESS", 1000).show();    
                        if(ProjectManager.getTrueRamValue() == 0){
                            ramListPreference.setSummary(contentString+RAMSWITCH_UIQHD[currentValues]);
                        } else {
                            ramListPreference.setSummary(contentString+RAMSWITCH_UIQHD_LARGE[currentValues]);
                        }
               

                    } else {
                        //chmod failed
                        Log.e(TAG,"chmod failed");
                        Toast.makeText(mContext, "FAILED", 1000).show();    
                    }
                } catch (Exception e) {
                    Log.e(TAG,
                            "Exception Occured: Trying to write logo_choice.file "
                            + e.toString());
                }
            }
    
        4.在点击发生后,给 ".rammodefile" 文件写值,确定真实Ram,并更新romListPreference的显示
        
        5.编模块 : mmm packages/apps/BuiltInData/
        6.使用adb 推送进手机 : adb push out/target/product/gxq6580_weg_l/system/app/BuiltInData/BuiltInData.apk /system/app/BuiltInData/BuiltInData.apk
    
d : 统一指令 网络 3G / 4G
        
        1.打开/frameworks/base/core/java/android/os/ProjectManager.java
            
            /**
             * readGTypeFlag 0 关闭 , 3 3G, 4 4G , 5 4G LTE
             * @hide
             */    
            private static final String GTYPE_FILE_NAME = "GTypeFlag";
            public static int readGTypeFlag()
            {
                byte flag = 0;
                File file = new File(INTERNAL_DIR,GTYPE_FILE_NAME);

                if(!file.exists()) {
                    if(FeatureOption.CUSTOM_PROJECT_B){
                        return 4;//默认开启4G LTE
                    }else if(FeatureOption.CUSTOM_PROJECT_A){
                        return 4;//默认开启4G LTE
                    }else if(FeatureOption.CUSTOM_PROJECT_C){
                        if(isUi12()){
                            return 0;//welcome 下 默认真实
                        }
                        return 4;//其他 开启4G LTE
                    }
                    return 0;//默认开启真实值
                }
                try {
                    FileInputStream fis = new FileInputStream(file);
                    flag = (byte)fis.read();
                    fis.close();
                } catch (Exception e) {
                    Log.e(TAG,"readGTypeFlag e " + e.toString());

                    return -1;
                }
                Log.e(TAG," readGTypeFlag flag="+flag);
                  
                return (int)flag;
            }
            
        1.打开/packages/apps/BuiltInData/java/res/values/arrays.xml
            <string-array name="switch_fake">
                <item>Normal</item>
                <item>3G</item>
                <item>Single 4G LTE</item>
                <item>Double 4G</item>
            </string-array>
            <string-array name="switch_fake_values">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
            </string-array>
    
        2.打开/packages/apps/BuiltInData/java/src/com/android/builtindata/ProjectSwitchMenu.java
            
            //两套数组分别加载数据
            FAKESWITCH=mContext.getResources().getTextArray(R.array.switch_fake);
            
            在方法private void init()中
            
            //按 fakeValues 判断 fakeListPreference 是否出现有512M 选项的列表
            int fakeValues=ProjectManager.readGTypeFlag();
            //Log.d("ww_log","fakeValues : "+fakeValues);
            if(fakeValues==0){
                fakeValues=0;       //Normal
            }else if(fakeValues==3){
                fakeValues=1;       //3G
            }else if(fakeValues==5){
                fakeValues=2;       //Single 4G LTE
            }else if(fakeValues==4){
                fakeValues=3;       //Double 4G
            }else{
                fakeValues=0;
            }
            //Log.d("ww_log","计算后fakeValues : "+fakeValues);
            fakeListPreference.setValue(fakeValues+"");
            fakeListPreference.setSummary(contentString+FAKESWITCH[fakeValues]);
            
            在方法onPreferenceChange(Preference mPre, Object objectValues)中
            
            if (key.equals(SWITCH_FAKE_KEY)) {
                switch (values) {
                case 0:
                    Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://05"));//normal
                    sendBroadcast(intent);

                    break;
                case 1:
                    Intent intent1 = new Intent(TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://03"));//3G
                    sendBroadcast(intent1);


                    break;
                case 2:
                    Intent intent2 = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://06"));//SINGLE 4G LTE
                    sendBroadcast(intent2);
                    break;
                case 3:
                    Intent intent3 = new Intent( TelephonyIntents.SECRET_CODE_ACTION, Uri.parse("android_secret_code://04"));//double 4G
                    sendBroadcast(intent3);
                    break;
                default:
                    break;
                }
                fakeListPreference.setSummary(contentString+FAKESWITCH[values]);
            }
            
            打开/packages/apps/BuiltInData/java/src/com/android/builtindata/Switch3GIcon.java
                在方法onReceive(Context context, Intent intent)中
                if (host != null){
                    if (host.equals("04")){//Double 4G
                        writeGTypeFlag(4);
                        SystemProperties.set("ctl.start","writedata:/system/private/GTypeFlag 4");
                        Toast.makeText(context, "4G Type Open 4", 1000).show();    
                    }else if (host.equals("03")){// 3G
                        writeGTypeFlag(3);
                        SystemProperties.set("ctl.start","writedata:/system/private/GTypeFlag 3");
                        Toast.makeText(context, "3G Type Open 3", 1000).show();
                    }else if (host.equals("05")){// 关闭
                        writeGTypeFlag(0);
                        SystemProperties.set("ctl.start","writedata:/system/private/GTypeFlag 0");
                        Toast.makeText(context, "G Type Close 0", 1000).show();
                    }else if (host.equals("06")){// Single 4G LTE
                        writeGTypeFlag(5);
                        Toast.makeText(context, "Single 4G LTE Type Open 5", 1000).show();
                    }
                    intent = new Intent("android.intent.action.SWITCH_SIGNAL_CHANGE");
                    mContext.sendBroadcast(intent);
                }
                
                // 0 关闭
                // 3 3G
                // 4 4G
                //private static final String C8_FILE_NAME = "ClientId83GFlag";
                private static final String GTYPE_FILE_NAME = "GTypeFlag";
                public static void writeGTypeFlag(int name)
                {
                    byte buf[] = new byte[1];

                    buf[0] = (byte)name;
                    File file = new File(INTERNAL_FILE_PATH, GTYPE_FILE_NAME);
                    try {
                        FileOutputStream fos = new FileOutputStream(file, false);
                        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fos);
                        bufferedOutputStream.write(buf, 0, buf.length);
                        bufferedOutputStream.flush();
                        bufferedOutputStream.close();

                        fos.close();
                    } catch (Exception e) {
                        Log.e(TAG,
                                "Exception Occured: Trying to write projectName "
                                + e.toString());
                    }
                    //Toast.makeText(mContext, "Succeed", 1000).show();   

                    try {
                        Process p = Runtime.getRuntime().exec("chmod 644 " + INTERNAL_FILE_PATH+GTYPE_FILE_NAME);
                        int status = p.waitFor();
                        if (status == 0) {
                            //chmod succeed
                            Log.e(TAG,"chmod succeed");
                        } else {
                            //chmod failed
                            Log.e(TAG,"chmod failed");
                        }
                    } catch (Exception e) {
                        Log.e(TAG,
                                "Exception Occured: Trying to write logo_choice.file "
                                + e.toString());
                    }
                }
    
        4.在点击发生后,给 "GTypeFlag" 文件写值,发送广播,并更新romListPreference的显示
        
        5.编模块 : mmm packages/apps/BuiltInData/
        6.使用adb 推送进手机 : adb push out/target/product/gxq6580_weg_l/system/app/BuiltInData/BuiltInData.apk /system/app/BuiltInData/BuiltInData.apk
    
二:设置
    a.作假Settings -> Storage 中Rom内存显示
        打开/packages/apps/Settings/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
            /*
            mItemAvailable.setSummary(formatSize((long)Math.abs(details.totalSize)));    //显示为7.95GB/15.95GB
            */
            
            DecimalFormat fnum = new DecimalFormat("##0.00");
            Log.d("ww_log","StorageVolumePreferenceCategory size : " + details.totalSize);
            String stringSize=fnum.format(setStorage(details.totalSize));
            mItemTotal.setSummary(stringSize +"GB");
            
            /**
             * setStorage 格式化Rom值的显示,把kernel中读出的7.95GB转化成8GB等,当需要显示真实值时,直接返回kernel的真实值
             */
            public double setStorage(long totalSize){
                double size=(double)totalSize / 1073741824.0;
                if( ProjectManager.getRomSpace() == 1 )  return size ;
                if( (int)size >= 1 && (int)size <= 4) size=4;
                if( (int)size > 4 && (int)size <= 8) size=8;
                if( (int)size > 8 && (int)size <= 16) size=16;
                if( (int)size > 16 && (int)size <= 32) size=32;
                if( (int)size > 32 && (int)size <= 64) size=64;
                if( (int)size > 64 && (int)size <= 128) size=128;
                return (double)size ;
            }
   

    b.作假Settings -> Manage apps -> Running 的Ram显示
        1.打开/frameworks/base/core/java/android/os/ProjectManager.java
            //RAM 0 (真实), 1 (4G),2 (3G) ,3(2G) ,4(1G),5(512M) 没文件时读到 4
            //获得手机运行内存倍数
            public static float getRamMul(float realSize){
                float mul = 0.5f;
                //add by zbp 根据真实信息定义倍率
                if(getTrueRamValue() == 1){
                    mul = 0.5f;//真实内存为1G的倍率
                }else if(getTrueRamValue() == 0){
                    mul = 1.0f;//真实内存为512M的倍率
                }else{
                    mul = 1.0f;
                }
                //对应BuiltInData下的Ram切换
                if(getRAMMode() == 0)//对应真实值
                    mul = 1.0f;
                else if(getRAMMode() == 5)//512MB
                    mul = mul;
                else if (getRAMMode() == 4)//1GB
                    mul = 2*mul;        
                else if (getRAMMode() == 3)//2GB
                    mul = 4*mul;    
                else if (getRAMMode() == 2)//3GB
                    mul = 6*mul;    
                else if (getRAMMode() == 1)//4GB
                    mul = 8*mul;        
                return mul;
            }
            
        2.打开/packages/apps/Settings/src/com/android/settings/applications/RunningProcessesView.java
            在方法void refreshUi(boolean dataChanged)中
            
            float multSize = ProjectManager.getRamMul((float)totalRam);//比例参数
            参与System(highRam) Apps(medRam) Free(lowRam)  (totalRam)的运算
            
        3.编模块 : mmm packages/apps/Settings/
        4.使用adb 推送进手机 : adb push out/target/product/gxq6580_weg_l/system/priv-app/Settings/Settings.apk /system/priv-app/Settings
        
三:文件管理器Rom
    1.打开/vendor/mediatek/proprietary/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoAdapter.java
        在方法 setSizeText(TextView textView,ImageView imageView, FileInfo fileInfo) 中
        /*
        String stringSize=FileUtils.sizeToString((long)Math.abs(totalSpace));//显示为7.95GB/15.95GB
        */
        
        DecimalFormat fnum = new DecimalFormat("##0.00");
        Log.d("ww_log"," totalSpace : " + totalSpace);
        String stringSize=fnum.format(setStorage(totalSpace));
        
        /**
         * setStorage 格式化Rom值的显示,把kernel中读出的7.95GB转化成8GB等,当需要显示真实值时,直接返回kernel的真实值
         */
        public static double setStorage(long totalSize){
            double size=(double)totalSize / 1073741824.0;
            if( ProjectManager.getRomSpace() == 1 )  return size ;
            if( (int)size >= 1 && (int)size <= 4) size=4;
            if( (int)size > 4 && (int)size <= 8) size=8;
            if( (int)size > 8 && (int)size <= 16) size=16;
            if( (int)size > 16 && (int)size <= 32) size=32;
            if( (int)size > 32 && (int)size <= 64) size=64;
            if( (int)size > 64 && (int)size <= 128) size=128;
            return (double)size ;
        }
        
    2.编模块 : mmm vendor/mediatek/proprietary/packages/apps/FileManager/
    3.使用adb 推送进手机 : adb push out/target/product/gxq6580_weg_l/system/app/FileManager/FileManager.apk /system/app/FileManager/FileManager.apk

#### 以上做法仅适用于4GB/8GB的Rom和512MB/1GB的Ram 的手机









评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值