summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail/impl/sync
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/voicemail/impl/sync')
-rw-r--r--java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java76
-rw-r--r--java/com/android/voicemail/impl/sync/SyncOneTask.java14
-rw-r--r--java/com/android/voicemail/impl/sync/SyncTask.java14
-rw-r--r--java/com/android/voicemail/impl/sync/VoicemailStatusQueryHelper.java16
-rw-r--r--java/com/android/voicemail/impl/sync/VoicemailsQueryHelper.java38
-rw-r--r--java/com/android/voicemail/impl/sync/VvmNetworkRequest.java20
-rw-r--r--java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java72
7 files changed, 124 insertions, 126 deletions
diff --git a/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java b/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
index f7c8f29c7..cf2763be7 100644
--- a/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
+++ b/java/com/android/voicemail/impl/sync/OmtpVvmSyncService.java
@@ -56,12 +56,12 @@ public class OmtpVvmSyncService {
/** Threshold for whether we should archive and delete voicemails from the remote VM server. */
private static final float AUTO_DELETE_ARCHIVE_VM_THRESHOLD = 0.75f;
- private final Context mContext;
- private final VoicemailsQueryHelper mQueryHelper;
+ private final Context context;
+ private final VoicemailsQueryHelper queryHelper;
public OmtpVvmSyncService(Context context) {
- mContext = context;
- mQueryHelper = new VoicemailsQueryHelper(mContext);
+ this.context = context;
+ queryHelper = new VoicemailsQueryHelper(this.context);
}
public void sync(
@@ -79,22 +79,22 @@ public class OmtpVvmSyncService {
PhoneAccountHandle phoneAccount,
Voicemail voicemail,
VoicemailStatus.Editor status) {
- if (!VisualVoicemailSettingsUtil.isEnabled(mContext, phoneAccount)) {
+ if (!VisualVoicemailSettingsUtil.isEnabled(context, phoneAccount)) {
VvmLog.e(TAG, "Sync requested for disabled account");
return;
}
- if (!VvmAccountManager.isAccountActivated(mContext, phoneAccount)) {
- ActivationTask.start(mContext, phoneAccount, null);
+ if (!VvmAccountManager.isAccountActivated(context, phoneAccount)) {
+ ActivationTask.start(context, phoneAccount, null);
return;
}
- OmtpVvmCarrierConfigHelper config = new OmtpVvmCarrierConfigHelper(mContext, phoneAccount);
- LoggerUtils.logImpressionOnMainThread(mContext, DialerImpression.Type.VVM_SYNC_STARTED);
+ 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(mContext, phoneAccount), OmtpEvents.DATA_IMAP_OPERATION_STARTED);
+ 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");
@@ -114,7 +114,7 @@ public class OmtpVvmSyncService {
PhoneAccountHandle phoneAccount,
Voicemail voicemail,
VoicemailStatus.Editor status) {
- try (ImapHelper imapHelper = new ImapHelper(mContext, phoneAccount, network, status)) {
+ try (ImapHelper imapHelper = new ImapHelper(context, phoneAccount, network, status)) {
boolean success;
if (voicemail == null) {
success = syncAll(imapHelper, phoneAccount);
@@ -126,7 +126,7 @@ public class OmtpVvmSyncService {
imapHelper.updateQuota();
autoDeleteAndArchiveVM(imapHelper, phoneAccount);
imapHelper.handleEvent(OmtpEvents.DATA_IMAP_OPERATION_COMPLETED);
- LoggerUtils.logImpressionOnMainThread(mContext, DialerImpression.Type.VVM_SYNC_COMPLETED);
+ LoggerUtils.logImpressionOnMainThread(context, DialerImpression.Type.VVM_SYNC_COMPLETED);
} else {
task.fail();
}
@@ -142,16 +142,16 @@ public class OmtpVvmSyncService {
*/
private void autoDeleteAndArchiveVM(
ImapHelper imapHelper, PhoneAccountHandle phoneAccountHandle) {
- if (!isArchiveAllowedAndEnabled(mContext, phoneAccountHandle)) {
+ if (!isArchiveAllowedAndEnabled(context, phoneAccountHandle)) {
VvmLog.i(TAG, "autoDeleteAndArchiveVM is turned off");
LoggerUtils.logImpressionOnMainThread(
- mContext, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETE_TURNED_OFF);
+ context, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETE_TURNED_OFF);
return;
}
Quota quotaOnServer = imapHelper.getQuota();
if (quotaOnServer == null) {
LoggerUtils.logImpressionOnMainThread(
- mContext, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETE_FAILED_DUE_TO_FAILED_QUOTA_CHECK);
+ context, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETE_FAILED_DUE_TO_FAILED_QUOTA_CHECK);
VvmLog.e(TAG, "autoDeleteAndArchiveVM failed - Can't retrieve Imap quota.");
return;
}
@@ -161,7 +161,7 @@ public class OmtpVvmSyncService {
deleteAndArchiveVM(imapHelper, quotaOnServer);
imapHelper.updateQuota();
LoggerUtils.logImpressionOnMainThread(
- mContext, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETED_VM_FROM_SERVER);
+ context, DialerImpression.Type.VVM_ARCHIVE_AUTO_DELETED_VM_FROM_SERVER);
} else {
VvmLog.i(TAG, "no need to archive and auto delete VM, quota below threshold");
}
@@ -194,10 +194,10 @@ public class OmtpVvmSyncService {
// The number of voicemails that exceed our threshold and should be deleted from the server
int numVoicemails =
quotaOnServer.occupied - (int) (AUTO_DELETE_ARCHIVE_VM_THRESHOLD * quotaOnServer.total);
- List<Voicemail> oldestVoicemails = mQueryHelper.oldestVoicemailsOnServer(numVoicemails);
+ List<Voicemail> oldestVoicemails = queryHelper.oldestVoicemailsOnServer(numVoicemails);
VvmLog.w(TAG, "number of voicemails to delete " + numVoicemails);
if (!oldestVoicemails.isEmpty()) {
- mQueryHelper.markArchivedInDatabase(oldestVoicemails);
+ queryHelper.markArchivedInDatabase(oldestVoicemails);
imapHelper.markMessagesAsDeleted(oldestVoicemails);
VvmLog.i(
TAG,
@@ -211,8 +211,8 @@ public class OmtpVvmSyncService {
private boolean syncAll(ImapHelper imapHelper, PhoneAccountHandle account) {
List<Voicemail> serverVoicemails = imapHelper.fetchAllVoicemails();
- List<Voicemail> localVoicemails = mQueryHelper.getAllVoicemails(account);
- List<Voicemail> deletedVoicemails = mQueryHelper.getDeletedVoicemails(account);
+ List<Voicemail> localVoicemails = queryHelper.getAllVoicemails(account);
+ List<Voicemail> deletedVoicemails = queryHelper.getDeletedVoicemails(account);
boolean succeeded = true;
if (localVoicemails == null || serverVoicemails == null) {
@@ -225,7 +225,7 @@ public class OmtpVvmSyncService {
if (imapHelper.markMessagesAsDeleted(deletedVoicemails)) {
// Delete only the voicemails that was deleted on the server, in case more are deleted
// since the IMAP query was completed.
- mQueryHelper.deleteFromDatabase(deletedVoicemails);
+ queryHelper.deleteFromDatabase(deletedVoicemails);
} else {
succeeded = false;
}
@@ -249,10 +249,10 @@ public class OmtpVvmSyncService {
// Do not delete voicemails that are archived marked as archived.
if (remoteVoicemail == null) {
- mQueryHelper.deleteNonArchivedFromDatabase(localVoicemail);
+ queryHelper.deleteNonArchivedFromDatabase(localVoicemail);
} else {
if (remoteVoicemail.isRead() && !localVoicemail.isRead()) {
- mQueryHelper.markReadInDatabase(localVoicemail);
+ queryHelper.markReadInDatabase(localVoicemail);
} else if (localVoicemail.isRead() && !remoteVoicemail.isRead()) {
localReadVoicemails.add(localVoicemail);
}
@@ -260,8 +260,8 @@ public class OmtpVvmSyncService {
if (!TextUtils.isEmpty(remoteVoicemail.getTranscription())
&& TextUtils.isEmpty(localVoicemail.getTranscription())) {
LoggerUtils.logImpressionOnMainThread(
- mContext, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
- mQueryHelper.updateWithTranscription(localVoicemail, remoteVoicemail.getTranscription());
+ context, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
+ queryHelper.updateWithTranscription(localVoicemail, remoteVoicemail.getTranscription());
}
}
}
@@ -270,7 +270,7 @@ public class OmtpVvmSyncService {
VvmLog.i(TAG, "Marking voicemails as read");
if (imapHelper.markMessagesAsRead(localReadVoicemails)) {
VvmLog.i(TAG, "Marking voicemails as clean");
- mQueryHelper.markCleanInDatabase(localReadVoicemails);
+ queryHelper.markCleanInDatabase(localReadVoicemails);
} else {
return false;
}
@@ -281,12 +281,12 @@ public class OmtpVvmSyncService {
for (Voicemail remoteVoicemail : remoteMap.values()) {
if (!TextUtils.isEmpty(remoteVoicemail.getTranscription())) {
LoggerUtils.logImpressionOnMainThread(
- mContext, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
+ context, DialerImpression.Type.VVM_TRANSCRIPTION_DOWNLOADED);
}
- Uri uri = VoicemailDatabaseUtil.insert(mContext, remoteVoicemail);
+ Uri uri = VoicemailDatabaseUtil.insert(context, remoteVoicemail);
if (prefetchEnabled) {
VoicemailFetchedCallback fetchedCallback =
- new VoicemailFetchedCallback(mContext, uri, account);
+ new VoicemailFetchedCallback(context, uri, account);
imapHelper.fetchVoicemailPayload(fetchedCallback, remoteVoicemail.getSourceData());
}
}
@@ -298,17 +298,17 @@ public class OmtpVvmSyncService {
ImapHelper imapHelper, Voicemail voicemail, PhoneAccountHandle account) {
if (shouldPerformPrefetch(account, imapHelper)) {
VoicemailFetchedCallback callback =
- new VoicemailFetchedCallback(mContext, voicemail.getUri(), account);
+ new VoicemailFetchedCallback(context, voicemail.getUri(), account);
imapHelper.fetchVoicemailPayload(callback, voicemail.getSourceData());
}
return imapHelper.fetchTranscription(
- new TranscriptionFetchedCallback(mContext, voicemail), voicemail.getSourceData());
+ new TranscriptionFetchedCallback(context, voicemail), voicemail.getSourceData());
}
private boolean shouldPerformPrefetch(PhoneAccountHandle account, ImapHelper imapHelper) {
OmtpVvmCarrierConfigHelper carrierConfigHelper =
- new OmtpVvmCarrierConfigHelper(mContext, account);
+ new OmtpVvmCarrierConfigHelper(context, account);
return carrierConfigHelper.isPrefetchEnabled() && !imapHelper.isRoaming();
}
@@ -324,17 +324,17 @@ public class OmtpVvmSyncService {
/** Callback for {@link ImapHelper#fetchTranscription(TranscriptionFetchedCallback, String)} */
public static class TranscriptionFetchedCallback {
- private Context mContext;
- private Voicemail mVoicemail;
+ private Context context;
+ private Voicemail voicemail;
public TranscriptionFetchedCallback(Context context, Voicemail voicemail) {
- mContext = context;
- mVoicemail = voicemail;
+ this.context = context;
+ this.voicemail = voicemail;
}
public void setVoicemailTranscription(String transcription) {
- VoicemailsQueryHelper queryHelper = new VoicemailsQueryHelper(mContext);
- queryHelper.updateWithTranscription(mVoicemail, transcription);
+ VoicemailsQueryHelper queryHelper = new VoicemailsQueryHelper(context);
+ queryHelper.updateWithTranscription(voicemail, transcription);
}
}
}
diff --git a/java/com/android/voicemail/impl/sync/SyncOneTask.java b/java/com/android/voicemail/impl/sync/SyncOneTask.java
index 70c6bd890..2f0b23f46 100644
--- a/java/com/android/voicemail/impl/sync/SyncOneTask.java
+++ b/java/com/android/voicemail/impl/sync/SyncOneTask.java
@@ -41,8 +41,8 @@ public class SyncOneTask extends BaseTask {
private static final String EXTRA_PHONE_ACCOUNT_HANDLE = "extra_phone_account_handle";
private static final String EXTRA_VOICEMAIL = "extra_voicemail";
- private PhoneAccountHandle mPhone;
- private Voicemail mVoicemail;
+ private PhoneAccountHandle phone;
+ private Voicemail voicemail;
public static void start(Context context, PhoneAccountHandle phone, Voicemail voicemail) {
Intent intent = BaseTask.createIntent(context, SyncOneTask.class, phone);
@@ -59,22 +59,22 @@ public class SyncOneTask extends BaseTask {
@Override
public void onCreate(Context context, Bundle extras) {
super.onCreate(context, extras);
- mPhone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
- mVoicemail = extras.getParcelable(EXTRA_VOICEMAIL);
+ phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
+ voicemail = extras.getParcelable(EXTRA_VOICEMAIL);
}
@Override
public void onExecuteInBackgroundThread() {
OmtpVvmSyncService service = new OmtpVvmSyncService(getContext());
- service.sync(this, mPhone, mVoicemail, VoicemailStatus.edit(getContext(), mPhone));
+ service.sync(this, phone, voicemail, VoicemailStatus.edit(getContext(), phone));
}
@Override
public Intent createRestartIntent() {
LoggerUtils.logImpressionOnMainThread(getContext(), DialerImpression.Type.VVM_AUTO_RETRY_SYNC);
Intent intent = super.createRestartIntent();
- intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, mPhone);
- intent.putExtra(EXTRA_VOICEMAIL, mVoicemail);
+ intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phone);
+ intent.putExtra(EXTRA_VOICEMAIL, voicemail);
return intent;
}
}
diff --git a/java/com/android/voicemail/impl/sync/SyncTask.java b/java/com/android/voicemail/impl/sync/SyncTask.java
index 68ce0122e..06a5e9e81 100644
--- a/java/com/android/voicemail/impl/sync/SyncTask.java
+++ b/java/com/android/voicemail/impl/sync/SyncTask.java
@@ -38,9 +38,9 @@ public class SyncTask extends BaseTask {
private static final String EXTRA_PHONE_ACCOUNT_HANDLE = "extra_phone_account_handle";
- private final RetryPolicy mRetryPolicy;
+ private final RetryPolicy retryPolicy;
- private PhoneAccountHandle mPhone;
+ private PhoneAccountHandle phone;
public static void start(Context context, PhoneAccountHandle phone) {
Intent intent = BaseTask.createIntent(context, SyncTask.class, phone);
@@ -50,28 +50,28 @@ public class SyncTask extends BaseTask {
public SyncTask() {
super(TASK_SYNC);
- mRetryPolicy = new RetryPolicy(RETRY_TIMES, RETRY_INTERVAL_MILLIS);
- addPolicy(mRetryPolicy);
+ retryPolicy = new RetryPolicy(RETRY_TIMES, RETRY_INTERVAL_MILLIS);
+ addPolicy(retryPolicy);
addPolicy(new MinimalIntervalPolicy(MINIMAL_INTERVAL_MILLIS));
}
@Override
public void onCreate(Context context, Bundle extras) {
super.onCreate(context, extras);
- mPhone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
+ phone = extras.getParcelable(EXTRA_PHONE_ACCOUNT_HANDLE);
}
@Override
public void onExecuteInBackgroundThread() {
OmtpVvmSyncService service = new OmtpVvmSyncService(getContext());
- service.sync(this, mPhone, null, mRetryPolicy.getVoicemailStatusEditor());
+ service.sync(this, phone, null, retryPolicy.getVoicemailStatusEditor());
}
@Override
public Intent createRestartIntent() {
LoggerUtils.logImpressionOnMainThread(getContext(), DialerImpression.Type.VVM_AUTO_RETRY_SYNC);
Intent intent = super.createRestartIntent();
- intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, mPhone);
+ intent.putExtra(EXTRA_PHONE_ACCOUNT_HANDLE, phone);
return intent;
}
}
diff --git a/java/com/android/voicemail/impl/sync/VoicemailStatusQueryHelper.java b/java/com/android/voicemail/impl/sync/VoicemailStatusQueryHelper.java
index 4ef19daf6..259d79bcc 100644
--- a/java/com/android/voicemail/impl/sync/VoicemailStatusQueryHelper.java
+++ b/java/com/android/voicemail/impl/sync/VoicemailStatusQueryHelper.java
@@ -39,14 +39,14 @@ public class VoicemailStatusQueryHelper {
public static final int NOTIFICATION_CHANNEL_STATE = 2;
public static final int SOURCE_PACKAGE = 3;
- private Context mContext;
- private ContentResolver mContentResolver;
- private Uri mSourceUri;
+ private Context context;
+ private ContentResolver contentResolver;
+ private Uri sourceUri;
public VoicemailStatusQueryHelper(Context context) {
- mContext = context;
- mContentResolver = context.getContentResolver();
- mSourceUri = VoicemailContract.Status.buildSourceUri(mContext.getPackageName());
+ this.context = context;
+ contentResolver = context.getContentResolver();
+ sourceUri = VoicemailContract.Status.buildSourceUri(this.context.getPackageName());
}
/**
@@ -97,8 +97,8 @@ public class VoicemailStatusQueryHelper {
+ "=? AND "
+ Status.SOURCE_PACKAGE
+ "=?";
- String[] whereArgs = {phoneAccountComponentName, phoneAccountId, mContext.getPackageName()};
- cursor = mContentResolver.query(mSourceUri, PROJECTION, whereClause, whereArgs, null);
+ String[] whereArgs = {phoneAccountComponentName, phoneAccountId, context.getPackageName()};
+ cursor = contentResolver.query(sourceUri, PROJECTION, whereClause, whereArgs, null);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getInt(columnIndex) == value;
}
diff --git a/java/com/android/voicemail/impl/sync/VoicemailsQueryHelper.java b/java/com/android/voicemail/impl/sync/VoicemailsQueryHelper.java
index 1af5e688e..c47b40dab 100644
--- a/java/com/android/voicemail/impl/sync/VoicemailsQueryHelper.java
+++ b/java/com/android/voicemail/impl/sync/VoicemailsQueryHelper.java
@@ -52,14 +52,14 @@ public class VoicemailsQueryHelper {
static final String DELETED_SELECTION = Voicemails.DELETED + "=1";
static final String ARCHIVED_SELECTION = Voicemails.ARCHIVED + "=0";
- private Context mContext;
- private ContentResolver mContentResolver;
- private Uri mSourceUri;
+ private Context context;
+ private ContentResolver contentResolver;
+ private Uri sourceUri;
public VoicemailsQueryHelper(Context context) {
- mContext = context;
- mContentResolver = context.getContentResolver();
- mSourceUri = VoicemailContract.Voicemails.buildSourceUri(mContext.getPackageName());
+ this.context = context;
+ contentResolver = context.getContentResolver();
+ sourceUri = VoicemailContract.Voicemails.buildSourceUri(this.context.getPackageName());
}
/**
@@ -90,7 +90,7 @@ public class VoicemailsQueryHelper {
*/
private List<Voicemail> getLocalVoicemails(
@NonNull PhoneAccountHandle unusedPhoneAccountHandle, String selection) {
- Cursor cursor = mContentResolver.query(mSourceUri, PROJECTION, selection, null, null);
+ Cursor cursor = contentResolver.query(sourceUri, PROJECTION, selection, null, null);
if (cursor == null) {
return null;
}
@@ -135,12 +135,12 @@ public class VoicemailsQueryHelper {
}
String selectionStatement = String.format(Voicemails._ID + " IN (%s)", sb.toString());
- return mContentResolver.delete(Voicemails.CONTENT_URI, selectionStatement, null);
+ return contentResolver.delete(Voicemails.CONTENT_URI, selectionStatement, null);
}
/** Utility method to delete a single voicemail that is not archived. */
public void deleteNonArchivedFromDatabase(Voicemail voicemail) {
- mContentResolver.delete(
+ contentResolver.delete(
Voicemails.CONTENT_URI,
Voicemails._ID + "=? AND " + Voicemails.ARCHIVED + "= 0",
new String[] {Long.toString(voicemail.getId())});
@@ -156,10 +156,10 @@ public class VoicemailsQueryHelper {
/** Utility method to mark single message as read. */
public void markReadInDatabase(Voicemail voicemail) {
- Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+ Uri uri = ContentUris.withAppendedId(sourceUri, voicemail.getId());
ContentValues contentValues = new ContentValues();
contentValues.put(Voicemails.IS_READ, "1");
- mContentResolver.update(uri, contentValues, null, null);
+ contentResolver.update(uri, contentValues, null, null);
}
/**
@@ -181,17 +181,17 @@ public class VoicemailsQueryHelper {
/** Utility method to mark single message as clean. */
public void markCleanInDatabase(Voicemail voicemail) {
- Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+ Uri uri = ContentUris.withAppendedId(sourceUri, voicemail.getId());
ContentValues contentValues = new ContentValues();
- mContentResolver.update(uri, contentValues, null, null);
+ contentResolver.update(uri, contentValues, null, null);
}
/** Utility method to add a transcription to the voicemail. */
public void updateWithTranscription(Voicemail voicemail, String transcription) {
- Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+ Uri uri = ContentUris.withAppendedId(sourceUri, voicemail.getId());
ContentValues contentValues = new ContentValues();
contentValues.put(Voicemails.TRANSCRIPTION, transcription);
- mContentResolver.update(uri, contentValues, null, null);
+ contentResolver.update(uri, contentValues, null, null);
}
/**
@@ -221,7 +221,7 @@ public class VoicemailsQueryHelper {
+ Voicemails.SOURCE_DATA
+ "=?";
String[] whereArgs = {phoneAccountComponentName, phoneAccountId, sourceData};
- cursor = mContentResolver.query(mSourceUri, PROJECTION, whereClause, whereArgs, null);
+ cursor = contentResolver.query(sourceUri, PROJECTION, whereClause, whereArgs, null);
if (cursor.getCount() == 0) {
return true;
} else {
@@ -249,10 +249,10 @@ public class VoicemailsQueryHelper {
/** Utility method to mark single voicemail as archived. */
public void markArchiveInDatabase(Voicemail voicemail) {
- Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+ Uri uri = ContentUris.withAppendedId(sourceUri, voicemail.getId());
ContentValues contentValues = new ContentValues();
contentValues.put(Voicemails.ARCHIVED, "1");
- mContentResolver.update(uri, contentValues, null, null);
+ contentResolver.update(uri, contentValues, null, null);
}
/** Find the oldest voicemails that are on the device, and also on the server. */
@@ -265,7 +265,7 @@ public class VoicemailsQueryHelper {
String sortAndLimit = "date ASC limit " + numVoicemails;
try (Cursor cursor =
- mContentResolver.query(mSourceUri, PROJECTION, ARCHIVED_SELECTION, null, sortAndLimit)) {
+ contentResolver.query(sourceUri, PROJECTION, ARCHIVED_SELECTION, null, sortAndLimit)) {
Assert.isNotNull(cursor);
diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
index 189dc8f2b..e7517363c 100644
--- a/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
+++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequest.java
@@ -45,21 +45,21 @@ public class VvmNetworkRequest {
*/
public static class NetworkWrapper implements Closeable {
- private final Network mNetwork;
- private final VvmNetworkRequestCallback mCallback;
+ private final Network network;
+ private final VvmNetworkRequestCallback callback;
private NetworkWrapper(Network network, VvmNetworkRequestCallback callback) {
- mNetwork = network;
- mCallback = callback;
+ this.network = network;
+ this.callback = callback;
}
public Network get() {
- return mNetwork;
+ return network;
}
@Override
public void close() {
- mCallback.releaseNetwork();
+ callback.releaseNetwork();
}
}
@@ -92,7 +92,7 @@ public class VvmNetworkRequest {
* {@link CompletableFuture#get()} will block until {@link CompletableFuture# complete(Object) }
* has been called on the other thread.
*/
- private final CompletableFuture<NetworkWrapper> mFuture = new CompletableFuture<>();
+ private final CompletableFuture<NetworkWrapper> future = new CompletableFuture<>();
public FutureNetworkRequestCallback(
OmtpVvmCarrierConfigHelper config,
@@ -102,19 +102,19 @@ public class VvmNetworkRequest {
}
public Future<NetworkWrapper> getFuture() {
- return mFuture;
+ return future;
}
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
- mFuture.complete(new NetworkWrapper(network, this));
+ future.complete(new NetworkWrapper(network, this));
}
@Override
public void onFailed(String reason) {
super.onFailed(reason);
- mFuture.complete(null);
+ future.complete(null);
}
}
}
diff --git a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
index 17f5c1608..60ba166ba 100644
--- a/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
+++ b/java/com/android/voicemail/impl/sync/VvmNetworkRequestCallback.java
@@ -48,37 +48,37 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
public static final String NETWORK_REQUEST_FAILED_TIMEOUT = "timeout";
public static final String NETWORK_REQUEST_FAILED_LOST = "lost";
- protected Context mContext;
- protected PhoneAccountHandle mPhoneAccount;
- protected NetworkRequest mNetworkRequest;
- private ConnectivityManager mConnectivityManager;
- private final OmtpVvmCarrierConfigHelper mCarrierConfigHelper;
- private final VoicemailStatus.Editor mStatus;
- private boolean mRequestSent = false;
- private boolean mResultReceived = false;
+ protected Context context;
+ protected PhoneAccountHandle phoneAccount;
+ protected NetworkRequest networkRequest;
+ private ConnectivityManager connectivityManager;
+ private final OmtpVvmCarrierConfigHelper carrierConfigHelper;
+ private final VoicemailStatus.Editor status;
+ private boolean requestSent = false;
+ private boolean resultReceived = false;
public VvmNetworkRequestCallback(
Context context, PhoneAccountHandle phoneAccount, VoicemailStatus.Editor status) {
- mContext = context;
- mPhoneAccount = phoneAccount;
- mStatus = status;
- mCarrierConfigHelper = new OmtpVvmCarrierConfigHelper(context, mPhoneAccount);
- mNetworkRequest = createNetworkRequest();
+ this.context = context;
+ this.phoneAccount = phoneAccount;
+ this.status = status;
+ carrierConfigHelper = new OmtpVvmCarrierConfigHelper(context, this.phoneAccount);
+ networkRequest = createNetworkRequest();
}
public VvmNetworkRequestCallback(
OmtpVvmCarrierConfigHelper config,
PhoneAccountHandle phoneAccount,
VoicemailStatus.Editor status) {
- mContext = config.getContext();
- mPhoneAccount = phoneAccount;
- mStatus = status;
- mCarrierConfigHelper = config;
- mNetworkRequest = createNetworkRequest();
+ context = config.getContext();
+ this.phoneAccount = phoneAccount;
+ this.status = status;
+ carrierConfigHelper = config;
+ networkRequest = createNetworkRequest();
}
public VoicemailStatus.Editor getVoicemailStatusEditor() {
- return mStatus;
+ return status;
}
/**
@@ -91,12 +91,10 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
TelephonyManager telephonyManager =
- mContext
- .getSystemService(TelephonyManager.class)
- .createForPhoneAccountHandle(mPhoneAccount);
+ context.getSystemService(TelephonyManager.class).createForPhoneAccountHandle(phoneAccount);
// At this point mPhoneAccount should always be valid and telephonyManager will never be null
Assert.isNotNull(telephonyManager);
- if (mCarrierConfigHelper.isCellularDataRequired()) {
+ if (carrierConfigHelper.isCellularDataRequired()) {
VvmLog.d(TAG, "Transport type: CELLULAR");
builder
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
@@ -108,14 +106,14 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
}
public NetworkRequest getNetworkRequest() {
- return mNetworkRequest;
+ return networkRequest;
}
@Override
@CallSuper
public void onLost(Network network) {
VvmLog.d(TAG, "onLost");
- mResultReceived = true;
+ resultReceived = true;
onFailed(NETWORK_REQUEST_FAILED_LOST);
}
@@ -123,22 +121,22 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
@CallSuper
public void onAvailable(Network network) {
super.onAvailable(network);
- mResultReceived = true;
+ resultReceived = true;
}
@CallSuper
public void onUnavailable() {
// TODO(twyen): a bug this is hidden, do we really need this?
- mResultReceived = true;
+ resultReceived = true;
onFailed(NETWORK_REQUEST_FAILED_TIMEOUT);
}
public void requestNetwork() {
- if (mRequestSent == true) {
+ if (requestSent == true) {
VvmLog.e(TAG, "requestNetwork() called twice");
return;
}
- mRequestSent = true;
+ requestSent = true;
getConnectivityManager().requestNetwork(getNetworkRequest(), this);
/**
* Somehow requestNetwork() with timeout doesn't work, and it's a hidden method. Implement our
@@ -149,7 +147,7 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
new Runnable() {
@Override
public void run() {
- if (mResultReceived == false) {
+ if (resultReceived == false) {
onFailed(NETWORK_REQUEST_FAILED_TIMEOUT);
}
}
@@ -163,20 +161,20 @@ public abstract class VvmNetworkRequestCallback extends ConnectivityManager.Netw
}
public ConnectivityManager getConnectivityManager() {
- if (mConnectivityManager == null) {
- mConnectivityManager =
- (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivityManager == null) {
+ connectivityManager =
+ (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
- return mConnectivityManager;
+ return connectivityManager;
}
@CallSuper
public void onFailed(String reason) {
VvmLog.d(TAG, "onFailed: " + reason);
- if (mCarrierConfigHelper.isCellularDataRequired()) {
- mCarrierConfigHelper.handleEvent(mStatus, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED);
+ if (carrierConfigHelper.isCellularDataRequired()) {
+ carrierConfigHelper.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION_CELLULAR_REQUIRED);
} else {
- mCarrierConfigHelper.handleEvent(mStatus, OmtpEvents.DATA_NO_CONNECTION);
+ carrierConfigHelper.handleEvent(status, OmtpEvents.DATA_NO_CONNECTION);
}
releaseNetwork();
}