use of com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper 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(b/29082671): 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();
}
}
use of com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper 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(mHelper, mHandle, mStatus)) {
Network network = wrapper.get();
VvmLog.d(TAG, "provisioning: network available");
mRequestQueue = Volley.newRequestQueue(mHelper.getContext(), new NetworkSpecifiedHurlStack(network));
processSubscription();
} catch (RequestFailedException e) {
mHelper.handleEvent(mStatus, OmtpEvents.VVM3_VMG_CONNECTION_FAILED);
mTask.fail();
}
}
use of com.android.voicemail.impl.sync.VvmNetworkRequest.NetworkWrapper 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();
}
}
Aggregations