BackupTask(@NonNull SmsBackupService service) {
final Context context = service.getApplicationContext();
this.service = service;
this.authPreferences = service.getAuthPreferences();
this.preferences = service.getPreferences();
this.fetcher = new BackupItemsFetcher(
context.getContentResolver(),
new BackupQueryBuilder(preferences.getDataTypePreferences()));
PersonLookup personLookup = new PersonLookup(service.getContentResolver());
this.contactAccessor = new ContactAccessor();
this.converter = new MessageConverter(context, service.getPreferences(), authPreferences.getUserEmail(), personLookup, contactAccessor);
if (preferences.isCallLogCalendarSyncEnabled()) {
calendarSyncer = new CalendarSyncer(
CalendarAccessor.Get.instance(service.getContentResolver()),
preferences.getCallLogCalendarId(),
personLookup,
new CallFormatter(context.getResources())
);
} else {
calendarSyncer = null;
}
this.tokenRefresher = new TokenRefresher(service, new OAuth2Client(authPreferences.getOAuth2ClientId()), authPreferences);
}