diff options
author | Eric Erfanian <erfanian@google.com> | 2017-03-15 14:41:07 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-03-15 16:24:23 -0700 |
commit | d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 (patch) | |
tree | b54abbb51fb7d66e7755a1fbb5db023ff601090b /java/com/android/dialer/backup | |
parent | 30436e7e6d3f2c8755a91b2b6222b74d465a9e87 (diff) |
Update Dialer source from latest green build.
* Refactor voicemail component
* Add new enriched calling components
Test: treehugger, manual aosp testing
Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942
Diffstat (limited to 'java/com/android/dialer/backup')
-rw-r--r-- | java/com/android/dialer/backup/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | java/com/android/dialer/backup/DialerBackupAgent.java | 18 | ||||
-rw-r--r-- | java/com/android/dialer/backup/DialerBackupUtils.java | 44 | ||||
-rw-r--r-- | java/com/android/dialer/backup/nano/VoicemailInfo.java (renamed from java/com/android/dialer/backup/proto/VoicemailInfo.java) | 280 |
4 files changed, 209 insertions, 136 deletions
diff --git a/java/com/android/dialer/backup/AndroidManifest.xml b/java/com/android/dialer/backup/AndroidManifest.xml index cfdb3d93d..1cbbe5339 100644 --- a/java/com/android/dialer/backup/AndroidManifest.xml +++ b/java/com/android/dialer/backup/AndroidManifest.xml @@ -21,7 +21,6 @@ android:backupAgent="com.android.dialer.backup.DialerBackupAgent" android:fullBackupOnly="true" android:restoreAnyVersion="true" - android:name="com.android.dialer.app.DialerApplication" /> -</manifest>
\ No newline at end of file +</manifest> diff --git a/java/com/android/dialer/backup/DialerBackupAgent.java b/java/com/android/dialer/backup/DialerBackupAgent.java index 391a93f29..2f8684aa2 100644 --- a/java/com/android/dialer/backup/DialerBackupAgent.java +++ b/java/com/android/dialer/backup/DialerBackupAgent.java @@ -31,6 +31,7 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.VoicemailContract; import android.provider.VoicemailContract.Voicemails; +import android.telecom.PhoneAccountHandle; import android.util.Pair; import com.android.dialer.backup.nano.VoicemailInfo; import com.android.dialer.common.Assert; @@ -42,6 +43,7 @@ import com.android.dialer.telecom.TelecomUtil; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.util.List; import java.util.Locale; /** @@ -100,9 +102,11 @@ public class DialerBackupAgent extends BackupAgent { ConfigProviderBindings.get(this).getBoolean("enable_autobackup", true); boolean vmBackupEnabled = ConfigProviderBindings.get(this).getBoolean("enable_vm_backup", false); + List<PhoneAccountHandle> phoneAccountsToArchive = + DialerBackupUtils.getPhoneAccountsToArchive(this); if (autoBackupEnabled) { - if (!maxVoicemailBackupReached && vmBackupEnabled) { + if (!maxVoicemailBackupReached && vmBackupEnabled && !phoneAccountsToArchive.isEmpty()) { voicemailsBackedupSoFar = 0; sizeOfVoicemailsBackedupSoFar = 0; @@ -123,9 +127,12 @@ public class DialerBackupAgent extends BackupAgent { uri, null, String.format( - "(%s = ? AND deleted = 0 AND %s = ?)", Calls.TYPE, Voicemails.SOURCE_PACKAGE), + "(%s = ? AND deleted = 0 AND %s = ? AND ?)", + Calls.TYPE, Voicemails.SOURCE_PACKAGE), new String[] { - Integer.toString(CallLog.Calls.VOICEMAIL_TYPE), VOICEMAIL_SOURCE_PACKAGE + Integer.toString(CallLog.Calls.VOICEMAIL_TYPE), + VOICEMAIL_SOURCE_PACKAGE, + DialerBackupUtils.getPhoneAccountClause(phoneAccountsToArchive) }, ORDER_BY_DATE, null)) { @@ -150,11 +157,12 @@ public class DialerBackupAgent extends BackupAgent { LogUtil.i( "DialerBackupAgent.onFullBackup", "vm files backed up: %d, vm size backed up:%d, " - + "max vm backup reached:%b, vm backup enabled:%b", + + "max vm backup reached:%b, vm backup enabled:%b phone accounts to archive: %d", voicemailsBackedupSoFar, sizeOfVoicemailsBackedupSoFar, maxVoicemailBackupReached, - vmBackupEnabled); + vmBackupEnabled, + phoneAccountsToArchive.size()); super.onFullBackup(data); Logger.get(this).logImpression(DialerImpression.Type.BACKUP_FULL_BACKED_UP); } else { diff --git a/java/com/android/dialer/backup/DialerBackupUtils.java b/java/com/android/dialer/backup/DialerBackupUtils.java index ff0cb4f7c..410772ff0 100644 --- a/java/com/android/dialer/backup/DialerBackupUtils.java +++ b/java/com/android/dialer/backup/DialerBackupUtils.java @@ -27,10 +27,14 @@ import android.provider.VoicemailContract; import android.provider.VoicemailContract.Voicemails; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.telecom.PhoneAccountHandle; +import android.telecom.TelecomManager; import android.util.Pair; import com.android.dialer.backup.nano.VoicemailInfo; +import com.android.dialer.common.Assert; import com.android.dialer.common.ConfigProviderBindings; import com.android.dialer.common.LogUtil; +import com.android.voicemail.VoicemailComponent; import com.google.common.io.ByteStreams; import com.google.common.io.Files; import com.google.protobuf.nano.MessageNano; @@ -40,6 +44,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; /** Helper functions for DialerBackupAgent */ public class DialerBackupUtils { @@ -317,4 +323,42 @@ public class DialerBackupUtils { } return false; } + + public static String getPhoneAccountClause(List<PhoneAccountHandle> phoneAccountsToArchive) { + Assert.checkArgument(!phoneAccountsToArchive.isEmpty()); + StringBuilder whereQuery = new StringBuilder(); + + whereQuery.append("("); + + for (int i = 0; i < phoneAccountsToArchive.size(); i++) { + whereQuery.append( + Voicemails.PHONE_ACCOUNT_ID + " = " + phoneAccountsToArchive.get(i).getId()); + + if (phoneAccountsToArchive.size() > 1 && i < phoneAccountsToArchive.size() - 1) { + whereQuery.append(" OR "); + } + } + whereQuery.append(")"); + return whereQuery.toString(); + } + + public static List<PhoneAccountHandle> getPhoneAccountsToArchive(Context context) { + List<PhoneAccountHandle> phoneAccountsToBackUp = new ArrayList<>(); + + for (PhoneAccountHandle handle : + context.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts()) { + + if (VoicemailComponent.get(context) + .getVoicemailClient() + .isVoicemailArchiveEnabled(context, handle)) { + phoneAccountsToBackUp.add(handle); + LogUtil.i( + "DialerBackupUtils.getPhoneAccountsToArchive", "enabled for: " + handle.toString()); + } else { + LogUtil.i( + "DialerBackupUtils.getPhoneAccountsToArchive", "not enabled for: " + handle.toString()); + } + } + return phoneAccountsToBackUp; + } } diff --git a/java/com/android/dialer/backup/proto/VoicemailInfo.java b/java/com/android/dialer/backup/nano/VoicemailInfo.java index 9ff8423f3..f11595ec2 100644 --- a/java/com/android/dialer/backup/proto/VoicemailInfo.java +++ b/java/com/android/dialer/backup/nano/VoicemailInfo.java @@ -18,16 +18,17 @@ package com.android.dialer.backup.nano; +/** This file is autogenerated, but javadoc required. */ @SuppressWarnings("hiding") -public final class VoicemailInfo extends - com.google.protobuf.nano.ExtendableMessageNano<VoicemailInfo> { +public final class VoicemailInfo + extends com.google.protobuf.nano.ExtendableMessageNano<VoicemailInfo> { private static volatile VoicemailInfo[] _emptyArray; + public static VoicemailInfo[] emptyArray() { // Lazily initializes the empty array if (_emptyArray == null) { - synchronized ( - com.google.protobuf.nano.InternalNano.LAZY_INIT_LOCK) { + synchronized (com.google.protobuf.nano.InternalNano.LAZY_INIT_LOCK) { if (_emptyArray == null) { _emptyArray = new VoicemailInfo[0]; } @@ -178,7 +179,8 @@ public final class VoicemailInfo extends if (this.voicemailUri != null && !this.voicemailUri.equals("")) { output.writeString(17, this.voicemailUri); } - if (!java.util.Arrays.equals(this.encodedVoicemailKey, com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES)) { + if (!java.util.Arrays.equals( + this.encodedVoicemailKey, com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES)) { output.writeBytes(18, this.encodedVoicemailKey); } if (this.archived != null && !this.archived.equals("")) { @@ -191,175 +193,196 @@ public final class VoicemailInfo extends protected int computeSerializedSize() { int size = super.computeSerializedSize(); if (this.date != null && !this.date.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(1, this.date); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(1, this.date); } if (this.deleted != null && !this.deleted.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(2, this.deleted); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(2, this.deleted); } if (this.dirty != null && !this.dirty.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(3, this.dirty); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(3, this.dirty); } if (this.dirType != null && !this.dirType.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(4, this.dirType); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(4, this.dirType); } if (this.duration != null && !this.duration.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(5, this.duration); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(5, this.duration); } if (this.hasContent != null && !this.hasContent.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(6, this.hasContent); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(6, this.hasContent); } if (this.isRead != null && !this.isRead.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(7, this.isRead); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(7, this.isRead); } if (this.itemType != null && !this.itemType.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(8, this.itemType); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(8, this.itemType); } if (this.lastModified != null && !this.lastModified.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(9, this.lastModified); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 9, this.lastModified); } if (this.mimeType != null && !this.mimeType.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(10, this.mimeType); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(10, this.mimeType); } if (this.number != null && !this.number.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(11, this.number); + size += com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(11, this.number); } if (this.phoneAccountComponentName != null && !this.phoneAccountComponentName.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(12, this.phoneAccountComponentName); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 12, this.phoneAccountComponentName); } if (this.phoneAccountId != null && !this.phoneAccountId.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(13, this.phoneAccountId); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 13, this.phoneAccountId); } if (this.sourceData != null && !this.sourceData.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(14, this.sourceData); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(14, this.sourceData); } if (this.sourcePackage != null && !this.sourcePackage.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(15, this.sourcePackage); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 15, this.sourcePackage); } if (this.transcription != null && !this.transcription.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(16, this.transcription); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 16, this.transcription); } if (this.voicemailUri != null && !this.voicemailUri.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(17, this.voicemailUri); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize( + 17, this.voicemailUri); } - if (!java.util.Arrays.equals(this.encodedVoicemailKey, com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES)) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeBytesSize(18, this.encodedVoicemailKey); + if (!java.util.Arrays.equals( + this.encodedVoicemailKey, com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES)) { + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeBytesSize( + 18, this.encodedVoicemailKey); } if (this.archived != null && !this.archived.equals("")) { - size += com.google.protobuf.nano.CodedOutputByteBufferNano - .computeStringSize(19, this.archived); + size += + com.google.protobuf.nano.CodedOutputByteBufferNano.computeStringSize(19, this.archived); } return size; } @Override - public VoicemailInfo mergeFrom( - com.google.protobuf.nano.CodedInputByteBufferNano input) + public VoicemailInfo mergeFrom(com.google.protobuf.nano.CodedInputByteBufferNano input) throws java.io.IOException { while (true) { int tag = input.readTag(); switch (tag) { case 0: return this; - default: { - if (!super.storeUnknownField(input, tag)) { - return this; + default: + { + if (!super.storeUnknownField(input, tag)) { + return this; + } + break; + } + case 10: + { + this.date = input.readString(); + break; + } + case 18: + { + this.deleted = input.readString(); + break; + } + case 26: + { + this.dirty = input.readString(); + break; + } + case 34: + { + this.dirType = input.readString(); + break; + } + case 42: + { + this.duration = input.readString(); + break; + } + case 50: + { + this.hasContent = input.readString(); + break; + } + case 58: + { + this.isRead = input.readString(); + break; + } + case 66: + { + this.itemType = input.readString(); + break; + } + case 74: + { + this.lastModified = input.readString(); + break; + } + case 82: + { + this.mimeType = input.readString(); + break; + } + case 90: + { + this.number = input.readString(); + break; + } + case 98: + { + this.phoneAccountComponentName = input.readString(); + break; + } + case 106: + { + this.phoneAccountId = input.readString(); + break; + } + case 114: + { + this.sourceData = input.readString(); + break; + } + case 122: + { + this.sourcePackage = input.readString(); + break; + } + case 130: + { + this.transcription = input.readString(); + break; + } + case 138: + { + this.voicemailUri = input.readString(); + break; + } + case 146: + { + this.encodedVoicemailKey = input.readBytes(); + break; + } + case 154: + { + this.archived = input.readString(); + break; } - break; - } - case 10: { - this.date = input.readString(); - break; - } - case 18: { - this.deleted = input.readString(); - break; - } - case 26: { - this.dirty = input.readString(); - break; - } - case 34: { - this.dirType = input.readString(); - break; - } - case 42: { - this.duration = input.readString(); - break; - } - case 50: { - this.hasContent = input.readString(); - break; - } - case 58: { - this.isRead = input.readString(); - break; - } - case 66: { - this.itemType = input.readString(); - break; - } - case 74: { - this.lastModified = input.readString(); - break; - } - case 82: { - this.mimeType = input.readString(); - break; - } - case 90: { - this.number = input.readString(); - break; - } - case 98: { - this.phoneAccountComponentName = input.readString(); - break; - } - case 106: { - this.phoneAccountId = input.readString(); - break; - } - case 114: { - this.sourceData = input.readString(); - break; - } - case 122: { - this.sourcePackage = input.readString(); - break; - } - case 130: { - this.transcription = input.readString(); - break; - } - case 138: { - this.voicemailUri = input.readString(); - break; - } - case 146: { - this.encodedVoicemailKey = input.readBytes(); - break; - } - case 154: { - this.archived = input.readString(); - break; - } } } } @@ -369,8 +392,7 @@ public final class VoicemailInfo extends return com.google.protobuf.nano.MessageNano.mergeFrom(new VoicemailInfo(), data); } - public static VoicemailInfo parseFrom( - com.google.protobuf.nano.CodedInputByteBufferNano input) + public static VoicemailInfo parseFrom(com.google.protobuf.nano.CodedInputByteBufferNano input) throws java.io.IOException { return new VoicemailInfo().mergeFrom(input); } |