Search in sources :

Example 1 with RequestFailedException

use of com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException in project android_packages_apps_Dialer by LineageOS.

the class OmtpVvmSyncService method setupAndSendRequest.

private void setupAndSendRequest(BaseTask task, PhoneAccountHandle phoneAccount, Voicemail voicemail, VoicemailStatus.Editor status) {
    if (!VisualVoicemailSettingsUtil.isEnabled(context, phoneAccount)) {
        VvmLog.e(TAG, "Sync requested for disabled account");
        return;
    }
    if (!VvmAccountManager.isAccountActivated(context, phoneAccount)) {
        ActivationTask.start(context, phoneAccount, null);
        return;
    }
    OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(context, phoneAccount);
    LoggerUtils.logImpressionOnMainThread(context, DialerImpression.Type.VVM_SYNC_STARTED);
    // DATA_IMAP_OPERATION_STARTED posting should not be deferred. This event clears all data
    // channel errors, which should happen when the task starts, not when it ends. It is the
    // "Sync in progress..." status, which is currently displayed to the user as no error.
    config.handleEvent(VoicemailStatus.edit(context, phoneAccount), OmtpEvents.DATA_IMAP_OPERATION_STARTED);
    try (NetworkWrapper network = VvmNetworkRequest.getNetwork(config, phoneAccount, status)) {
        if (network == null) {
            VvmLog.e(TAG, "unable to acquire network");
            task.fail();
            return;
        }
        doSync(task, network.get(), phoneAccount, voicemail, status);
    } catch (RequestFailedException e) {
        config.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED);
        task.fail();
    }
}
Also used : NetworkWrapper(com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper) OmtpVvmCarrierConfigHelper(com.android.voicemail.impl.OmtpVvmCarrierConfigHelper) RequestFailedException(com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException)

Example 2 with RequestFailedException

use of com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException in project android_packages_apps_Dialer by LineageOS.

the class Vvm3Protocol method startProvisionNewUser.

private void startProvisionNewUser(ActivationTask task, PhoneAccountHandle phoneAccountHandle, OmtpVvmCarrierConfigHelper config, VoicemailStatus.Editor status, StatusMessage message) {
    try (NetworkWrapper wrapper = VvmNetworkRequest.getNetwork(config, phoneAccountHandle, status)) {
        Network network = wrapper.get();
        VvmLog.i(TAG, "new user: network available");
        try (ImapHelper helper = new ImapHelper(config.getContext(), phoneAccountHandle, network, status)) {
            // TODO(a bug): use LocaleList
            if (Locale.getDefault().getLanguage().equals(new Locale(ISO639_SPANISH).getLanguage())) {
                // Spanish
                helper.changeVoicemailTuiLanguage(VVM3_VM_LANGUAGE_SPANISH_STANDARD_NO_GUEST_PROMPTS);
            } else {
                // English
                helper.changeVoicemailTuiLanguage(VVM3_VM_LANGUAGE_ENGLISH_STANDARD_NO_GUEST_PROMPTS);
            }
            VvmLog.i(TAG, "new user: language set");
            if (setPin(config.getContext(), phoneAccountHandle, helper, message)) {
                // Only close new user tutorial if the PIN has been changed.
                helper.closeNewUserTutorial();
                VvmLog.i(TAG, "new user: NUT closed");
                LoggerUtils.logImpressionOnMainThread(config.getContext(), DialerImpression.Type.VVM_PROVISIONING_COMPLETED);
                config.requestStatus(null);
            }
        } catch (InitializingException | MessagingException | IOException e) {
            config.handleEvent(status, OmtpEvents.VVM3_NEW_USER_SETUP_FAILED);
            task.fail();
            VvmLog.e(TAG, e.toString());
        }
    } catch (RequestFailedException e) {
        config.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED);
        task.fail();
    }
}
Also used : Locale(java.util.Locale) NetworkWrapper(com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper) MessagingException(com.android.voicemail.impl.mail.MessagingException) RequestFailedException(com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException) Network(android.net.Network) IOException(java.io.IOException) InitializingException(com.android.voicemail.impl.imap.ImapHelper.InitializingException) ImapHelper(com.android.voicemail.impl.imap.ImapHelper)

Example 3 with RequestFailedException

use of com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException in project android_packages_apps_Dialer by LineageOS.

the class Vvm3Subscriber method subscribe.

