Home | History | Annotate | Download | only in content
      1 /*
      2  * Copyright (C) 2009 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;
     18 
     19 import android.accounts.Account;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * Information about the sync operation that is currently underway.
     25  */
     26 public class SyncInfo implements Parcelable {
     27     /** @hide */
     28     public final int authorityId;
     29 
     30     /**
     31      * The {@link Account} that is currently being synced.
     32      */
     33     public final Account account;
     34 
     35     /**
     36      * The authority of the provider that is currently being synced.
     37      */
     38     public final String authority;
     39 
     40     /**
     41      * The start time of the current sync operation in milliseconds since boot.
     42      * This is represented in elapsed real time.
     43      * See {@link android.os.SystemClock#elapsedRealtime()}.
     44      */
     45     public final long startTime;
     46 
     47     /** @hide */
     48     public SyncInfo(int authorityId, Account account, String authority, long startTime) {
     49         this.authorityId = authorityId;
     50         this.account = account;
     51         this.authority = authority;
     52         this.startTime = startTime;
     53     }
     54 
     55     /** @hide */
     56     public SyncInfo(SyncInfo other) {
     57         this.authorityId = other.authorityId;
     58         this.account = new Account(other.account.name, other.account.type);
     59         this.authority = other.authority;
     60         this.startTime = other.startTime;
     61     }
     62 
     63     /** @hide */
     64     public int describeContents() {
     65         return 0;
     66     }
     67 
     68     /** @hide */
     69     public void writeToParcel(Parcel parcel, int flags) {
     70         parcel.writeInt(authorityId);
     71         parcel.writeParcelable(account, flags);
     72         parcel.writeString(authority);
     73         parcel.writeLong(startTime);
     74     }
     75 
     76     /** @hide */
     77     SyncInfo(Parcel parcel) {
     78         authorityId = parcel.readInt();
     79         account = parcel.readParcelable(Account.class.getClassLoader());
     80         authority = parcel.readString();
     81         startTime = parcel.readLong();
     82     }
     83 
     84     /** @hide */
     85     public static final Creator<SyncInfo> CREATOR = new Creator<SyncInfo>() {
     86         public SyncInfo createFromParcel(Parcel in) {
     87             return new SyncInfo(in);
     88         }
     89 
     90         public SyncInfo[] newArray(int size) {
     91             return new SyncInfo[size];
     92         }
     93     };
     94 }
     95