• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.os.Parcelable;
20 import android.os.Bundle;
21 import android.os.Parcel;
22 import android.accounts.Account;
23 
24 /**
25  * Value type that contains information about a periodic sync. Is parcelable, making it suitable
26  * for passing in an IPC.
27  */
28 public class PeriodicSync implements Parcelable {
29     /** The account to be synced */
30     public final Account account;
31     /** The authority of the sync */
32     public final String authority;
33     /** Any extras that parameters that are to be passed to the sync adapter. */
34     public final Bundle extras;
35     /** How frequently the sync should be scheduled, in seconds. */
36     public final long period;
37 
38     /** Creates a new PeriodicSync, copying the Bundle */
PeriodicSync(Account account, String authority, Bundle extras, long period)39     public PeriodicSync(Account account, String authority, Bundle extras, long period) {
40         this.account = account;
41         this.authority = authority;
42         this.extras = new Bundle(extras);
43         this.period = period;
44     }
45 
describeContents()46     public int describeContents() {
47         return 0;
48     }
49 
writeToParcel(Parcel dest, int flags)50     public void writeToParcel(Parcel dest, int flags) {
51         account.writeToParcel(dest, flags);
52         dest.writeString(authority);
53         dest.writeBundle(extras);
54         dest.writeLong(period);
55     }
56 
57     public static final Creator<PeriodicSync> CREATOR = new Creator<PeriodicSync>() {
58         public PeriodicSync createFromParcel(Parcel source) {
59             return new PeriodicSync(Account.CREATOR.createFromParcel(source),
60                     source.readString(), source.readBundle(), source.readLong());
61         }
62 
63         public PeriodicSync[] newArray(int size) {
64             return new PeriodicSync[size];
65         }
66     };
67 
equals(Object o)68     public boolean equals(Object o) {
69         if (o == this) {
70             return true;
71         }
72 
73         if (!(o instanceof PeriodicSync)) {
74             return false;
75         }
76 
77         final PeriodicSync other = (PeriodicSync) o;
78 
79         return account.equals(other.account)
80                 && authority.equals(other.authority)
81                 && period == other.period
82                 && SyncStorageEngine.equals(extras, other.extras);
83     }
84 }
85