BootupBroadcastReceiver.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.device.PowerManagementService;
  29. import com.nextcloud.client.jobs.BackgroundJobManager;
  30. import com.nextcloud.client.network.ConnectivityService;
  31. import com.owncloud.android.MainApp;
  32. import com.owncloud.android.datamodel.UploadsStorageManager;
  33. import com.owncloud.android.lib.common.utils.Log_OC;
  34. import javax.inject.Inject;
  35. import dagger.android.AndroidInjection;
  36. /**
  37. * App-registered receiver catching the broadcast intent reporting that the system was
  38. * just boot up.
  39. */
  40. public class BootupBroadcastReceiver extends BroadcastReceiver {
  41. private static final String TAG = BootupBroadcastReceiver.class.getSimpleName();
  42. @Inject UserAccountManager accountManager;
  43. @Inject UploadsStorageManager uploadsStorageManager;
  44. @Inject ConnectivityService connectivityService;
  45. @Inject PowerManagementService powerManagementService;
  46. @Inject BackgroundJobManager backgroundJobManager;
  47. /**
  48. * Receives broadcast intent reporting that the system was just boot up.
  49. **
  50. * @param context The context where the receiver is running.
  51. * @param intent The intent received.
  52. */
  53. @Override
  54. public void onReceive(Context context, Intent intent) {
  55. AndroidInjection.inject(this, context);
  56. if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
  57. MainApp.initSyncOperations(uploadsStorageManager,
  58. accountManager,
  59. connectivityService,
  60. powerManagementService,
  61. backgroundJobManager);
  62. MainApp.initContactsBackup(accountManager);
  63. } else {
  64. Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
  65. }
  66. }
  67. }