BootupBroadcastReceiver.java 2.1 KB

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