diff options
Diffstat (limited to 'java/com/android/voicemail/impl/sms')
6 files changed, 127 insertions, 129 deletions
diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java index 43835276b..eae990ab0 100644 --- a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java +++ b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java @@ -46,11 +46,11 @@ public class OmtpMessageReceiver extends BroadcastReceiver { private static final String TAG = "OmtpMessageReceiver"; - private Context mContext; + private Context context; @Override public void onReceive(Context context, Intent intent) { - mContext = context; + this.context = context; VisualVoicemailSms sms = intent.getExtras().getParcelable(OmtpService.EXTRA_VOICEMAIL_SMS); PhoneAccountHandle phone = sms.getPhoneAccountHandle(); @@ -69,12 +69,12 @@ public class OmtpMessageReceiver extends BroadcastReceiver { return; } - OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(mContext, phone); + OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(this.context, phone); if (!helper.isValid()) { VvmLog.e(TAG, "vvm config no longer valid"); return; } - if (!VisualVoicemailSettingsUtil.isEnabled(mContext, phone)) { + if (!VisualVoicemailSettingsUtil.isEnabled(this.context, phone)) { if (helper.isLegacyModeEnabled()) { LegacyModeSmsHandler.handle(context, sms); } else { @@ -140,18 +140,18 @@ public class OmtpMessageReceiver extends BroadcastReceiver { .setPhoneAccount(phone) .setSourceData(message.getId()) .setDuration(message.getLength()) - .setSourcePackage(mContext.getPackageName()); + .setSourcePackage(context.getPackageName()); Voicemail voicemail = builder.build(); - VoicemailsQueryHelper queryHelper = new VoicemailsQueryHelper(mContext); + VoicemailsQueryHelper queryHelper = new VoicemailsQueryHelper(context); if (queryHelper.isVoicemailUnique(voicemail)) { - Uri uri = VoicemailDatabaseUtil.insert(mContext, voicemail); + Uri uri = VoicemailDatabaseUtil.insert(context, voicemail); voicemail = builder.setId(ContentUris.parseId(uri)).setUri(uri).build(); - SyncOneTask.start(mContext, phone, voicemail); + SyncOneTask.start(context, phone, voicemail); } break; case OmtpConstants.MAILBOX_UPDATE: - SyncTask.start(mContext, phone); + SyncTask.start(context, phone); break; case OmtpConstants.GREETINGS_UPDATE: // Not implemented in V1 diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java index 19661e99d..76a258366 100644 --- a/java/com/android/voicemail/impl/sms/OmtpMessageSender.java +++ b/java/com/android/voicemail/impl/sms/OmtpMessageSender.java @@ -35,20 +35,20 @@ import com.android.voicemail.impl.VvmLog; */ public abstract class OmtpMessageSender { protected static final String TAG = "OmtpMessageSender"; - protected final Context mContext; - protected final PhoneAccountHandle mPhoneAccountHandle; - protected final short mApplicationPort; - protected final String mDestinationNumber; + protected final Context context; + protected final PhoneAccountHandle phoneAccountHandle; + protected final short applicationPort; + protected final String destinationNumber; public OmtpMessageSender( Context context, PhoneAccountHandle phoneAccountHandle, short applicationPort, String destinationNumber) { - mContext = context; - mPhoneAccountHandle = phoneAccountHandle; - mApplicationPort = applicationPort; - mDestinationNumber = destinationNumber; + this.context = context; + this.phoneAccountHandle = phoneAccountHandle; + this.applicationPort = applicationPort; + this.destinationNumber = destinationNumber; } /** @@ -78,11 +78,10 @@ public abstract class OmtpMessageSender { protected void sendSms(String text, PendingIntent sentIntent) { VvmLog.v( - TAG, - String.format("Sending sms '%s' to %s:%d", text, mDestinationNumber, mApplicationPort)); + TAG, String.format("Sending sms '%s' to %s:%d", text, destinationNumber, applicationPort)); TelephonyMangerCompat.sendVisualVoicemailSms( - mContext, mPhoneAccountHandle, mDestinationNumber, mApplicationPort, text, sentIntent); + context, phoneAccountHandle, destinationNumber, applicationPort, text, sentIntent); } protected void appendField(StringBuilder sb, String field, Object value) { diff --git a/java/com/android/voicemail/impl/sms/OmtpStandardMessageSender.java b/java/com/android/voicemail/impl/sms/OmtpStandardMessageSender.java index 7974699a0..a8d27ff99 100644 --- a/java/com/android/voicemail/impl/sms/OmtpStandardMessageSender.java +++ b/java/com/android/voicemail/impl/sms/OmtpStandardMessageSender.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Google Inc. All Rights Reserved. + * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ import com.android.voicemail.impl.OmtpConstants; /** A implementation of the OmtpMessageSender using the standard OMTP sms protocol. */ public class OmtpStandardMessageSender extends OmtpMessageSender { - private final String mClientType; - private final String mProtocolVersion; - private final String mClientPrefix; + private final String clientType; + private final String protocolVersion; + private final String clientPrefix; /** * Creates a new instance of OmtpStandardMessageSender. @@ -49,9 +49,9 @@ public class OmtpStandardMessageSender extends OmtpMessageSender { String protocolVersion, String clientPrefix) { super(context, phoneAccountHandle, applicationPort, destinationNumber); - mClientType = clientType; - mProtocolVersion = protocolVersion; - mClientPrefix = clientPrefix; + this.clientType = clientType; + this.protocolVersion = protocolVersion; + this.clientPrefix = clientPrefix; } // Activate message: @@ -63,8 +63,8 @@ public class OmtpStandardMessageSender extends OmtpMessageSender { StringBuilder sb = new StringBuilder().append(OmtpConstants.ACTIVATE_REQUEST); appendProtocolVersionAndClientType(sb); - if (TextUtils.equals(mProtocolVersion, OmtpConstants.PROTOCOL_VERSION1_2) - || TextUtils.equals(mProtocolVersion, OmtpConstants.PROTOCOL_VERSION1_3)) { + if (TextUtils.equals(protocolVersion, OmtpConstants.PROTOCOL_VERSION1_2) + || TextUtils.equals(protocolVersion, OmtpConstants.PROTOCOL_VERSION1_3)) { appendApplicationPort(sb); appendClientPrefix(sb); } @@ -92,7 +92,7 @@ public class OmtpStandardMessageSender extends OmtpMessageSender { public void requestVvmStatus(@Nullable PendingIntent sentIntent) { StringBuilder sb = new StringBuilder().append(OmtpConstants.STATUS_REQUEST); - if (TextUtils.equals(mProtocolVersion, OmtpConstants.PROTOCOL_VERSION1_3)) { + if (TextUtils.equals(protocolVersion, OmtpConstants.PROTOCOL_VERSION1_3)) { appendProtocolVersionAndClientType(sb); appendApplicationPort(sb); appendClientPrefix(sb); @@ -103,18 +103,18 @@ public class OmtpStandardMessageSender extends OmtpMessageSender { private void appendProtocolVersionAndClientType(StringBuilder sb) { sb.append(OmtpConstants.SMS_PREFIX_SEPARATOR); - appendField(sb, OmtpConstants.PROTOCOL_VERSION, mProtocolVersion); + appendField(sb, OmtpConstants.PROTOCOL_VERSION, protocolVersion); sb.append(OmtpConstants.SMS_FIELD_SEPARATOR); - appendField(sb, OmtpConstants.CLIENT_TYPE, mClientType); + appendField(sb, OmtpConstants.CLIENT_TYPE, clientType); } private void appendApplicationPort(StringBuilder sb) { sb.append(OmtpConstants.SMS_FIELD_SEPARATOR); - appendField(sb, OmtpConstants.APPLICATION_PORT, mApplicationPort); + appendField(sb, OmtpConstants.APPLICATION_PORT, applicationPort); } private void appendClientPrefix(StringBuilder sb) { sb.append(OmtpConstants.SMS_FIELD_SEPARATOR); - sb.append(mClientPrefix); + sb.append(clientPrefix); } } diff --git a/java/com/android/voicemail/impl/sms/StatusMessage.java b/java/com/android/voicemail/impl/sms/StatusMessage.java index a5766a61a..7fd2966a4 100644 --- a/java/com/android/voicemail/impl/sms/StatusMessage.java +++ b/java/com/android/voicemail/impl/sms/StatusMessage.java @@ -32,66 +32,66 @@ public class StatusMessage { // to be useful for initial omtp source implementation. // lang, g_len, vs_len, pw_len, pm, gm, vtc, vt - private final String mProvisioningStatus; - private final String mStatusReturnCode; - private final String mSubscriptionUrl; - private final String mServerAddress; - private final String mTuiAccessNumber; - private final String mClientSmsDestinationNumber; - private final String mImapPort; - private final String mImapUserName; - private final String mImapPassword; - private final String mSmtpPort; - private final String mSmtpUserName; - private final String mSmtpPassword; - private final String mTuiPasswordLength; + private final String provisioningStatus; + private final String statusReturnCode; + private final String subscriptionUrl; + private final String serverAddress; + private final String tuiAccessNumber; + private final String clientSmsDestinationNumber; + private final String imapPort; + private final String imapUserName; + private final String imapPassword; + private final String smtpPort; + private final String smtpUserName; + private final String smtpPassword; + private final String tuiPasswordLength; @Override public String toString() { return "StatusMessage [mProvisioningStatus=" - + mProvisioningStatus + + provisioningStatus + ", mStatusReturnCode=" - + mStatusReturnCode + + statusReturnCode + ", mSubscriptionUrl=" - + mSubscriptionUrl + + subscriptionUrl + ", mServerAddress=" - + mServerAddress + + serverAddress + ", mTuiAccessNumber=" - + mTuiAccessNumber + + tuiAccessNumber + ", mClientSmsDestinationNumber=" - + mClientSmsDestinationNumber + + clientSmsDestinationNumber + ", mImapPort=" - + mImapPort + + imapPort + ", mImapUserName=" - + mImapUserName + + imapUserName + ", mImapPassword=" - + VvmLog.pii(mImapPassword) + + VvmLog.pii(imapPassword) + ", mSmtpPort=" - + mSmtpPort + + smtpPort + ", mSmtpUserName=" - + mSmtpUserName + + smtpUserName + ", mSmtpPassword=" - + VvmLog.pii(mSmtpPassword) + + VvmLog.pii(smtpPassword) + ", mTuiPasswordLength=" - + mTuiPasswordLength + + tuiPasswordLength + "]"; } public StatusMessage(Bundle wrappedData) { - mProvisioningStatus = unquote(getString(wrappedData, OmtpConstants.PROVISIONING_STATUS)); - mStatusReturnCode = getString(wrappedData, OmtpConstants.RETURN_CODE); - mSubscriptionUrl = getString(wrappedData, OmtpConstants.SUBSCRIPTION_URL); - mServerAddress = getString(wrappedData, OmtpConstants.SERVER_ADDRESS); - mTuiAccessNumber = getString(wrappedData, OmtpConstants.TUI_ACCESS_NUMBER); - mClientSmsDestinationNumber = + provisioningStatus = unquote(getString(wrappedData, OmtpConstants.PROVISIONING_STATUS)); + statusReturnCode = getString(wrappedData, OmtpConstants.RETURN_CODE); + subscriptionUrl = getString(wrappedData, OmtpConstants.SUBSCRIPTION_URL); + serverAddress = getString(wrappedData, OmtpConstants.SERVER_ADDRESS); + tuiAccessNumber = getString(wrappedData, OmtpConstants.TUI_ACCESS_NUMBER); + clientSmsDestinationNumber = getString(wrappedData, OmtpConstants.CLIENT_SMS_DESTINATION_NUMBER); - mImapPort = getString(wrappedData, OmtpConstants.IMAP_PORT); - mImapUserName = getString(wrappedData, OmtpConstants.IMAP_USER_NAME); - mImapPassword = getString(wrappedData, OmtpConstants.IMAP_PASSWORD); - mSmtpPort = getString(wrappedData, OmtpConstants.SMTP_PORT); - mSmtpUserName = getString(wrappedData, OmtpConstants.SMTP_USER_NAME); - mSmtpPassword = getString(wrappedData, OmtpConstants.SMTP_PASSWORD); - mTuiPasswordLength = getString(wrappedData, OmtpConstants.TUI_PASSWORD_LENGTH); + imapPort = getString(wrappedData, OmtpConstants.IMAP_PORT); + imapUserName = getString(wrappedData, OmtpConstants.IMAP_USER_NAME); + imapPassword = getString(wrappedData, OmtpConstants.IMAP_PASSWORD); + smtpPort = getString(wrappedData, OmtpConstants.SMTP_PORT); + smtpUserName = getString(wrappedData, OmtpConstants.SMTP_USER_NAME); + smtpPassword = getString(wrappedData, OmtpConstants.SMTP_PASSWORD); + tuiPasswordLength = getString(wrappedData, OmtpConstants.TUI_PASSWORD_LENGTH); } private static String unquote(String string) { @@ -106,12 +106,12 @@ public class StatusMessage { /** @return the subscriber's VVM provisioning status. */ public String getProvisioningStatus() { - return mProvisioningStatus; + return provisioningStatus; } /** @return the return-code of the status SMS. */ public String getReturnCode() { - return mStatusReturnCode; + return statusReturnCode; } /** @@ -120,14 +120,14 @@ public class StatusMessage { */ @NeededForTesting public String getSubscriptionUrl() { - return mSubscriptionUrl; + return subscriptionUrl; } /** * @return the voicemail server address. Either server IP address or fully qualified domain name. */ public String getServerAddress() { - return mServerAddress; + return serverAddress; } /** @@ -135,50 +135,50 @@ public class StatusMessage { */ @NeededForTesting public String getTuiAccessNumber() { - return mTuiAccessNumber; + return tuiAccessNumber; } /** @return the number to which client originated SMSes should be sent to. */ @NeededForTesting public String getClientSmsDestinationNumber() { - return mClientSmsDestinationNumber; + return clientSmsDestinationNumber; } /** @return the IMAP server port to talk to. */ public String getImapPort() { - return mImapPort; + return imapPort; } /** @return the IMAP user name to be used for authentication. */ public String getImapUserName() { - return mImapUserName; + return imapUserName; } /** @return the IMAP password to be used for authentication. */ public String getImapPassword() { - return mImapPassword; + return imapPassword; } /** @return the SMTP server port to talk to. */ @NeededForTesting public String getSmtpPort() { - return mSmtpPort; + return smtpPort; } /** @return the SMTP user name to be used for SMTP authentication. */ @NeededForTesting public String getSmtpUserName() { - return mSmtpUserName; + return smtpUserName; } /** @return the SMTP password to be used for SMTP authentication. */ @NeededForTesting public String getSmtpPassword() { - return mSmtpPassword; + return smtpPassword; } public String getTuiPasswordLength() { - return mTuiPasswordLength; + return tuiPasswordLength; } private static String getString(Bundle bundle, String key) { diff --git a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java index d178628c6..73e0c7f3c 100644 --- a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java +++ b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java @@ -58,14 +58,14 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { "com.android.voicemailomtp.sms.REQUEST_SENT"; private static final int ACTION_REQUEST_SENT_REQUEST_CODE = 0; - private CompletableFuture<Bundle> mFuture = new CompletableFuture<>(); + private CompletableFuture<Bundle> future = new CompletableFuture<>(); - private final Context mContext; - private final PhoneAccountHandle mPhoneAccountHandle; + private final Context context; + private final PhoneAccountHandle phoneAccountHandle; public StatusSmsFetcher(Context context, PhoneAccountHandle phoneAccountHandle) { - mContext = context; - mPhoneAccountHandle = phoneAccountHandle; + this.context = context; + this.phoneAccountHandle = phoneAccountHandle; IntentFilter filter = new IntentFilter(ACTION_REQUEST_SENT_INTENT); filter.addAction(OmtpService.ACTION_SMS_RECEIVED); context.registerReceiver(this, filter); @@ -73,7 +73,7 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { @Override public void close() throws IOException { - mContext.unregisterReceiver(this); + context.unregisterReceiver(this); } @WorkerThread @@ -81,16 +81,16 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { public Bundle get() throws InterruptedException, ExecutionException, TimeoutException, CancellationException { Assert.isNotMainThread(); - return mFuture.get(STATUS_SMS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); + return future.get(STATUS_SMS_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); } public PendingIntent getSentIntent() { Intent intent = new Intent(ACTION_REQUEST_SENT_INTENT); - intent.setPackage(mContext.getPackageName()); + intent.setPackage(context.getPackageName()); // Because the receiver is registered dynamically, implicit intent must be used. // There should only be a single status SMS request at a time. return PendingIntent.getBroadcast( - mContext, ACTION_REQUEST_SENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT); + context, ACTION_REQUEST_SENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT); } @Override @@ -106,19 +106,19 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { } VvmLog.e(TAG, "Request SMS send failed: " + sentSmsResultToString(resultCode)); - mFuture.cancel(true); + future.cancel(true); return; } VisualVoicemailSms sms = intent.getExtras().getParcelable(OmtpService.EXTRA_VOICEMAIL_SMS); - if (!mPhoneAccountHandle.equals(sms.getPhoneAccountHandle())) { + if (!phoneAccountHandle.equals(sms.getPhoneAccountHandle())) { return; } String eventType = sms.getPrefix(); if (eventType.equals(OmtpConstants.STATUS_SMS_PREFIX)) { - mFuture.complete(sms.getFields()); + future.complete(sms.getFields()); return; } @@ -129,8 +129,7 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { VvmLog.i( TAG, "VVM SMS with event " + eventType + " received, attempting to translate to STATUS SMS"); - OmtpVvmCarrierConfigHelper helper = - new OmtpVvmCarrierConfigHelper(context, mPhoneAccountHandle); + OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle); VisualVoicemailProtocol protocol = helper.getProtocol(); if (protocol == null) { return; @@ -139,7 +138,7 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable { if (translatedBundle != null) { VvmLog.i(TAG, "Translated to STATUS SMS"); - mFuture.complete(translatedBundle); + future.complete(translatedBundle); } } diff --git a/java/com/android/voicemail/impl/sms/SyncMessage.java b/java/com/android/voicemail/impl/sms/SyncMessage.java index 3cfa1a7b3..de5b3ce35 100644 --- a/java/com/android/voicemail/impl/sms/SyncMessage.java +++ b/java/com/android/voicemail/impl/sms/SyncMessage.java @@ -31,47 +31,47 @@ import java.util.Locale; */ public class SyncMessage { // Sync event that triggered this message. - private final String mSyncTriggerEvent; + private final String syncTriggerEvent; // Total number of new messages on the server. - private final int mNewMessageCount; + private final int newMessageCount; // UID of the new message. - private final String mMessageId; + private final String messageId; // Length of the message. - private final int mMessageLength; + private final int messageLength; // Content type (voice, video, fax...) of the new message. - private final String mContentType; + private final String contentType; // Sender of the new message. - private final String mSender; + private final String sender; // Timestamp (in millis) of the new message. - private final long mMsgTimeMillis; + private final long msgTimeMillis; @Override public String toString() { return "SyncMessage [mSyncTriggerEvent=" - + mSyncTriggerEvent + + syncTriggerEvent + ", mNewMessageCount=" - + mNewMessageCount + + newMessageCount + ", mMessageId=" - + mMessageId + + messageId + ", mMessageLength=" - + mMessageLength + + messageLength + ", mContentType=" - + mContentType + + contentType + ", mSender=" - + mSender + + sender + ", mMsgTimeMillis=" - + mMsgTimeMillis + + msgTimeMillis + "]"; } public SyncMessage(Bundle wrappedData) { - mSyncTriggerEvent = getString(wrappedData, OmtpConstants.SYNC_TRIGGER_EVENT); - mMessageId = getString(wrappedData, OmtpConstants.MESSAGE_UID); - mMessageLength = getInt(wrappedData, OmtpConstants.MESSAGE_LENGTH); - mContentType = getString(wrappedData, OmtpConstants.CONTENT_TYPE); - mSender = getString(wrappedData, OmtpConstants.SENDER); - mNewMessageCount = getInt(wrappedData, OmtpConstants.NUM_MESSAGE_COUNT); - mMsgTimeMillis = parseTime(wrappedData.getString(OmtpConstants.TIME)); + syncTriggerEvent = getString(wrappedData, OmtpConstants.SYNC_TRIGGER_EVENT); + messageId = getString(wrappedData, OmtpConstants.MESSAGE_UID); + messageLength = getInt(wrappedData, OmtpConstants.MESSAGE_LENGTH); + contentType = getString(wrappedData, OmtpConstants.CONTENT_TYPE); + sender = getString(wrappedData, OmtpConstants.SENDER); + newMessageCount = getInt(wrappedData, OmtpConstants.NUM_MESSAGE_COUNT); + msgTimeMillis = parseTime(wrappedData.getString(OmtpConstants.TIME)); } private static long parseTime(@Nullable String value) { @@ -89,13 +89,13 @@ public class SyncMessage { * set. */ public String getSyncTriggerEvent() { - return mSyncTriggerEvent; + return syncTriggerEvent; } /** @return the number of new messages stored on the voicemail server. */ @NeededForTesting public int getNewMessageCount() { - return mNewMessageCount; + return newMessageCount; } /** @@ -103,7 +103,7 @@ public class SyncMessage { * <p>Expected to be set only for {@link OmtpConstants#NEW_MESSAGE} */ public String getId() { - return mMessageId; + return messageId; } /** @@ -112,7 +112,7 @@ public class SyncMessage { */ @NeededForTesting public String getContentType() { - return mContentType; + return contentType; } /** @@ -120,7 +120,7 @@ public class SyncMessage { * <p>Expected to be set only for {@link OmtpConstants#NEW_MESSAGE} */ public int getLength() { - return mMessageLength; + return messageLength; } /** @@ -128,7 +128,7 @@ public class SyncMessage { * <p>Expected to be set only for {@link OmtpConstants#NEW_MESSAGE} */ public String getSender() { - return mSender; + return sender; } /** @@ -136,7 +136,7 @@ public class SyncMessage { * <p>Expected to be set only for {@link OmtpConstants#NEW_MESSAGE} */ public long getTimestampMillis() { - return mMsgTimeMillis; + return msgTimeMillis; } private static int getInt(Bundle wrappedData, String key) { |