Home | History | Annotate | Download | only in pm
      1 /**
      2  * Copyright (c) 2017, 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 package android.content.pm;
     17 
     18 import android.annotation.NonNull;
     19 import android.annotation.Nullable;
     20 import android.annotation.TestApi;
     21 import android.content.Intent;
     22 import android.os.Parcel;
     23 import android.os.Parcelable;
     24 
     25 import java.util.List;
     26 
     27 /**
     28  * Packages that have been changed since the last time they
     29  * were requested.
     30  * @see PackageManager#getChangedPackages(int)
     31  */
     32 public final class ChangedPackages implements Parcelable {
     33     /** The last known sequence number for these changes */
     34     private final int mSequenceNumber;
     35     /** The names of the packages that have changed */
     36     private final List<String> mPackageNames;
     37 
     38     public ChangedPackages(int sequenceNumber, @NonNull List<String> packageNames) {
     39         this.mSequenceNumber = sequenceNumber;
     40         this.mPackageNames = packageNames;
     41     }
     42 
     43     /** @hide */
     44     protected ChangedPackages(Parcel in) {
     45         mSequenceNumber = in.readInt();
     46         mPackageNames = in.createStringArrayList();
     47     }
     48 
     49     @Override
     50     public int describeContents() {
     51         return 0;
     52     }
     53 
     54     @Override
     55     public void writeToParcel(Parcel dest, int flags) {
     56         dest.writeInt(mSequenceNumber);
     57         dest.writeStringList(mPackageNames);
     58     }
     59 
     60     /**
     61      * Returns the last known sequence number for these changes.
     62      */
     63     public int getSequenceNumber() {
     64         return mSequenceNumber;
     65     }
     66 
     67     /**
     68      * Returns the names of the packages that have changed.
     69      */
     70     public @NonNull List<String> getPackageNames() {
     71         return mPackageNames;
     72     }
     73 
     74     public static final Parcelable.Creator<ChangedPackages> CREATOR =
     75             new Parcelable.Creator<ChangedPackages>() {
     76         public ChangedPackages createFromParcel(Parcel in) {
     77             return new ChangedPackages(in);
     78         }
     79 
     80         public ChangedPackages[] newArray(int size) {
     81             return new ChangedPackages[size];
     82         }
     83     };
     84 }
     85