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 Hackborn
231b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana/**
241b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana * Information about the sync operation that is currently underway.
251b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana */
26c6a69559cb62bd20166c0c9684e64c60d779da38Fred Quintanapublic class SyncInfo implements Parcelable {
27d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    /** @hide */
28d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    public final int authorityId;
291b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
301b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /**
315a9decd589f3f6a512168fd669ee2c5d8daa238bMatthew Williams     * The {@link Account} that is currently being synced.
321b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana     */
33d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    public final Account account;
341b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
351b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /**
365a9decd589f3f6a512168fd669ee2c5d8daa238bMatthew Williams     * The authority of the provider that is currently being synced.
371b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana     */
38d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    public final String authority;
391b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
401b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /**
41d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana     * The start time of the current sync operation in milliseconds since boot.
42d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana     * This is represented in elapsed real time.
431b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana     * See {@link android.os.SystemClock#elapsedRealtime()}.
441b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana     */
45d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    public final long startTime;
461b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
471b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /** @hide */
485a9decd589f3f6a512168fd669ee2c5d8daa238bMatthew Williams    public SyncInfo(int authorityId, Account account, String authority, long startTime) {
49231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        this.authorityId = authorityId;
50231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        this.account = account;
51231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        this.authority = authority;
52231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        this.startTime = startTime;
53231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    }
541b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
551b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /** @hide */
56a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams    public SyncInfo(SyncInfo other) {
57a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams        this.authorityId = other.authorityId;
58a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams        this.account = new Account(other.account.name, other.account.type);
59a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams        this.authority = other.authority;
60a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams        this.startTime = other.startTime;
61a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams    }
62a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams
63a7456e46f4cb64524386b22e2596ea93c244c16fMatthew Williams    /** @hide */
64231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    public int describeContents() {
65231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        return 0;
66231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    }
67231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn
681b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /** @hide */
69231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    public void writeToParcel(Parcel parcel, int flags) {
70231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        parcel.writeInt(authorityId);
7156dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams        parcel.writeParcelable(account, flags);
72231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        parcel.writeString(authority);
73231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        parcel.writeLong(startTime);
74231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    }
75231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn
761b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /** @hide */
77d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    SyncInfo(Parcel parcel) {
78231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        authorityId = parcel.readInt();
7956dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams        account = parcel.readParcelable(Account.class.getClassLoader());
80231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        authority = parcel.readString();
81231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        startTime = parcel.readLong();
82231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    }
831b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana
841b487ec44b6b5594914d52fa427bec4f29a60541Fred Quintana    /** @hide */
85d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana    public static final Creator<SyncInfo> CREATOR = new Creator<SyncInfo>() {
86d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana        public SyncInfo createFromParcel(Parcel in) {
87d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana            return new SyncInfo(in);
88231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        }
89231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn
90d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana        public SyncInfo[] newArray(int size) {
91d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintana            return new SyncInfo[size];
92231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn        }
93231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn    };
946cb6f246fe9fa7bd2be88946f531a82576008be4Fred Quintana}
95