private void handleErrorState(BackupState state) {
if (state.isAuthException()) {
appLog(R.string.app_log_backup_failed_authentication, state.getDetailedErrorMessage(getResources()));
if (shouldNotifyUser(state)) {
notifyUser(NOTIFICATION_ID_WARNING, notificationBuilder(stat_sys_warning,
getString(R.string.notification_auth_failure),
getString(getAuthPreferences().useXOAuth() ? R.string.status_auth_failure_details_xoauth : R.string.status_auth_failure_details_plain)));
}
} else if (state.isConnectivityError()) {
appLog(R.string.app_log_backup_failed_connectivity, state.getDetailedErrorMessage(getResources()));
} else if (state.isPermissionException()) {
if (state.backupType != MANUAL) {
Bundle extras = new Bundle();
extras.putStringArray(MainActivity.EXTRA_PERMISSIONS, state.getMissingPermissions());
notifyUser(NOTIFICATION_ID_WARNING, notificationBuilder(R.drawable.ic_notification,
getString(R.string.notification_missing_permission),
formatMissingPermissionDetails(getResources(), state.getMissingPermissions()))
.setContentIntent(getPendingIntent(extras)));
}
} else {
appLog(R.string.app_log_backup_failed_general_error, state.getDetailedErrorMessage(getResources()));
if (shouldNotifyUser(state)) {
notifyUser(NOTIFICATION_ID_WARNING, notificationBuilder(stat_sys_warning,
getString(R.string.notification_general_error),
state.getErrorMessage(getResources())));
}
}
}