am e8f1f899: am 78250907: Merge "Add phone account field for voicemail to distinguish the source." into mnc-dev
* commit 'e8f1f899a127bc6c809f635b70be434c51cf6415': Add phone account field for voicemail to distinguish the source.
This commit is contained in:
@@ -306,6 +306,13 @@ public class VoicemailContract {
|
||||
contentValues.put(Voicemails.SOURCE_PACKAGE, voicemail.getSourcePackage());
|
||||
contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData());
|
||||
contentValues.put(Voicemails.IS_READ, voicemail.isRead() ? 1 : 0);
|
||||
|
||||
PhoneAccountHandle phoneAccount = voicemail.getPhoneAccount();
|
||||
if (voicemail.getPhoneAccount() != null) {
|
||||
contentValues.put(Voicemails.PHONE_ACCOUNT_COMPONENT_NAME,
|
||||
phoneAccount.getComponentName().flattenToString());
|
||||
contentValues.put(Voicemails.PHONE_ACCOUNT_ID, phoneAccount.getId());
|
||||
}
|
||||
return contentValues;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.os.Parcelable;
|
||||
public class Voicemail implements Parcelable {
|
||||
private final Long mTimestamp;
|
||||
private final String mNumber;
|
||||
private final PhoneAccountHandle mPhoneAccount;
|
||||
private final Long mId;
|
||||
private final Long mDuration;
|
||||
private final String mSource;
|
||||
@@ -36,10 +37,12 @@ public class Voicemail implements Parcelable {
|
||||
private final Boolean mIsRead;
|
||||
private final Boolean mHasContent;
|
||||
|
||||
private Voicemail(Long timestamp, String number, Long id, Long duration, String source,
|
||||
String providerData, Uri uri, Boolean isRead, Boolean hasContent) {
|
||||
private Voicemail(Long timestamp, String number, PhoneAccountHandle phoneAccountHandle, Long id,
|
||||
Long duration, String source, String providerData, Uri uri, Boolean isRead,
|
||||
Boolean hasContent) {
|
||||
mTimestamp = timestamp;
|
||||
mNumber = number;
|
||||
mPhoneAccount = phoneAccountHandle;
|
||||
mId = id;
|
||||
mDuration = duration;
|
||||
mSource = source;
|
||||
@@ -77,6 +80,7 @@ public class Voicemail implements Parcelable {
|
||||
public static class Builder {
|
||||
private Long mBuilderTimestamp;
|
||||
private String mBuilderNumber;
|
||||
private PhoneAccountHandle mBuilderPhoneAccount;
|
||||
private Long mBuilderId;
|
||||
private Long mBuilderDuration;
|
||||
private String mBuilderSourcePackage;
|
||||
@@ -99,6 +103,11 @@ public class Voicemail implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPhoneAccount(PhoneAccountHandle phoneAccount) {
|
||||
mBuilderPhoneAccount = phoneAccount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setId(long id) {
|
||||
mBuilderId = id;
|
||||
return this;
|
||||
@@ -139,9 +148,9 @@ public class Voicemail implements Parcelable {
|
||||
mBuilderTimestamp = mBuilderTimestamp == null ? 0 : mBuilderTimestamp;
|
||||
mBuilderDuration = mBuilderDuration == null ? 0: mBuilderDuration;
|
||||
mBuilderIsRead = mBuilderIsRead == null ? false : mBuilderIsRead;
|
||||
return new Voicemail(mBuilderTimestamp, mBuilderNumber, mBuilderId, mBuilderDuration,
|
||||
mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderIsRead,
|
||||
mBuilderHasContent);
|
||||
return new Voicemail(mBuilderTimestamp, mBuilderNumber, mBuilderPhoneAccount,
|
||||
mBuilderId, mBuilderDuration, mBuilderSourcePackage, mBuilderSourceData,
|
||||
mBuilderUri, mBuilderIsRead, mBuilderHasContent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +170,11 @@ public class Voicemail implements Parcelable {
|
||||
return mNumber;
|
||||
}
|
||||
|
||||
/** The phone account associated with the voicemail, null if not set. */
|
||||
public PhoneAccountHandle getPhoneAccount() {
|
||||
return mPhoneAccount;
|
||||
}
|
||||
|
||||
/** The timestamp the voicemail was received, in millis since the epoch, zero if not set. */
|
||||
public long getTimestampMillis() {
|
||||
return mTimestamp;
|
||||
@@ -225,6 +239,12 @@ public class Voicemail implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(mTimestamp);
|
||||
dest.writeCharSequence(mNumber);
|
||||
if (mPhoneAccount == null) {
|
||||
dest.writeInt(0);
|
||||
} else {
|
||||
dest.writeInt(1);
|
||||
mPhoneAccount.writeToParcel(dest, flags);
|
||||
}
|
||||
dest.writeLong(mId);
|
||||
dest.writeLong(mDuration);
|
||||
dest.writeCharSequence(mSource);
|
||||
@@ -263,6 +283,11 @@ public class Voicemail implements Parcelable {
|
||||
private Voicemail(Parcel in) {
|
||||
mTimestamp = in.readLong();
|
||||
mNumber = (String) in.readCharSequence();
|
||||
if (in.readInt() > 0) {
|
||||
mPhoneAccount = PhoneAccountHandle.CREATOR.createFromParcel(in);
|
||||
} else {
|
||||
mPhoneAccount = null;
|
||||
}
|
||||
mId = in.readLong();
|
||||
mDuration = in.readLong();
|
||||
mSource = (String) in.readCharSequence();
|
||||
|
||||
Reference in New Issue
Block a user