blob: 146dd99e9ef7bf84613ab7366aeb06ea6ec55c51 [file] [log] [blame]
Fred Quintanad5e4fdc2010-03-30 15:16:21 -07001/*
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
17package android.content;
18
19import android.accounts.Account;
20import android.os.Parcel;
Fred Quintanac6a69552010-09-27 17:05:04 -070021import android.os.Parcelable;
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070022
23/**
24 * Information about the sync operation that is currently underway.
25 */
Fred Quintanac6a69552010-09-27 17:05:04 -070026public class SyncInfo implements Parcelable {
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070027 /** @hide */
28 public final int authorityId;
29
30 /**
Matthew Williams56dbf8f2013-07-26 12:56:39 -070031 * The {@link Account} that is currently being synced. Will be null if this sync is running via
32 * a {@link SyncService}.
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070033 */
34 public final Account account;
35
36 /**
Matthew Williams56dbf8f2013-07-26 12:56:39 -070037 * The authority of the provider that is currently being synced. Will be null if this sync
38 * is running via a {@link SyncService}.
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070039 */
40 public final String authority;
41
42 /**
Matthew Williams56dbf8f2013-07-26 12:56:39 -070043 * 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 Quintanad5e4fdc2010-03-30 15:16:21 -070049 * 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 Williams56dbf8f2013-07-26 12:56:39 -070056 public SyncInfo(int authorityId, Account account, String authority, ComponentName service,
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070057 long startTime) {
58 this.authorityId = authorityId;
59 this.account = account;
60 this.authority = authority;
61 this.startTime = startTime;
Matthew Williams56dbf8f2013-07-26 12:56:39 -070062 this.service = service;
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070063 }
64
65 /** @hide */
Matthew Williamsa7456e42013-11-12 14:41:02 -080066 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 Williamsee7081d2013-11-14 11:52:58 -080071 this.service = other.service;
Matthew Williamsa7456e42013-11-12 14:41:02 -080072 }
73
74 /** @hide */
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070075 public int describeContents() {
76 return 0;
77 }
78
79 /** @hide */
80 public void writeToParcel(Parcel parcel, int flags) {
81 parcel.writeInt(authorityId);
Matthew Williams56dbf8f2013-07-26 12:56:39 -070082 parcel.writeParcelable(account, flags);
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070083 parcel.writeString(authority);
84 parcel.writeLong(startTime);
Matthew Williams56dbf8f2013-07-26 12:56:39 -070085 parcel.writeParcelable(service, flags);
86
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070087 }
88
89 /** @hide */
90 SyncInfo(Parcel parcel) {
91 authorityId = parcel.readInt();
Matthew Williams56dbf8f2013-07-26 12:56:39 -070092 account = parcel.readParcelable(Account.class.getClassLoader());
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070093 authority = parcel.readString();
94 startTime = parcel.readLong();
Matthew Williams56dbf8f2013-07-26 12:56:39 -070095 service = parcel.readParcelable(ComponentName.class.getClassLoader());
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070096 }
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}