summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail/impl/fetch
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/voicemail/impl/fetch')
-rw-r--r--java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java58
-rw-r--r--java/com/android/voicemail/impl/fetch/VoicemailFetchedCallback.java34
2 files changed, 46 insertions, 46 deletions
diff --git a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
index 0348a60c5..9fda37343 100644
--- a/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
+++ b/java/com/android/voicemail/impl/fetch/FetchVoicemailReceiver.java
@@ -64,13 +64,13 @@ public class FetchVoicemailReceiver extends BroadcastReceiver {
// Number of retries
private static final int NETWORK_RETRY_COUNT = 3;
- private ContentResolver mContentResolver;
- private Uri mUri;
- private VvmNetworkRequestCallback mNetworkCallback;
- private Context mContext;
- private String mUid;
- private PhoneAccountHandle mPhoneAccount;
- private int mRetryCount = NETWORK_RETRY_COUNT;
+ private ContentResolver contentResolver;
+ private Uri uri;
+ private VvmNetworkRequestCallback networkCallback;
+ private Context context;
+ private String uid;
+ private PhoneAccountHandle phoneAccount;
+ private int retryCount = NETWORK_RETRY_COUNT;
@Override
public void onReceive(final Context context, Intent intent) {
@@ -79,31 +79,31 @@ public class FetchVoicemailReceiver extends BroadcastReceiver {
}
if (VoicemailContract.ACTION_FETCH_VOICEMAIL.equals(intent.getAction())) {
VvmLog.i(TAG, "ACTION_FETCH_VOICEMAIL received");
- mContext = context;
- mContentResolver = context.getContentResolver();
- mUri = intent.getData();
+ this.context = context;
+ contentResolver = context.getContentResolver();
+ uri = intent.getData();
- if (mUri == null) {
+ if (uri == null) {
VvmLog.w(TAG, VoicemailContract.ACTION_FETCH_VOICEMAIL + " intent sent with no data");
return;
}
if (!context
.getPackageName()
- .equals(mUri.getQueryParameter(VoicemailContract.PARAM_KEY_SOURCE_PACKAGE))) {
+ .equals(uri.getQueryParameter(VoicemailContract.PARAM_KEY_SOURCE_PACKAGE))) {
// Ignore if the fetch request is for a voicemail not from this package.
VvmLog.e(TAG, "ACTION_FETCH_VOICEMAIL from foreign pacakge " + context.getPackageName());
return;
}
- Cursor cursor = mContentResolver.query(mUri, PROJECTION, null, null, null);
+ Cursor cursor = contentResolver.query(uri, PROJECTION, null, null, null);
if (cursor == null) {
VvmLog.i(TAG, "ACTION_FETCH_VOICEMAIL query returned null");
return;
}
try {
if (cursor.moveToFirst()) {
- mUid = cursor.getString(SOURCE_DATA);
+ uid = cursor.getString(SOURCE_DATA);
String accountId = cursor.getString(PHONE_ACCOUNT_ID);
if (TextUtils.isEmpty(accountId)) {
TelephonyManager telephonyManager =
@@ -116,31 +116,31 @@ public class FetchVoicemailReceiver extends BroadcastReceiver {
}
}
- mPhoneAccount =
+ phoneAccount =
new PhoneAccountHandle(
ComponentName.unflattenFromString(cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME)),
cursor.getString(PHONE_ACCOUNT_ID));
TelephonyManager telephonyManager =
context
.getSystemService(TelephonyManager.class)
- .createForPhoneAccountHandle(mPhoneAccount);
+ .createForPhoneAccountHandle(phoneAccount);
if (telephonyManager == null) {
// can happen when trying to fetch voicemails from a SIM that is no longer on the
// device
VvmLog.e(TAG, "account no longer valid, cannot retrieve message");
return;
}
- if (!VvmAccountManager.isAccountActivated(context, mPhoneAccount)) {
- mPhoneAccount = getAccountFromMarshmallowAccount(context, mPhoneAccount);
- if (mPhoneAccount == null) {
+ if (!VvmAccountManager.isAccountActivated(context, phoneAccount)) {
+ phoneAccount = getAccountFromMarshmallowAccount(context, phoneAccount);
+ if (phoneAccount == null) {
VvmLog.w(TAG, "Account not registered - cannot retrieve message.");
return;
}
VvmLog.i(TAG, "Fetching voicemail with Marshmallow PhoneAccountHandle");
}
VvmLog.i(TAG, "Requesting network to fetch voicemail");
- mNetworkCallback = new fetchVoicemailNetworkRequestCallback(context, mPhoneAccount);
- mNetworkCallback.requestNetwork();
+ networkCallback = new fetchVoicemailNetworkRequestCallback(context, phoneAccount);
+ networkCallback.requestNetwork();
}
} finally {
cursor.close();
@@ -203,16 +203,16 @@ public class FetchVoicemailReceiver extends BroadcastReceiver {
@Override
public void run() {
try {
- while (mRetryCount > 0) {
- VvmLog.i(TAG, "fetching voicemail, retry count=" + mRetryCount);
+ while (retryCount > 0) {
+ VvmLog.i(TAG, "fetching voicemail, retry count=" + retryCount);
try (ImapHelper imapHelper =
- new ImapHelper(mContext, mPhoneAccount, network, status)) {
+ new ImapHelper(context, phoneAccount, network, status)) {
boolean success =
imapHelper.fetchVoicemailPayload(
- new VoicemailFetchedCallback(mContext, mUri, mPhoneAccount), mUid);
- if (!success && mRetryCount > 0) {
+ new VoicemailFetchedCallback(context, uri, phoneAccount), uid);
+ if (!success && retryCount > 0) {
VvmLog.i(TAG, "fetch voicemail failed, retrying");
- mRetryCount--;
+ retryCount--;
} else {
return;
}
@@ -222,8 +222,8 @@ public class FetchVoicemailReceiver extends BroadcastReceiver {
}
}
} finally {
- if (mNetworkCallback != null) {
- mNetworkCallback.releaseNetwork();
+ if (networkCallback != null) {
+ networkCallback.releaseNetwork();
}
}
}
diff --git a/java/com/android/voicemail/impl/fetch/VoicemailFetchedCallback.java b/java/com/android/voicemail/impl/fetch/VoicemailFetchedCallback.java
index e8e14bedb..78dbdc06f 100644
--- a/java/com/android/voicemail/impl/fetch/VoicemailFetchedCallback.java
+++ b/java/com/android/voicemail/impl/fetch/VoicemailFetchedCallback.java
@@ -40,16 +40,16 @@ import org.apache.commons.io.IOUtils;
public class VoicemailFetchedCallback {
private static final String TAG = "VoicemailFetchedCallback";
- private final Context mContext;
- private final ContentResolver mContentResolver;
- private final Uri mUri;
- private final PhoneAccountHandle mPhoneAccountHandle;
+ private final Context context;
+ private final ContentResolver contentResolver;
+ private final Uri uri;
+ private final PhoneAccountHandle phoneAccountHandle;
public VoicemailFetchedCallback(Context context, Uri uri, PhoneAccountHandle phoneAccountHandle) {
- mContext = context;
- mContentResolver = context.getContentResolver();
- mUri = uri;
- mPhoneAccountHandle = phoneAccountHandle;
+ this.context = context;
+ contentResolver = context.getContentResolver();
+ this.uri = uri;
+ this.phoneAccountHandle = phoneAccountHandle;
}
/**
@@ -65,26 +65,26 @@ public class VoicemailFetchedCallback {
ContentValues values = new ContentValues();
values.put(
Voicemails.TRANSCRIPTION,
- mContext.getString(
+ context.getString(
R.string.vvm_unsupported_message_format,
- mContext
+ context
.getSystemService(TelecomManager.class)
- .getVoiceMailNumber(mPhoneAccountHandle)));
+ .getVoiceMailNumber(phoneAccountHandle)));
updateVoicemail(values);
return;
}
- VvmLog.d(TAG, String.format("Writing new voicemail content: %s", mUri));
+ VvmLog.d(TAG, String.format("Writing new voicemail content: %s", uri));
OutputStream outputStream = null;
try {
- outputStream = mContentResolver.openOutputStream(mUri);
+ outputStream = contentResolver.openOutputStream(uri);
byte[] inputBytes = voicemailPayload.getBytes();
if (inputBytes != null) {
outputStream.write(inputBytes);
}
} catch (IOException e) {
- VvmLog.w(TAG, String.format("File not found for %s", mUri));
+ VvmLog.w(TAG, String.format("File not found for %s", uri));
return;
} finally {
IOUtils.closeQuietly(outputStream);
@@ -98,15 +98,15 @@ public class VoicemailFetchedCallback {
ThreadUtil.postOnUiThread(
() -> {
if (!TranscriptionService.scheduleNewVoicemailTranscriptionJob(
- mContext, mUri, mPhoneAccountHandle, true)) {
- VvmLog.w(TAG, String.format("Failed to schedule transcription for %s", mUri));
+ context, uri, phoneAccountHandle, true)) {
+ VvmLog.w(TAG, String.format("Failed to schedule transcription for %s", uri));
}
});
}
}
private boolean updateVoicemail(ContentValues values) {
- int updatedCount = mContentResolver.update(mUri, values, null, null);
+ int updatedCount = contentResolver.update(uri, values, null, null);
if (updatedCount != 1) {
VvmLog.e(TAG, "Updating voicemail should have updated 1 row, was: " + updatedCount);
return false;