BootupBroadcastReceiver.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * ownCloud Android client application
  3. *
  4. * @author David A. Velasco
  5. * @author Chris Narkiewicz
  6. * Copyright (C) 2012 Bartek Przybylski
  7. * Copyright (C) 2015 ownCloud Inc.
  8. * Copyright (C) 2017 Mario Danic
  9. * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. package com.owncloud.android.files;
  24. import android.content.BroadcastReceiver;
  25. import android.content.Context;
  26. import android.content.Intent;
  27. import com.nextcloud.client.account.UserAccountManager;
  28. import com.nextcloud.client.network.ConnectivityService;
  29. import com.owncloud.android.MainApp;
  30. import com.owncloud.android.datamodel.UploadsStorageManager;
  31. import com.owncloud.android.lib.common.utils.Log_OC;
  32. import javax.inject.Inject;
  33. import dagger.android.AndroidInjection;
  34. /**
  35. * App-registered receiver catching the broadcast intent reporting that the system was
  36. * just boot up.
  37. */
  38. public class BootupBroadcastReceiver extends BroadcastReceiver {
  39. private static final String TAG = BootupBroadcastReceiver.class.getSimpleName();
  40. @Inject UserAccountManager accountManager;
  41. @Inject UploadsStorageManager uploadsStorageManager;
  42. @Inject ConnectivityService connectivityService;
  43. /**
  44. * Receives broadcast intent reporting that the system was just boot up.
  45. **
  46. * @param context The context where the receiver is running.
  47. * @param intent The intent received.
  48. */
  49. @Override
  50. public void onReceive(Context context, Intent intent) {
  51. AndroidInjection.inject(this, context);
  52. if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
  53. MainApp.initSyncOperations(uploadsStorageManager, accountManager, connectivityService);
  54. MainApp.initContactsBackup(accountManager);
  55. } else {
  56. Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
  57. }
  58. }
  59. }