标签: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); }
标签:sum systems hand emmc nal app primary port storage
原文地址:https://www.cnblogs.com/crushgirl/p/14721395.html