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