Exemple #1
0
  public void sync365(
      boolean riliSource, boolean eventSource, boolean noteSource, boolean birthSource) {

    AppInitializer initializer = new AppInitializer();
    initializer.init(this.context, this.handler, riliSource, eventSource, noteSource, birthSource);
    Configuration configuration = initializer.getConfiguration();

    Vector<AppSyncSource> sources = initializer.getSourcesToSync();
    if (sources == null || sources.size() == 0) {
      SyncLock.getInstance().releaseLock();
      if (SyncService.isWaiting()) {
        SyncService.synchronizeWaiting(context);
      }
      return;
    }
    try {
      NetworkStatus networkStatus = new NetworkStatus(this.context);
      SyncEngine syncEngine = new SyncEngine(configuration, networkStatus);
      CalendarSyncEngineListener listener =
          new CalendarSyncEngineListener(this.context, this.handler);
      syncEngine.setListener(listener);
      syncEngine.synchronize(sources);
    } catch (Exception e) {
      SyncLock.getInstance().releaseLock();
      if (SyncService.isWaiting()) {
        SyncService.synchronizeWaiting(context);
      }
    } finally {

    }
  }
Exemple #2
0
 private boolean addLock() {
   // 在CalendarSyncEngineListener的end中释放lock
   if (SyncLock.getInstance().isLocked()) {
     Log.info(TAG_LOG, "Synchronization not permitted because sync is locked");
     return false;
   } else {
     SyncLock.getInstance().acquireLock();
     return true;
   }
 }