码迷,mamicode.com
首页 > 其他好文 > 详细

应用设置之属性、名词等解析

时间:2014-10-09 18:34:57      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:des   android   style   blog   http   color   io   使用   ar   

一、一级界面显示的条目数据大小,指的是哪里?

是否存在模拟存储区 = 存储空间是否含有模拟存储区。

假如(含有模拟存储区){
     大小 = Size_Total;
}否则{
    大小 = Size_Internal;
}

如果应用程序存在于SD卡中,则:大小 = Size_External;

二、名词解释,以及所代表的存储空间。

public class PackageStats{
    /** Size of the code (e.g., APK) */
    public long codeSize;//apk的大小

    /**
     * Size of the internal data size for the application. (e.g.,
     * /data/data/<app>)
     */
    public long dataSize;//内部数据。/data/data/<packageName>

    /** Size of cache used by the application. (e.g., /data/data/<app>/cache) */
    public long cacheSize;//内部数据。/data/data/<packageName>/cache

    /**
     * Size of the secure container on external storage holding the
     * application‘s code.
     */
    public long externalCodeSize;//外部代码大小。例如下载的插件、资源等。以及移动到sd中的应用

    /**
     * Size of the external data used by the application (e.g.,
     * <sdcard>/Android/data/<app>)
     */
    public long externalDataSize;//外部数据大小。<sdcard>/Android/data/<packageName>

    /**
     * Size of the external cache used by the application (i.e., on the SD
     * card). If this is a subdirectory of the data directory, this size will be
     * subtracted out of the external data size.
     */
    public long externalCacheSize;//外部缓冲数据大小。如果此目录是externalDataSize的子目录,则此大小包含在externalDataSize中。

    /** Size of the external media size used by the application. */
    public long externalMediaSize;//外部媒体大小。

