BootupBroadcastReceiver.java 3.5 KB

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