diff options
Diffstat (limited to 'telecomm/java/android/telecom')
-rw-r--r-- | telecomm/java/android/telecom/AuthenticatorService.java | 99 | ||||
-rw-r--r-- | telecomm/java/android/telecom/Call.java | 76 | ||||
-rw-r--r-- | telecomm/java/android/telecom/Connection.java | 72 | ||||
-rw-r--r-- | telecomm/java/android/telecom/PhoneAccount.java | 14 | ||||
-rw-r--r-- | telecomm/java/android/telecom/PhoneAccountHandle.java | 20 | ||||
-rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 17 | ||||
-rw-r--r-- | telecomm/java/android/telecom/VideoProfile.java | 2 | ||||
-rw-r--r-- | telecomm/java/android/telecom/Voicemail.java | 266 |
8 files changed, 523 insertions, 43 deletions
diff --git a/telecomm/java/android/telecom/AuthenticatorService.java b/telecomm/java/android/telecom/AuthenticatorService.java new file mode 100644 index 0000000..39717c3 --- /dev/null +++ b/telecomm/java/android/telecom/AuthenticatorService.java @@ -0,0 +1,99 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package android.telecom; +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.NetworkErrorException; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; + +/** + * A generic stub account authenticator service often used for sync adapters that do not directly + * involve accounts. + */ +public class AuthenticatorService extends Service { + private static Authenticator mAuthenticator; + + @Override + public void onCreate() { + mAuthenticator = new Authenticator(this); + } + + @Override + public IBinder onBind(Intent intent) { + return mAuthenticator.getIBinder(); + } + + /** + * Stub account authenticator. All methods either return null or throw an exception. + */ + public class Authenticator extends AbstractAccountAuthenticator { + public Authenticator(Context context) { + super(context); + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse accountAuthenticatorResponse, + String s) { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse accountAuthenticatorResponse, + String s, String s2, String[] strings, Bundle bundle) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, Bundle bundle) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String s, Bundle bundle) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + + @Override + public String getAuthTokenLabel(String s) { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String s, Bundle bundle) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse accountAuthenticatorResponse, + Account account, String[] strings) + throws NetworkErrorException { + throw new UnsupportedOperationException(); + } + } +} diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index c1d2f9b..436f20a 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -141,28 +141,42 @@ public final class Call { public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; /** - * Local device supports video telephony. + * Local device supports receiving video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_LOCAL = 0x00000100; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; /** - * Remote device supports video telephony. + * Local device supports transmitting video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_REMOTE = 0x00000200; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; /** - * Call is using high definition audio. + * Local device supports bidirectional video calling. * @hide */ - public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00000400; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL = + CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; /** - * Call is using WIFI. + * Remote device supports receiving video. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; + + /** + * Remote device supports transmitting video. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; + + /** + * Remote device supports bidirectional video calling. * @hide */ - public static final int CAPABILITY_WIFI = 0x00000800; + public static final int CAPABILITY_SUPPORTS_VT_REMOTE = + CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; /** * Call is able to be separated from its parent {@code Conference}, if any. @@ -183,10 +197,37 @@ public final class Call { public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; /** + * Call is using high definition audio. + * @hide + */ + public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; + + /** + * Call is using WIFI. + * @hide + */ + public static final int CAPABILITY_WIFI = 0x00010000; + + //****************************************************************************************** + // Next CAPABILITY value: 0x00020000 + //****************************************************************************************** + + /** + * Indicates that the current device callback number should be shown. + * + * @hide + */ + public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; + + /** * Speed up audio setup for MT call. * @hide */ - public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00008000; + public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; + + //****************************************************************************************** + // Next CAPABILITY value: 0x00080000 + //****************************************************************************************** private final Uri mHandle; private final int mHandlePresentation; @@ -255,9 +296,21 @@ public final class Call { if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { builder.append(" CAPABILITY_MANAGE_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); + } if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL)) { builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL"); } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); + } if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE)) { builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE"); } @@ -270,8 +323,11 @@ public final class Call { if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { builder.append(" CAPABILITY_GENERIC_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { + builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); + } if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { - builder.append(" CAPABILITY_SPEED_UP_IMS_MT_AUDIO"); + builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); } builder.append("]"); return builder.toString(); diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 569163a..bab064e 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -106,28 +106,42 @@ public abstract class Connection implements IConferenceable { public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; /** - * Local device supports video telephony. + * Local device supports receiving video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_LOCAL = 0x00000100; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; /** - * Remote device supports video telephony. + * Local device supports transmitting video. * @hide */ - public static final int CAPABILITY_SUPPORTS_VT_REMOTE = 0x00000200; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; /** - * Connection is using high definition audio. + * Local device supports bidirectional video calling. * @hide */ - public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00000400; + public static final int CAPABILITY_SUPPORTS_VT_LOCAL = + CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; /** - * Connection is using WIFI. + * Remote device supports receiving video. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; + + /** + * Remote device supports transmitting video. + * @hide + */ + public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; + + /** + * Remote device supports bidirectional video calling. * @hide */ - public static final int CAPABILITY_WIFI = 0x00000800; + public static final int CAPABILITY_SUPPORTS_VT_REMOTE = + CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; /** * Connection is able to be separated from its parent {@code Conference}, if any. @@ -148,10 +162,33 @@ public abstract class Connection implements IConferenceable { public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; /** + * Connection is using high definition audio. + * @hide + */ + public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; + + /** + * Connection is using WIFI. + * @hide + */ + public static final int CAPABILITY_WIFI = 0x00010000; + + /** + * Indicates that the current device callback number should be shown. + * + * @hide + */ + public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; + + /** * Speed up audio setup for MT call. * @hide */ - public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00008000; + public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; + + //********************************************************************************************** + // Next CAPABILITY value: 0x00080000 + //********************************************************************************************** // Flag controlling whether PII is emitted into the logs private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); @@ -224,9 +261,21 @@ public abstract class Connection implements IConferenceable { if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { builder.append(" CAPABILITY_MANAGE_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); + } if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL)) { builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL"); } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); + } + if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { + builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); + } if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE)) { builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE"); } @@ -239,8 +288,11 @@ public abstract class Connection implements IConferenceable { if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { builder.append(" CAPABILITY_GENERIC_CONFERENCE"); } + if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { + builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); + } if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { - builder.append(" CAPABILITY_SPEED_UP_IMS_MT_AUDIO"); + builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); } builder.append("]"); return builder.toString(); diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index 052a481..a94c2f6 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -40,15 +40,13 @@ import java.util.MissingResourceException; /** * Represents a distinct method to place or receive a phone call. Apps which can place calls and * want those calls to be integrated into the dialer and in-call UI should build an instance of - * this class and register it with the system using {@link TelecomManager#registerPhoneAccount}. + * this class and register it with the system using {@link TelecomManager}. * <p> * {@link TelecomManager} uses registered {@link PhoneAccount}s to present the user with * alternative options when placing a phone call. When building a {@link PhoneAccount}, the app - * should supply a valid {@link PhoneAccountHandle} that references the {@link ConnectionService} + * should supply a valid {@link PhoneAccountHandle} that references the connection service * implementation Telecom will use to interact with the app. - * @hide */ -@SystemApi public class PhoneAccount implements Parcelable { /** @@ -62,7 +60,9 @@ public class PhoneAccount implements Parcelable { * if the user has explicitly selected it to be used as the default connection manager. * <p> * See {@link #getCapabilities} + * @hide */ + @SystemApi public static final int CAPABILITY_CONNECTION_MANAGER = 0x1; /** @@ -76,6 +76,7 @@ public class PhoneAccount implements Parcelable { * <p> * {@hide} */ + @SystemApi public static final int CAPABILITY_CALL_PROVIDER = 0x2; /** @@ -94,6 +95,7 @@ public class PhoneAccount implements Parcelable { * See {@link #getCapabilities} * @hide */ + @SystemApi public static final int CAPABILITY_VIDEO_CALLING = 0x8; /** @@ -111,6 +113,7 @@ public class PhoneAccount implements Parcelable { * See {@link #getCapabilities} * @hide */ + @SystemApi public static final int CAPABILITY_MULTI_USER = 0x20; /** @@ -203,6 +206,7 @@ public class PhoneAccount implements Parcelable { } /** @hide */ + @SystemApi public Builder setAccountHandle(PhoneAccountHandle accountHandle) { mAccountHandle = accountHandle; return this; @@ -333,6 +337,7 @@ public class PhoneAccount implements Parcelable { * @return The builder. * @hide */ + @SystemApi public Builder addSupportedUriScheme(String uriScheme) { if (!TextUtils.isEmpty(uriScheme) && !mSupportedUriSchemes.contains(uriScheme)) { this.mSupportedUriSchemes.add(uriScheme); @@ -423,6 +428,7 @@ public class PhoneAccount implements Parcelable { * @return The builder. * @hide */ + @SystemApi public Builder toBuilder() { return new Builder(this); } /** diff --git a/telecomm/java/android/telecom/PhoneAccountHandle.java b/telecomm/java/android/telecom/PhoneAccountHandle.java index 97af41a..4600b72 100644 --- a/telecomm/java/android/telecom/PhoneAccountHandle.java +++ b/telecomm/java/android/telecom/PhoneAccountHandle.java @@ -29,16 +29,13 @@ import java.util.Objects; * The unique identifier for a {@link PhoneAccount}. A {@code PhoneAccountHandle} is made of two * parts: * <ul> - * <li>The component name of the associated {@link ConnectionService}.</li> + * <li>The component name of the associated connection service.</li> * <li>A string identifier that is unique across {@code PhoneAccountHandle}s with the same * component name.</li> * </ul> * - * See {@link PhoneAccount}, - * {@link TelecomManager#registerPhoneAccount TelecomManager.registerPhoneAccount}. - * @hide + * See {@link PhoneAccount}, {@link TelecomManager}. */ -@SystemApi public class PhoneAccountHandle implements Parcelable { private final ComponentName mComponentName; private final String mId; @@ -51,6 +48,7 @@ public class PhoneAccountHandle implements Parcelable { } /** @hide */ + @SystemApi public PhoneAccountHandle( ComponentName componentName, String id, @@ -61,8 +59,8 @@ public class PhoneAccountHandle implements Parcelable { } /** - * The {@code ComponentName} of the {@link android.telecom.ConnectionService} which is - * responsible for making phone calls using this {@code PhoneAccountHandle}. + * The {@code ComponentName} of the connection service which is responsible for making phone + * calls using this {@code PhoneAccountHandle}. * * @return A suitable {@code ComponentName}. */ @@ -72,9 +70,9 @@ public class PhoneAccountHandle implements Parcelable { /** * A string that uniquely distinguishes this particular {@code PhoneAccountHandle} from all the - * others supported by the {@link ConnectionService} that created it. + * others supported by the connection service that created it. * <p> - * A {@code ConnectionService} must select identifiers that are stable for the lifetime of + * A connection service must select identifiers that are stable for the lifetime of * their users' relationship with their service, across many Android devices. For example, a * good set of identifiers might be the email addresses with which with users registered for * their accounts with a particular service. Depending on how a service chooses to operate, @@ -82,6 +80,9 @@ public class PhoneAccountHandle implements Parcelable { * ({@code 0}, {@code 1}, {@code 2}, ...) that are generated locally on each phone and could * collide with values generated on other phones or after a data wipe of a given phone. * + * Important: A non-unique identifier could cause non-deterministic call-log backup/restore + * behavior. + * * @return A service-specific unique identifier for this {@code PhoneAccountHandle}. */ public String getId() { @@ -92,6 +93,7 @@ public class PhoneAccountHandle implements Parcelable { * @return the {@link UserHandle} to use when connecting to this PhoneAccount. * @hide */ + @SystemApi public UserHandle getUserHandle() { return mUserHandle; } diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 1a6b292..8be3e66 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -92,6 +92,15 @@ public class TelecomManager { "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; /** + * The {@link android.content.Intent} action used indicate that a new phone account was + * just registered. + * @hide + */ + @SystemApi + public static final String ACTION_PHONE_ACCOUNT_REGISTERED = + "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; + + /** * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that * determines whether the speakerphone should be automatically turned on for an outgoing call. */ @@ -106,7 +115,6 @@ public class TelecomManager { * {@link VideoProfile.VideoState#BIDIRECTIONAL}, * {@link VideoProfile.VideoState#RX_ENABLED}, * {@link VideoProfile.VideoState#TX_ENABLED}. - * @hide */ public static final String EXTRA_START_CALL_WITH_VIDEO_STATE = "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"; @@ -117,9 +125,7 @@ public class TelecomManager { * {@link PhoneAccountHandle} to use when making the call. * <p class="note"> * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. - * @hide */ - @SystemApi public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "android.telecom.extra.PHONE_ACCOUNT_HANDLE"; @@ -139,10 +145,7 @@ public class TelecomManager { * {@link android.content.Intent#ACTION_DIAL} {@code Intent} containing a {@link Bundle} * which contains metadata about the call. This {@link Bundle} will be saved into * {@code Call.Details}. - * - * @hide */ - @SystemApi public static final String EXTRA_OUTGOING_CALL_EXTRAS = "android.telecom.extra.OUTGOING_CALL_EXTRAS"; @@ -554,9 +557,7 @@ public class TelecomManager { * * @param account The {@link PhoneAccountHandle}. * @return The {@link PhoneAccount} object. - * @hide */ - @SystemApi public PhoneAccount getPhoneAccount(PhoneAccountHandle account) { try { if (isServiceConnected()) { diff --git a/telecomm/java/android/telecom/VideoProfile.java b/telecomm/java/android/telecom/VideoProfile.java index f5cb054..e62e994 100644 --- a/telecomm/java/android/telecom/VideoProfile.java +++ b/telecomm/java/android/telecom/VideoProfile.java @@ -21,8 +21,6 @@ import android.os.Parcelable; /** * Represents attributes of video calls. - * - * {@hide} */ public class VideoProfile implements Parcelable { /** diff --git a/telecomm/java/android/telecom/Voicemail.java b/telecomm/java/android/telecom/Voicemail.java new file mode 100644 index 0000000..864c6b1 --- /dev/null +++ b/telecomm/java/android/telecom/Voicemail.java @@ -0,0 +1,266 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecom; + +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Represents a single voicemail stored in the voicemail content provider. + */ +public class Voicemail implements Parcelable { + private final Long mTimestamp; + private final String mNumber; + private final Long mId; + private final Long mDuration; + private final String mSource; + private final String mProviderData; + private final Uri mUri; + 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) { + mTimestamp = timestamp; + mNumber = number; + mId = id; + mDuration = duration; + mSource = source; + mProviderData = providerData; + mUri = uri; + mIsRead = isRead; + mHasContent = hasContent; + } + + /** + * Create a {@link Builder} for a new {@link Voicemail} to be inserted. + * <p> + * The number and the timestamp are mandatory for insertion. + */ + public static Builder createForInsertion(long timestamp, String number) { + return new Builder().setNumber(number).setTimestamp(timestamp); + } + + /** + * Builder pattern for creating a {@link Voicemail}. The builder must be created with the + * {@link #createForInsertion(long, String)} method. + * <p> + * This class is <b>not thread safe</b> + */ + public static class Builder { + private Long mBuilderTimestamp; + private String mBuilderNumber; + private Long mBuilderId; + private Long mBuilderDuration; + private String mBuilderSourcePackage; + private String mBuilderSourceData; + private Uri mBuilderUri; + private Boolean mBuilderIsRead; + private boolean mBuilderHasContent; + + /** You should use the correct factory method to construct a builder. */ + private Builder() { + } + + public Builder setNumber(String number) { + mBuilderNumber = number; + return this; + } + + public Builder setTimestamp(long timestamp) { + mBuilderTimestamp = timestamp; + return this; + } + + public Builder setId(long id) { + mBuilderId = id; + return this; + } + + public Builder setDuration(long duration) { + mBuilderDuration = duration; + return this; + } + + public Builder setSourcePackage(String sourcePackage) { + mBuilderSourcePackage = sourcePackage; + return this; + } + + public Builder setSourceData(String sourceData) { + mBuilderSourceData = sourceData; + return this; + } + + public Builder setUri(Uri uri) { + mBuilderUri = uri; + return this; + } + + public Builder setIsRead(boolean isRead) { + mBuilderIsRead = isRead; + return this; + } + + public Builder setHasContent(boolean hasContent) { + mBuilderHasContent = hasContent; + return this; + } + + public Voicemail build() { + mBuilderId = mBuilderId == null ? -1 : mBuilderId; + 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); + } + } + + /** + * The identifier of the voicemail in the content provider. + * <p> + * This may be missing in the case of a new {@link Voicemail} that we plan to insert into the + * content provider, since until it has been inserted we don't know what id it should have. If + * none is specified, we return -1. + */ + public long getId() { + return mId; + } + + /** The number of the person leaving the voicemail, empty string if unknown, null if not set. */ + public String getNumber() { + return mNumber; + } + + /** The timestamp the voicemail was received, in millis since the epoch, zero if not set. */ + public long getTimestampMillis() { + return mTimestamp; + } + + /** Gets the duration of the voicemail in millis, or zero if the field is not set. */ + public long getDuration() { + return mDuration; + } + + /** + * Returns the package name of the source that added this voicemail, or null if this field is + * not set. + */ + public String getSourcePackage() { + return mSource; + } + + /** + * Returns the application-specific data type stored with the voicemail, or null if this field + * is not set. + * <p> + * Source data is typically used as an identifier to uniquely identify the voicemail against + * the voicemail server. This is likely to be something like the IMAP UID, or some other + * server-generated identifying string. + */ + public String getSourceData() { + return mProviderData; + } + + /** + * Gets the Uri that can be used to refer to this voicemail, and to make it play. + * <p> + * Returns null if we don't know the Uri. + */ + public Uri getUri() { + return mUri; + } + + /** + * Tells us if the voicemail message has been marked as read. + * <p> + * Always returns false if this field has not been set, i.e. if hasRead() returns false. + */ + public boolean isRead() { + return mIsRead; + } + + /** + * Tells us if there is content stored at the Uri. + */ + public boolean hasContent() { + return mHasContent; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeLong(mTimestamp); + dest.writeCharSequence(mNumber); + dest.writeLong(mId); + dest.writeLong(mDuration); + dest.writeCharSequence(mSource); + dest.writeCharSequence(mProviderData); + if (mUri == null) { + dest.writeInt(0); + } else { + dest.writeInt(1); + mUri.writeToParcel(dest, flags); + } + if (mIsRead) { + dest.writeInt(1); + } else { + dest.writeInt(0); + } + if (mHasContent) { + dest.writeInt(1); + } else { + dest.writeInt(0); + } + } + + public static final Creator<Voicemail> CREATOR + = new Creator<Voicemail>() { + @Override + public Voicemail createFromParcel(Parcel in) { + return new Voicemail(in); + } + + @Override + public Voicemail[] newArray(int size) { + return new Voicemail[size]; + } + }; + + private Voicemail(Parcel in) { + mTimestamp = in.readLong(); + mNumber = (String) in.readCharSequence(); + mId = in.readLong(); + mDuration = in.readLong(); + mSource = (String) in.readCharSequence(); + mProviderData = (String) in.readCharSequence(); + if (in.readInt() > 0) { + mUri = Uri.CREATOR.createFromParcel(in); + } else { + mUri = null; + } + mIsRead = in.readInt() > 0 ? true : false; + mHasContent = in.readInt() > 0 ? true : false; + } +}
\ No newline at end of file |