Update year in license
[pub/Android/ownCloud.git] / src / com / owncloud / android / syncadapter / FileSyncService.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author Bartek Przybylski
5 * @author David A. Velasco
6 * Copyright (C) 2011 Bartek Przybylski
7 * Copyright (C) 2015 ownCloud Inc.
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22 package com.owncloud.android.syncadapter;
23
24 import android.app.Service;
25 import android.content.Intent;
26 import android.os.IBinder;
27
28 /**
29 * Background service for synchronizing remote files with their local state.
30 *
31 * Serves as a connector to an instance of {@link FileSyncAdapter}, as required by standard Android APIs.
32 */
33 public class FileSyncService extends Service {
34
35 // Storage for an instance of the sync adapter
36 private static FileSyncAdapter sSyncAdapter = null;
37 // Object to use as a thread-safe lock
38 private static final Object sSyncAdapterLock = new Object();
39
40 /*
41 * {@inheritDoc}
42 */
43 @Override
44 public void onCreate() {
45 synchronized (sSyncAdapterLock) {
46 if (sSyncAdapter == null) {
47 sSyncAdapter = new FileSyncAdapter(getApplicationContext(), true);
48 }
49 }
50 }
51
52 /*
53 * {@inheritDoc}
54 */
55 @Override
56 public IBinder onBind(Intent intent) {
57 return sSyncAdapter.getSyncAdapterBinder();
58 }
59
60 }