Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 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; |
Fred Quintana | c6a6955 | 2010-09-27 17:05:04 -0700 | [diff] [blame] | 21 | import android.os.Parcelable; |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Information about the sync operation that is currently underway. |
| 25 | */ |
Fred Quintana | c6a6955 | 2010-09-27 17:05:04 -0700 | [diff] [blame] | 26 | public class SyncInfo implements Parcelable { |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 27 | /** @hide */ |
| 28 | public final int authorityId; |
| 29 | |
| 30 | /** |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 31 | * The {@link Account} that is currently being synced. Will be null if this sync is running via |
| 32 | * a {@link SyncService}. |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 33 | */ |
| 34 | public final Account account; |
| 35 | |
| 36 | /** |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 37 | * The authority of the provider that is currently being synced. Will be null if this sync |
| 38 | * is running via a {@link SyncService}. |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 39 | */ |
| 40 | public final String authority; |
| 41 | |
| 42 | /** |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 43 | * The {@link SyncService} that is targeted by this operation. Null if this sync is running via |
| 44 | * a {@link AbstractThreadedSyncAdapter}. |
| 45 | */ |
| 46 | public final ComponentName service; |
| 47 | |
| 48 | /** |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 49 | * The start time of the current sync operation in milliseconds since boot. |
| 50 | * This is represented in elapsed real time. |
| 51 | * See {@link android.os.SystemClock#elapsedRealtime()}. |
| 52 | */ |
| 53 | public final long startTime; |
| 54 | |
| 55 | /** @hide */ |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 56 | public SyncInfo(int authorityId, Account account, String authority, ComponentName service, |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 57 | long startTime) { |
| 58 | this.authorityId = authorityId; |
| 59 | this.account = account; |
| 60 | this.authority = authority; |
| 61 | this.startTime = startTime; |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 62 | this.service = service; |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /** @hide */ |
Matthew Williams | a7456e4 | 2013-11-12 14:41:02 -0800 | [diff] [blame] | 66 | public SyncInfo(SyncInfo other) { |
| 67 | this.authorityId = other.authorityId; |
| 68 | this.account = new Account(other.account.name, other.account.type); |
| 69 | this.authority = other.authority; |
| 70 | this.startTime = other.startTime; |
Matthew Williams | ee7081d | 2013-11-14 11:52:58 -0800 | [diff] [blame] | 71 | this.service = other.service; |
Matthew Williams | a7456e4 | 2013-11-12 14:41:02 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** @hide */ |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 75 | public int describeContents() { |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | /** @hide */ |
| 80 | public void writeToParcel(Parcel parcel, int flags) { |
| 81 | parcel.writeInt(authorityId); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 82 | parcel.writeParcelable(account, flags); |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 83 | parcel.writeString(authority); |
| 84 | parcel.writeLong(startTime); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 85 | parcel.writeParcelable(service, flags); |
| 86 | |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /** @hide */ |
| 90 | SyncInfo(Parcel parcel) { |
| 91 | authorityId = parcel.readInt(); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 92 | account = parcel.readParcelable(Account.class.getClassLoader()); |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 93 | authority = parcel.readString(); |
| 94 | startTime = parcel.readLong(); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 95 | service = parcel.readParcelable(ComponentName.class.getClassLoader()); |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /** @hide */ |
| 99 | public static final Creator<SyncInfo> CREATOR = new Creator<SyncInfo>() { |
| 100 | public SyncInfo createFromParcel(Parcel in) { |
| 101 | return new SyncInfo(in); |
| 102 | } |
| 103 | |
| 104 | public SyncInfo[] newArray(int size) { |
| 105 | return new SyncInfo[size]; |
| 106 | } |
| 107 | }; |
| 108 | } |