    /** Size of the package‘s OBBs placed on external media. */
    public long externalObbSize;//外部Obb大小。

三、 大小的计算方式。

内部数据大小 =  codeSize + dataSize。
外部数据大小 =  externalCodeSize + externalDataSize +externalCachaSize + externalMediaSize + externalObbSize。
应用大小(默认计算方式) = externalCodeSize + externalDataSize + codeSize + dataSize。

四、正在运行的服务排序方式。

参考资料:http://blog.csdn.net/jk2255cl/article/details/11682429
4、1:正在 运行的服务排序。
class ServiceProcessComparator implements Comparator<ProcessItem> {
        public int compare(ProcessItem object1, ProcessItem object2) {
            if (object1.mUserId != object2.mUserId) {//用户ID
                if (object1.mUserId == mMyUserId) return -1;
                if (object2.mUserId == mMyUserId) return 1;
                return object1.mUserId < object2.mUserId ? -1 : 1;
            }
            if (object1.mIsStarted != object2.mIsStarted) {//线程是否启动
                // Non-started processes go last.
                return object1.mIsStarted ? -1 : 1;
            }
            if (object1.mIsSystem != object2.mIsSystem) {//是否为系统进程
                // System processes go below non-system.
                return object1.mIsSystem ? 1 : -1;
            }
            if (object1.mActiveSince != object2.mActiveSince) {//服务activie的时间
                // Remaining ones are sorted with the longest running
                // services last.
                return (object1.mActiveSince > object2.mActiveSince) ? -1 : 1;
            }
            return 0;
        }
    }

4.2:显示后台线程后排序
final Comparator<RunningState.MergedItem> mBackgroundComparator
        = new Comparator<RunningState.MergedItem>() {
            @Override
            public int compare(MergedItem lhs, MergedItem rhs) {
                if (lhs.mUserId != rhs.mUserId) {//用户ID
                    if (lhs.mUserId == mMyUserId) return -1;
                    if (rhs.mUserId == mMyUserId) return 1;
                    return lhs.mUserId < rhs.mUserId ? -1 : 1;
                }
                if (lhs.mProcess == rhs.mProcess) {//如果同一个进程的 进程和服务,按照label进行排序
                    if (lhs.mLabel == rhs.mLabel) {
                        return 0;
                    }
                    return lhs.mLabel != null ? lhs.mLabel.compareTo(rhs.mLabel) : -1;
                }
                if (lhs.mProcess == null) return -1;//进程是否为null
                if (rhs.mProcess == null) return 1;
                if (DEBUG_COMPARE) Log.i(TAG, "    Label " + lhs.mProcess.mLabel
                        + " with " + rhs.mProcess.mLabel);
                final ActivityManager.RunningAppProcessInfo lhsInfo
                        = lhs.mProcess.mRunningProcessInfo;
                final ActivityManager.RunningAppProcessInfo rhsInfo
                        = rhs.mProcess.mRunningProcessInfo;
                final boolean lhsBg = lhsInfo.importance
                        >= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
                final boolean rhsBg = rhsInfo.importance
                        >= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
                        if (DEBUG_COMPARE) Log.i(TAG, "       Bg " + lhsBg + " with " + rhsBg);
                if (lhsBg != rhsBg) {
                    return lhsBg ? 1 : -1;//是否为后台线程
                }
                final boolean lhsA = (lhsInfo.flags
                        & ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
                final boolean rhsA = (rhsInfo.flags
                        & ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
                if (DEBUG_COMPARE) Log.i(TAG, "      Act " + lhsA + " with " + rhsA);
                if (lhsA != rhsA) {//是否关联到系统进程
                    return lhsA ? -1 : 1;
                }
                if (DEBUG_COMPARE) Log.i(TAG, "      Lru " + lhsInfo.lru + " with " + rhsInfo.lru);
                if (lhsInfo.lru != rhsInfo.lru) {//意味着是否近期频繁使用
                    return lhsInfo.lru < rhsInfo.lru ? -1 : 1;
                }
                if (lhs.mProcess.mLabel == rhs.mProcess.mLabel) {
                    return 0;
                }
                if (lhs.mProcess.mLabel == null) return 1;//名称字母
                if (rhs.mProcess.mLabel == null) return -1;
                return lhs.mProcess.mLabel.compareTo(rhs.mProcess.mLabel);
            }
    };

五、全部应用程序排序方式

按照大小、名称排序。mWhickSize取值参考一。等同于一中的大小。

按照名称进行排序:
public static final Comparator<AppEntry> ALPHA_COMPARATOR = new Comparator<AppEntry>() {
        private final Collator sCollator = Collator.getInstance();
        @Override
        public int compare(AppEntry object1, AppEntry object2) {
            final boolean normal1 = object1.info.enabled
                    && (object1.info.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
            final boolean normal2 = object2.info.enabled
                    && (object2.info.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
            if (normal1 != normal2) {
                return normal1 ? -1 : 1;
            }
            return sCollator.compare(object1.label, object2.label);
        }
    };
按照大小排序,按照存在位置,排序方式不同,规则如下:
                         switch (mWhichSize) {
                        case SIZE_INTERNAL:
                            comparatorObj = ApplicationsState.INTERNAL_SIZE_COMPARATOR;
                            break;
                        case SIZE_EXTERNAL:
                            comparatorObj = ApplicationsState.EXTERNAL_SIZE_COMPARATOR;
                            break;
                        default:
                            comparatorObj = ApplicationsState.SIZE_COMPARATOR;
                            break;
                    }

默认排序方式
public static final Comparator<AppEntry> SIZE_COMPARATOR
            = new Comparator<AppEntry>() {
        private final Collator sCollator = Collator.getInstance();
        @Override
        public int compare(AppEntry object1, AppEntry object2) {
            if (object1.size < object2.size) return 1;
            if (object1.size > object2.size) return -1;
            return sCollator.compare(object1.label, object2.label);
        }
    };
不含有模拟存储区
    public static final Comparator<AppEntry> INTERNAL_SIZE_COMPARATOR
            = new Comparator<AppEntry>() {
        private final Collator sCollator = Collator.getInstance();
        @Override
        public int compare(AppEntry object1, AppEntry object2) {
            if (object1.internalSize < object2.internalSize) return 1;
            if (object1.internalSize > object2.internalSize) return -1;
            return sCollator.compare(object1.label, object2.label);
        }
    };
sd卡存储区排序方式
    public static final Comparator<AppEntry> EXTERNAL_SIZE_COMPARATOR
            = new Comparator<AppEntry>() {
        private final Collator sCollator = Collator.getInstance();
        @Override
        public int compare(AppEntry object1, AppEntry object2) {
            if (object1.externalSize < object2.externalSize) return 1;
            if (object1.externalSize > object2.externalSize) return -1;
            return sCollator.compare(object1.label, object2.label);
        }
    }

应用设置之属性、名词等解析

标签:des   android   style   blog   http   color   io   使用   ar   

原文地址:http://www.cnblogs.com/yido9932/p/4013897.html

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