SyncInfo.java revision a7456e46f4cb64524386b22e2596ea93c244c16f
1231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn/* 2231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Copyright (C) 2009 The Android Open Source Project 3231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 4231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 5231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * you may not use this file except in compliance with the License. 6231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * You may obtain a copy of the License at 7231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 8231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 9231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 10231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 11231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 12231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * See the License for the specific language governing permissions and 14231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * limitations under the License. 15231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 16231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 17231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornpackage android.content; 18231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 197a1355950172b7a549820e9a2cd4a9b2099ec32fDianne Hackbornimport android.accounts.Account; 20231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.os.Parcel; 21c6a69559cb62bd20166c0c9684e64c60d779da38Fred Quintanaimport android.os.Parcelable; 22231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.os.Parcelable.Creator; 23231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 241b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana/** 251b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana * Information about the sync operation that is currently underway. 261b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana */ 27c6a69559cb62bd20166c0c9684e64c60d779da38Fred Quintanapublic class SyncInfo implements Parcelable { 28d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana /** @hide */ 29d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public final int authorityId; 301b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 311b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** 32d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana * The {@link Account} that is currently being synced. 331b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana */ 34d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public final Account account; 351b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 361b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** 37d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana * The authority of the provider that is currently being synced. 381b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana */ 39d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public final String authority; 401b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 411b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** 42d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana * The start time of the current sync operation in milliseconds since boot. 43d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana * This is represented in elapsed real time. 441b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana * See {@link android.os.SystemClock#elapsedRealtime()}. 451b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana */ 46d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public final long startTime; 471b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 481b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** @hide */ 497a96c39c510923ef73bbb06ab20109f0168b8eb1Jeff Sharkey public SyncInfo(int authorityId, Account account, String authority, 50231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn long startTime) { 51231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn this.authorityId = authorityId; 52231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn this.account = account; 53231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn this.authority = authority; 54231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn this.startTime = startTime; 55231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 561b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 571b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** @hide */ 58a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams public SyncInfo(SyncInfo other) { 59a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams this.authorityId = other.authorityId; 60a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams this.account = new Account(other.account.name, other.account.type); 61a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams this.authority = other.authority; 62a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams this.startTime = other.startTime; 63a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams } 64a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams 65a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams /** @hide */ 66231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn public int describeContents() { 67231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn return 0; 68231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 69231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 701b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** @hide */ 71231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn public void writeToParcel(Parcel parcel, int flags) { 72231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn parcel.writeInt(authorityId); 737a1355950172b7a549820e9a2cd4a9b2099ec32fDianne Hackborn account.writeToParcel(parcel, 0); 74231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn parcel.writeString(authority); 75231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn parcel.writeLong(startTime); 76231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 77231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 781b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** @hide */ 79d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana SyncInfo(Parcel parcel) { 80231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn authorityId = parcel.readInt(); 817a1355950172b7a549820e9a2cd4a9b2099ec32fDianne Hackborn account = new Account(parcel); 82231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn authority = parcel.readString(); 83231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn startTime = parcel.readLong(); 84231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 851b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana 861b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana /** @hide */ 87d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public static final Creator<SyncInfo> CREATOR = new Creator<SyncInfo>() { 88d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public SyncInfo createFromParcel(Parcel in) { 89d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana return new SyncInfo(in); 90231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 91231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 92d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana public SyncInfo[] newArray(int size) { 93d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana return new SyncInfo[size]; 94231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn } 95231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn }; 966cb6f246fe9fa7bd2be88946f531a82576008be4Fred Quintana} 97