Source:
<code>public static void setEmail(@NonNull final String email, @Nullable final String emailAuthHash, @Nullable final EmailUpdateHandler callback) { if (taskController.shouldQueueTaskForInit("setEmail()")) { <START> logger.error("Waiting for remote params. " + <END> "Moving setEmail() operation to a pending task queue."); taskController.addTaskWaitingForInit(new Runnable() { @Override public void run() { logger.debug("Running setEmail() operation from a pending task queue."); setEmail(email, emailAuthHash, callback); } }); } if (shouldLogUserPrivacyConsentErrorMessageForMethodName("setEmail()")) return; if (!OSUtils.isValidEmail(email)) { String errorMessage = "Email is invalid"; if (callback != null) callback.onFailure(new EmailUpdateError(EmailErrorType.VALIDATION, errorMessage)); logger.error(errorMessage); return; } if (getRemoteParams() != null && getRemoteParams().useEmailAuth && emailAuthHash == null) { String errorMessage = "Email authentication (auth token) is set to REQUIRED for this application. Please provide an auth token from your backend server or change the setting in the OneSignal dashboard."; if (callback != null) callback.onFailure(new EmailUpdateError(EmailErrorType.REQUIRES_EMAIL_AUTH, errorMessage)); logger.error(errorMessage); return; } emailUpdateHandler = callback; Runnable runSetEmail = new Runnable() { @Override public void run() { String trimmedEmail = email.trim(); String internalEmailAuthHash = emailAuthHash; if (internalEmailAuthHash != null) internalEmailAuthHash.toLowerCase(); getCurrentEmailSubscriptionState(appContext).setEmailAddress(trimmedEmail); OneSignalStateSynchronizer.setEmail(trimmedEmail.toLowerCase(), internalEmailAuthHash); } }; if (!initDone || taskController.shouldRunTaskThroughQueue()) { logger.error("You should initialize OneSignal before calling setEmail! " + "Moving this operation to a pending task queue."); taskController.addTaskToQueue(runSetEmail); return; } runSetEmail.run(); }</code><technical_language>OneSignal public methods steps. 1. Check if remote params done 2. If add queue 3. remote params finishes check if privacy consent is required. 4. Check if OneSignal initialized step 4 if download remote params OneSignal initialized. this is a redundant check</technical_language>

Target:
public static void setEmail(@NonNull final String email, @Nullable final String emailAuthHash, @Nullable final EmailUpdateHandler callback) { if (taskController.shouldQueueTaskForInit(OSTaskController.SET_EMAIL)) { logger.error("Waiting for remote params. " + "Moving " + OSTaskController.SET_EMAIL + " operation to a pending task queue."); taskController.addTaskToQueue(new Runnable() { @Override public void run() { logger.debug("Running " + OSTaskController.SET_EMAIL + " operation from a pending task queue."); setEmail(email, emailAuthHash, callback); } }); } if (shouldLogUserPrivacyConsentErrorMessageForMethodName(OSTaskController.SET_EMAIL)) return; if (!OSUtils.isValidEmail(email)) { String errorMessage = "Email is invalid"; if (callback != null) callback.onFailure(new EmailUpdateError(EmailErrorType.VALIDATION, errorMessage)); logger.error(errorMessage); return; } if (getRemoteParams().useEmailAuth && emailAuthHash == null) { String errorMessage = "Email authentication (auth token) is set to REQUIRED for this application. Please provide an auth token from your backend server or change the setting in the OneSignal dashboard."; if (callback != null) callback.onFailure(new EmailUpdateError(EmailErrorType.REQUIRES_EMAIL_AUTH, errorMessage)); logger.error(errorMessage); return; } emailUpdateHandler = callback; String trimmedEmail = email.trim(); String internalEmailAuthHash = emailAuthHash; if (internalEmailAuthHash != null) internalEmailAuthHash = internalEmailAuthHash.toLowerCase(); getCurrentEmailSubscriptionState(appContext).setEmailAddress(trimmedEmail); OneSignalStateSynchronizer.setEmail(trimmedEmail.toLowerCase(), internalEmailAuthHash); }