@WorkerThread
public void subscribe() {
    Assert.isNotMainThread();
    // Cellular data is required to subscribe.
    // processSubscription() is called after network is available.
    VvmLog.i(TAG, "Subscribing");
    try (NetworkWrapper wrapper = VvmNetworkRequest.getNetwork(helper, handle, status)) {
        Network network = wrapper.get();
        VvmLog.d(TAG, "provisioning: network available");
        requestQueue = Volley.newRequestQueue(helper.getContext(), new NetworkSpecifiedHurlStack(network));
        processSubscription();
    } catch (RequestFailedException e) {
        helper.handleEvent(status, OmtpEvents.VVM3_VMG_CONNECTION_FAILED);
        task.fail();
    }
}
Also used : NetworkWrapper(com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper) RequestFailedException(com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException) Network(android.net.Network) WorkerThread(android.support.annotation.WorkerThread)

Example 4 with RequestFailedException

use of com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException in project android_packages_apps_Dialer by MoKee.

the class PinChangerImpl method changePin.

@WorkerThread
@Override
@ChangePinResult
public int changePin(String oldPin, String newPin) {
    Assert.isWorkerThread();
    OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle);
    VoicemailStatus.Editor status = VoicemailStatus.edit(context, phoneAccountHandle);
    try (NetworkWrapper networkWrapper = VvmNetworkRequest.getNetwork(config, phoneAccountHandle, status)) {
        Network network = networkWrapper.get();
        try (ImapHelper helper = new ImapHelper(context, phoneAccountHandle, network, status)) {
            return helper.changePin(oldPin, newPin);
        } catch (InitializingException | MessagingException e) {
            VvmLog.e("VoicemailClientImpl.changePin", "ChangePinNetworkRequestCallback: onAvailable: " + e);
            return PinChanger.CHANGE_PIN_SYSTEM_ERROR;
        }
    } catch (RequestFailedException e) {
        return PinChanger.CHANGE_PIN_SYSTEM_ERROR;
    }
}
Also used : NetworkWrapper(com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper) MessagingException(com.android.voicemail.impl.mail.MessagingException) RequestFailedException(com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException) Network(android.net.Network) InitializingException(com.android.voicemail.impl.imap.ImapHelper.InitializingException) ImapHelper(com.android.voicemail.impl.imap.ImapHelper) WorkerThread(android.support.annotation.WorkerThread)

Example 5 with RequestFailedException

use of com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException in project android_packages_apps_Dialer by LineageOS.

the class OmtpVvmSyncService method setupAndSendRequest.

private void setupAndSendRequest(BaseTask task, PhoneAccountHandle phoneAccount, Voicemail voicemail, String action, VoicemailStatus.Editor status) {
    if (!VisualVoicemailSettingsUtil.isEnabled(mContext, phoneAccount)) {
        VvmLog.v(TAG, "Sync requested for disabled account");
        return;
    }
    if (!VvmAccountManager.isAccountActivated(mContext, phoneAccount)) {
        ActivationTask.start(mContext, phoneAccount, null);
        return;
    }
    OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(mContext, phoneAccount);
    LoggerUtils.logImpressionOnMainThread(mContext, DialerImpression.Type.VVM_SYNC_STARTED);
    // DATA_IMAP_OPERATION_STARTED posting should not be deferred. This event clears all data
    // channel errors, which should happen when the task starts, not when it ends. It is the
    // "Sync in progress..." status.
    config.handleEvent(VoicemailStatus.edit(mContext, phoneAccount), OmtpEvents.DATA_IMAP_OPERATION_STARTED);
    try (NetworkWrapper network = VvmNetworkRequest.getNetwork(config, phoneAccount, status)) {
        if (network == null) {
            VvmLog.e(TAG, "unable to acquire network");
            task.fail();
            return;
        }
        doSync(task, network.get(), phoneAccount, voicemail, action, status);
    } catch (RequestFailedException e) {
        config.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED);
        task.fail();
    }
}
Also used : NetworkWrapper(com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper) OmtpVvmCarrierConfigHelper(com.android.voicemail.impl.OmtpVvmCarrierConfigHelper) RequestFailedException(com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException)

Aggregations

NetworkWrapper (com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper)9 RequestFailedException (com.android.voicemail.impl.sync.VvmNetworkRequest.RequestFailedException)9 Network (android.net.Network)6 WorkerThread (android.support.annotation.WorkerThread)4 ImapHelper (com.android.voicemail.impl.imap.ImapHelper)4 InitializingException (com.android.voicemail.impl.imap.ImapHelper.InitializingException)4 MessagingException (com.android.voicemail.impl.mail.MessagingException)4 OmtpVvmCarrierConfigHelper (com.android.voicemail.impl.OmtpVvmCarrierConfigHelper)3 IOException (java.io.IOException)2 Locale (java.util.Locale)2