Home | History | Annotate | Download | only in pm
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.content.pm;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 /**
     23  * implementation of PackageStats associated with a
     24  * application package.
     25  */
     26 public class PackageStats implements Parcelable {
     27     /** Name of the package to which this stats applies. */
     28     public String packageName;
     29 
     30     /** Size of the code (e.g., APK) */
     31     public long codeSize;
     32 
     33     /**
     34      * Size of the internal data size for the application. (e.g.,
     35      * /data/data/<app>)
     36      */
     37     public long dataSize;
     38 
     39     /** Size of cache used by the application. (e.g., /data/data/<app>/cache) */
     40     public long cacheSize;
     41 
     42     /**
     43      * Size of the secure container on external storage holding the
     44      * application's code.
     45      */
     46     public long externalCodeSize;
     47 
     48     /**
     49      * Size of the external data used by the application (e.g.,
     50      * <sdcard>/Android/data/<app>)
     51      */
     52     public long externalDataSize;
     53 
     54     /**
     55      * Size of the external cache used by the application (i.e., on the SD
     56      * card). If this is a subdirectory of the data directory, this size will be
     57      * subtracted out of the external data size.
     58      */
     59     public long externalCacheSize;
     60 
     61     /** Size of the external media size used by the application. */
     62     public long externalMediaSize;
     63 
     64     /** Size of the package's OBBs placed on external media. */
     65     public long externalObbSize;
     66 
     67     public static final Parcelable.Creator<PackageStats> CREATOR
     68             = new Parcelable.Creator<PackageStats>() {
     69         public PackageStats createFromParcel(Parcel in) {
     70             return new PackageStats(in);
     71         }
     72 
     73         public PackageStats[] newArray(int size) {
     74             return new PackageStats[size];
     75         }
     76     };
     77 
     78     public String toString() {
     79         final StringBuilder sb = new StringBuilder("PackageStats{");
     80         sb.append(Integer.toHexString(System.identityHashCode(this)));
     81         sb.append(" packageName=");
     82         sb.append(packageName);
     83         sb.append(",codeSize=");
     84         sb.append(codeSize);
     85         sb.append(",dataSize=");
     86         sb.append(dataSize);
     87         sb.append(",cacheSize=");
     88         sb.append(cacheSize);
     89         sb.append(",externalCodeSize=");
     90         sb.append(externalCodeSize);
     91         sb.append(",externalDataSize=");
     92         sb.append(externalDataSize);
     93         sb.append(",externalCacheSize=");
     94         sb.append(externalCacheSize);
     95         sb.append(",externalMediaSize=");
     96         sb.append(externalMediaSize);
     97         sb.append(",externalObbSize=");
     98         sb.append(externalObbSize);
     99         return sb.toString();
    100     }
    101 
    102     public PackageStats(String pkgName) {
    103         packageName = pkgName;
    104     }
    105 
    106     public PackageStats(Parcel source) {
    107         packageName = source.readString();
    108         codeSize = source.readLong();
    109         dataSize = source.readLong();
    110         cacheSize = source.readLong();
    111         externalCodeSize = source.readLong();
    112         externalDataSize = source.readLong();
    113         externalCacheSize = source.readLong();
    114         externalMediaSize = source.readLong();
    115         externalObbSize = source.readLong();
    116     }
    117 
    118     public PackageStats(PackageStats pStats) {
    119         packageName = pStats.packageName;
    120         codeSize = pStats.codeSize;
    121         dataSize = pStats.dataSize;
    122         cacheSize = pStats.cacheSize;
    123         externalCodeSize = pStats.externalCodeSize;
    124         externalDataSize = pStats.externalDataSize;
    125         externalCacheSize = pStats.externalCacheSize;
    126         externalMediaSize = pStats.externalMediaSize;
    127         externalObbSize = pStats.externalObbSize;
    128     }
    129 
    130     public int describeContents() {
    131         return 0;
    132     }
    133 
    134     public void writeToParcel(Parcel dest, int parcelableFlags){
    135         dest.writeString(packageName);
    136         dest.writeLong(codeSize);
    137         dest.writeLong(dataSize);
    138         dest.writeLong(cacheSize);
    139         dest.writeLong(externalCodeSize);
    140         dest.writeLong(externalDataSize);
    141         dest.writeLong(externalCacheSize);
    142         dest.writeLong(externalMediaSize);
    143         dest.writeLong(externalObbSize);
    144     }
    145 }
    146