码迷,mamicode.com
首页 > 移动开发 > 详细

Android 7.1 emmc 存储总大小

时间:2021-04-30 12:44:10      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:sum   systems   hand   emmc   nal   app   primary   port   storage   

一.adb 命令

cat /proc/partitions
mmcblk1 mmcblk2

 二.Andoird 7.1.1  以上查询

7.1.1 版本之后才有  getPrimaryStorageSize()

2.1. packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java

import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import android.os.storage.StorageManager;
import android.text.format.Formatter;
public class DeviceInfoSettings extends SettingsPreferenceFragment implements Indexable {
    private static final String LOG_TAG = "DeviceInfoSettings";
@@ -96,6 +99,9 @@
    
    private static DecimalFormat fileIntegerFormat = new DecimalFormat("#0");
    private static DecimalFormat fileDecimalFormat = new DecimalFormat("#0.#");
    
    private static StorageManager mStorageManager = null;
    private static long sTotalInternalStorage;
    public static String formatFileSize(long size, boolean isInteger) {
        DecimalFormat df = isInteger ? fileIntegerFormat : fileDecimalFormat;
@@ -203,6 +209,8 @@
        mUm = UserManager.get(getActivity());
        addPreferencesFromResource(R.xml.device_info_settings);
        
        mStorageManager = (StorageManager) getActivity().getSystemService(StorageManager.class);
        setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE);
        findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
@@ -224,7 +232,11 @@
        findPreference(KEY_SCREEN_FPS).setSummary(GetScreenFps());
        
            String emmcString=formatFileSize(getEmmc_total(), true);
        if (sTotalInternalStorage <= 0) {
            sTotalInternalStorage = mStorageManager.getPrimaryStorageSize() / 1024 / 1024 /1024;          
        }
        
            String emmcString=String.valueOf(sTotalInternalStorage);//formatFileSize(getEmmc_total(), true);
            
            int size=Integer.valueOf(emmcString);
            if(size<8)

2.2.eclipse

import java.lang.reflect.Method;
import android.content.Context;
import android.os.storage.StorageManager;

	// rk3399
	private static StorageManager mStorageManager = null;
	private static long sTotalInternalStorage;
	private Context mContext;
	private static long totalSize = 0L;
	
	

	// android7.1 RK391
	public DeviceInfo(Context mContext) {
		super();
		this.mContext = mContext;
		mStorageManager = (StorageManager) mContext.getSystemService(StorageManager.class);
		if (sTotalInternalStorage <= 0) {
			Log.d("gatsby", "sTotalInternalStorage<=0");
			try {
				Method getPrimaryStorageSize = StorageManager.class.getMethod("getPrimaryStorageSize");
				totalSize = (long) getPrimaryStorageSize.invoke(mStorageManager) / 1024 / 1024 / 1024;
				Log.d("gatsby", "totalSize->" + totalSize);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}

		}
	}

		String emmcString;
		if (product.contains(R391)) {
			emmcString = String.valueOf(totalSize);
			Log.d("gatsby", "emmcString->" + emmcString);
		}

  

  

  

Android 7.1 emmc 存储总大小

标签:sum   systems   hand   emmc   nal   app   primary   port   storage   

原文地址:https://www.cnblogs.com/crushgirl/p/14721395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!