summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/enrichedcall
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-02-22 16:32:36 -0800
committerEric Erfanian <erfanian@google.com>2017-03-01 09:56:52 -0800
commitccca31529c07970e89419fb85a9e8153a5396838 (patch)
treea7034c0a01672b97728c13282a2672771cd28baa /java/com/android/dialer/enrichedcall
parente7ae4624ba6f25cb8e648db74e0d64c0113a16ba (diff)
Update dialer sources.
Test: Built package and system image. This change clobbers the old source, and is an export from an internal Google repository. The internal repository was forked form Android in March, and this change includes modifications since then, to near the v8 release. Since the fork, we've moved code from monolithic to independent modules. In addition, we've switched to Blaze/Bazel as the build sysetm. This export, however, still uses make. New dependencies have been added: - Dagger - Auto-Value - Glide - Libshortcutbadger Going forward, development will still be in Google3, and the Gerrit release will become an automated export, with the next drop happening in ~ two weeks. Android.mk includes local modifications from ToT. Abridged changelog: Bug fixes ● Not able to mute, add a call when using Phone app in multiwindow mode ● Double tap on keypad triggering multiple key and tones ● Reported spam numbers not showing as spam in the call log ● Crash when user tries to block number while Phone app is not set as default ● Crash when user picks a number from search auto-complete list Visual Voicemail (VVM) improvements ● Share Voicemail audio via standard exporting mechanisms that support file attachment (email, MMS, etc.) ● Make phone number, email and web sites in VVM transcript clickable ● Set PIN before declining VVM Terms of Service {Carrier} ● Set client type for outbound visual voicemail SMS {Carrier} New incoming call and incall UI on older devices (Android M) ● Updated Phone app icon ● New incall UI (large buttons, button labels) ● New and animated Answer/Reject gestures Accessibility ● Add custom answer/decline call buttons on answer screen for touch exploration accessibility services ● Increase size of touch target ● Add verbal feedback when a Voicemail fails to load ● Fix pressing of Phone buttons while in a phone call using Switch Access ● Fix selecting and opening contacts in talkback mode ● Split focus for ‘Learn More’ link in caller id & spam to help distinguish similar text Other ● Backup & Restore for App Preferences ● Prompt user to enable Wi-Fi calling if the call ends due to out of service and Wi-Fi is connected ● Rename “Dialpad” to “Keypad” ● Show "Private number" for restricted calls ● Delete unused items (vcard, add contact, call history) from Phone menu Change-Id: I2a7e53532a24c21bf308bf0a6d178d7ddbca4958
Diffstat (limited to 'java/com/android/dialer/enrichedcall')
-rw-r--r--java/com/android/dialer/enrichedcall/AutoValue_EnrichedCallCapabilities.java76
-rw-r--r--java/com/android/dialer/enrichedcall/AutoValue_OutgoingCallComposerData.java127
-rw-r--r--java/com/android/dialer/enrichedcall/EnrichedCallCapabilities.java36
-rw-r--r--java/com/android/dialer/enrichedcall/EnrichedCallManager.java225
-rw-r--r--java/com/android/dialer/enrichedcall/EnrichedCallManagerStub.java84
-rw-r--r--java/com/android/dialer/enrichedcall/OutgoingCallComposerData.java94
-rw-r--r--java/com/android/dialer/enrichedcall/Session.java63
-rw-r--r--java/com/android/dialer/enrichedcall/StubEnrichedCallModule.java32
-rw-r--r--java/com/android/dialer/enrichedcall/extensions/StateExtension.java54
9 files changed, 791 insertions, 0 deletions
diff --git a/java/com/android/dialer/enrichedcall/AutoValue_EnrichedCallCapabilities.java b/java/com/android/dialer/enrichedcall/AutoValue_EnrichedCallCapabilities.java
new file mode 100644
index 000000000..14299f92c
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/AutoValue_EnrichedCallCapabilities.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import javax.annotation.Generated;
+
+@Generated("com.google.auto.value.processor.AutoValueProcessor")
+ final class AutoValue_EnrichedCallCapabilities extends EnrichedCallCapabilities {
+
+ private final boolean supportsCallComposer;
+ private final boolean supportsPostCall;
+
+ AutoValue_EnrichedCallCapabilities(
+ boolean supportsCallComposer,
+ boolean supportsPostCall) {
+ this.supportsCallComposer = supportsCallComposer;
+ this.supportsPostCall = supportsPostCall;
+ }
+
+ @Override
+ public boolean supportsCallComposer() {
+ return supportsCallComposer;
+ }
+
+ @Override
+ public boolean supportsPostCall() {
+ return supportsPostCall;
+ }
+
+ @Override
+ public String toString() {
+ return "EnrichedCallCapabilities{"
+ + "supportsCallComposer=" + supportsCallComposer + ", "
+ + "supportsPostCall=" + supportsPostCall + ", "
+ + "}";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof EnrichedCallCapabilities) {
+ EnrichedCallCapabilities that = (EnrichedCallCapabilities) o;
+ return (this.supportsCallComposer == that.supportsCallComposer())
+ && (this.supportsPostCall == that.supportsPostCall());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int h = 1;
+ h *= 1000003;
+ h ^= this.supportsCallComposer ? 1231 : 1237;
+ h *= 1000003;
+ h ^= this.supportsPostCall ? 1231 : 1237;
+ return h;
+ }
+
+}
+
diff --git a/java/com/android/dialer/enrichedcall/AutoValue_OutgoingCallComposerData.java b/java/com/android/dialer/enrichedcall/AutoValue_OutgoingCallComposerData.java
new file mode 100644
index 000000000..edfefc479
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/AutoValue_OutgoingCallComposerData.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import android.net.Uri;
+import android.support.annotation.Nullable;
+import javax.annotation.Generated;
+
+@Generated("com.google.auto.value.processor.AutoValueProcessor")
+ final class AutoValue_OutgoingCallComposerData extends OutgoingCallComposerData {
+
+ private final String subject;
+ private final Uri imageUri;
+ private final String imageContentType;
+
+ private AutoValue_OutgoingCallComposerData(
+ @Nullable String subject,
+ @Nullable Uri imageUri,
+ @Nullable String imageContentType) {
+ this.subject = subject;
+ this.imageUri = imageUri;
+ this.imageContentType = imageContentType;
+ }
+
+ @Nullable
+ @Override
+ public String getSubject() {
+ return subject;
+ }
+
+ @Nullable
+ @Override
+ public Uri getImageUri() {
+ return imageUri;
+ }
+
+ @Nullable
+ @Override
+ public String getImageContentType() {
+ return imageContentType;
+ }
+
+ @Override
+ public String toString() {
+ return "OutgoingCallComposerData{"
+ + "subject=" + subject + ", "
+ + "imageUri=" + imageUri + ", "
+ + "imageContentType=" + imageContentType
+ + "}";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof OutgoingCallComposerData) {
+ OutgoingCallComposerData that = (OutgoingCallComposerData) o;
+ return ((this.subject == null) ? (that.getSubject() == null) : this.subject.equals(that.getSubject()))
+ && ((this.imageUri == null) ? (that.getImageUri() == null) : this.imageUri.equals(that.getImageUri()))
+ && ((this.imageContentType == null) ? (that.getImageContentType() == null) : this.imageContentType.equals(that.getImageContentType()));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int h = 1;
+ h *= 1000003;
+ h ^= (subject == null) ? 0 : this.subject.hashCode();
+ h *= 1000003;
+ h ^= (imageUri == null) ? 0 : this.imageUri.hashCode();
+ h *= 1000003;
+ h ^= (imageContentType == null) ? 0 : this.imageContentType.hashCode();
+ return h;
+ }
+
+ static final class Builder extends OutgoingCallComposerData.Builder {
+ private String subject;
+ private Uri imageUri;
+ private String imageContentType;
+ Builder() {
+ }
+ private Builder(OutgoingCallComposerData source) {
+ this.subject = source.getSubject();
+ this.imageUri = source.getImageUri();
+ this.imageContentType = source.getImageContentType();
+ }
+ @Override
+ public OutgoingCallComposerData.Builder setSubject(@Nullable String subject) {
+ this.subject = subject;
+ return this;
+ }
+ @Override
+ OutgoingCallComposerData.Builder setImageUri(@Nullable Uri imageUri) {
+ this.imageUri = imageUri;
+ return this;
+ }
+ @Override
+ OutgoingCallComposerData.Builder setImageContentType(@Nullable String imageContentType) {
+ this.imageContentType = imageContentType;
+ return this;
+ }
+ @Override
+ OutgoingCallComposerData autoBuild() {
+ return new AutoValue_OutgoingCallComposerData(
+ this.subject,
+ this.imageUri,
+ this.imageContentType);
+ }
+ }
+
+}
diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallCapabilities.java b/java/com/android/dialer/enrichedcall/EnrichedCallCapabilities.java
new file mode 100644
index 000000000..b7d780950
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/EnrichedCallCapabilities.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+
+
+/** Value type holding enriched call capabilities. */
+
+public abstract class EnrichedCallCapabilities {
+
+ public static final EnrichedCallCapabilities NO_CAPABILITIES =
+ EnrichedCallCapabilities.create(false, false);
+
+ public static EnrichedCallCapabilities create(
+ boolean supportsCallComposer, boolean supportsPostCall) {
+ return new AutoValue_EnrichedCallCapabilities(supportsCallComposer, supportsPostCall);
+ }
+
+ public abstract boolean supportsCallComposer();
+
+ public abstract boolean supportsPostCall();
+}
diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java
new file mode 100644
index 000000000..6af8c409a
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import android.app.Application;
+import android.support.annotation.IntDef;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.android.dialer.common.Assert;
+import com.android.dialer.multimedia.MultimediaData;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/** Performs all enriched calling logic. */
+public interface EnrichedCallManager {
+
+ /** Factory for {@link EnrichedCallManager}. */
+ interface Factory {
+ EnrichedCallManager getEnrichedCallManager();
+ }
+
+ /** Accessor for {@link EnrichedCallManager}. */
+ class Accessor {
+
+ /**
+ * @throws IllegalArgumentException if application does not implement {@link
+ * EnrichedCallManager.Factory}
+ */
+ @NonNull
+ public static EnrichedCallManager getInstance(@NonNull Application application) {
+ Assert.isNotNull(application);
+
+ return ((EnrichedCallManager.Factory) application).getEnrichedCallManager();
+ }
+ }
+
+ /** Receives updates when enriched call capabilities are ready. */
+ interface CapabilitiesListener {
+
+ /** Callback fired when the capabilities are updated. */
+ @MainThread
+ void onCapabilitiesUpdated();
+ }
+
+ /**
+ * Registers the given {@link CapabilitiesListener}.
+ *
+ * <p>As a result of this method, the listener will receive a call to {@link
+ * CapabilitiesListener#onCapabilitiesUpdated()} after a call to {@link
+ * #requestCapabilities(String)}.
+ */
+ @MainThread
+ void registerCapabilitiesListener(@NonNull CapabilitiesListener listener);
+
+ /**
+ * Starts an asynchronous process to get enriched call capabilities of the given number.
+ *
+ * <p>Registered listeners will receive a call to {@link
+ * CapabilitiesListener#onCapabilitiesUpdated()} on completion.
+ *
+ * @param number the remote number in any format
+ */
+ @MainThread
+ void requestCapabilities(@NonNull String number);
+
+ /**
+ * Unregisters the given {@link CapabilitiesListener}.
+ *
+ * <p>As a result of this method, the listener will not receive capabilities of the given number.
+ */
+ @MainThread
+ void unregisterCapabilitiesListener(@NonNull CapabilitiesListener listener);
+
+ /** Gets the cached capabilities for the given number, else null */
+ @MainThread
+ @Nullable
+ EnrichedCallCapabilities getCapabilities(@NonNull String number);
+
+ /** Clears any cached data, such as capabilities. */
+ @MainThread
+ void clearCachedData();
+
+ /** Possible states for call composer sessions. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ STATE_NONE,
+ STATE_STARTING,
+ STATE_STARTED,
+ STATE_START_FAILED,
+ STATE_MESSAGE_SENT,
+ STATE_MESSAGE_FAILED,
+ STATE_CLOSED,
+ })
+ @interface State {}
+
+ int STATE_NONE = 0;
+ int STATE_STARTING = STATE_NONE + 1;
+ int STATE_STARTED = STATE_STARTING + 1;
+ int STATE_START_FAILED = STATE_STARTED + 1;
+ int STATE_MESSAGE_SENT = STATE_START_FAILED + 1;
+ int STATE_MESSAGE_FAILED = STATE_MESSAGE_SENT + 1;
+ int STATE_CLOSED = STATE_MESSAGE_FAILED + 1;
+
+ /**
+ * Starts a call composer session with the given remote number.
+ *
+ * @param number the remote number in any format
+ * @return the id for the started session, or {@link Session#NO_SESSION_ID} if the session fails
+ */
+ @MainThread
+ long startCallComposerSession(@NonNull String number);
+
+ /**
+ * Sends the given information through an open enriched call session. As per the enriched calling
+ * spec, up to two messages are sent: the first is an enriched call data message that optionally
+ * includes the subject and the second is the optional image data message.
+ *
+ * @param sessionId the id for the session. See {@link #startCallComposerSession(String)}
+ * @param data the {@link MultimediaData}
+ * @throws IllegalArgumentException if there's no open session with the given number
+ * @throws IllegalStateException if the session isn't in the {@link #STATE_STARTED} state
+ */
+ @MainThread
+ void sendCallComposerData(long sessionId, @NonNull MultimediaData data);
+
+ /**
+ * Ends the given call composer session. Ending a session means that the call composer session
+ * will be closed.
+ *
+ * @param sessionId the id of the session to end
+ */
+ @MainThread
+ void endCallComposerSession(long sessionId);
+
+ /**
+ * Called once the capabilities are available for a corresponding call to {@link
+ * #requestCapabilities(String)}.
+ *
+ * @param number the remote number in any format
+ * @param capabilities the supported capabilities
+ */
+ @MainThread
+ void onCapabilitiesReceived(
+ @NonNull String number, @NonNull EnrichedCallCapabilities capabilities);
+
+ /** Receives updates when the state of an enriched call changes. */
+ interface StateChangedListener {
+
+ /**
+ * Callback fired when state changes. Listeners should call {@link #getSession(String)} to
+ * retrieve the new state.
+ */
+ void onEnrichedCallStateChanged();
+ }
+
+ /**
+ * Registers the given {@link StateChangedListener}.
+ *
+ * <p>As a result of this method, the listener will receive updates when the state of any enriched
+ * call changes.
+ */
+ @MainThread
+ void registerStateChangedListener(@NonNull StateChangedListener listener);
+
+ /** Returns the {@link Session} for the given number, or {@code null} if no session exists. */
+ @MainThread
+ @Nullable
+ Session getSession(@NonNull String number);
+
+ /** Returns the {@link Session} for the given sessionId, or {@code null} if no session exists. */
+ @MainThread
+ @Nullable
+ Session getSession(long sessionId);
+
+ /**
+ * Unregisters the given {@link StateChangedListener}.
+ *
+ * <p>As a result of this method, the listener will not receive updates when the state of enriched
+ * calls changes.
+ */
+ @MainThread
+ void unregisterStateChangedListener(@NonNull StateChangedListener listener);
+
+ /**
+ * Called when the status of an enriched call session changes.
+ *
+ *
+ * @throws IllegalArgumentException if the state is invalid
+ */
+ @MainThread
+ void onSessionStatusUpdate(long sessionId, @NonNull String number, int state);
+
+ /**
+ * Called when the status of an enriched call message updates.
+ *
+ *
+ * @throws IllegalArgumentException if the state is invalid
+ * @throws IllegalStateException if there's no session for the given id
+ */
+ @MainThread
+ void onMessageUpdate(long sessionId, @NonNull String messageId, int state);
+
+ /**
+ * Called when call composer data arrives for the given session.
+ *
+ * @throws IllegalStateException if there's no session for the given id
+ */
+ @MainThread
+ void onIncomingCallComposerData(long sessionId, @NonNull MultimediaData multimediaData);
+}
diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallManagerStub.java b/java/com/android/dialer/enrichedcall/EnrichedCallManagerStub.java
new file mode 100644
index 000000000..db9a799d3
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/EnrichedCallManagerStub.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.android.dialer.multimedia.MultimediaData;
+
+/** Stub implementation of {@link EnrichedCallManager}. */
+public final class EnrichedCallManagerStub implements EnrichedCallManager {
+
+ @Override
+ public void registerCapabilitiesListener(@NonNull CapabilitiesListener listener) {}
+
+ @Override
+ public void requestCapabilities(@NonNull String number) {}
+
+ @Override
+ public void unregisterCapabilitiesListener(@NonNull CapabilitiesListener listener) {}
+
+ @Override
+ public EnrichedCallCapabilities getCapabilities(@NonNull String number) {
+ return null;
+ }
+
+ @Override
+ public void clearCachedData() {}
+
+ @Override
+ public long startCallComposerSession(@NonNull String number) {
+ return Session.NO_SESSION_ID;
+ }
+
+ @Override
+ public void sendCallComposerData(long sessionId, @NonNull MultimediaData data) {}
+
+ @Override
+ public void endCallComposerSession(long sessionId) {}
+
+ @Override
+ public void onCapabilitiesReceived(
+ @NonNull String number, @NonNull EnrichedCallCapabilities capabilities) {}
+
+ @Override
+ public void registerStateChangedListener(@NonNull StateChangedListener listener) {}
+
+ @Nullable
+ @Override
+ public Session getSession(@NonNull String number) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Session getSession(long sessionId) {
+ return null;
+ }
+
+ @Override
+ public void unregisterStateChangedListener(@NonNull StateChangedListener listener) {}
+
+ @Override
+ public void onSessionStatusUpdate(long sessionId, @NonNull String number, int state) {}
+
+ @Override
+ public void onMessageUpdate(long sessionId, @NonNull String messageId, int state) {}
+
+ @Override
+ public void onIncomingCallComposerData(long sessionId, @NonNull MultimediaData multimediaData) {}
+}
diff --git a/java/com/android/dialer/enrichedcall/OutgoingCallComposerData.java b/java/com/android/dialer/enrichedcall/OutgoingCallComposerData.java
new file mode 100644
index 000000000..a8ee49d4e
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/OutgoingCallComposerData.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import com.android.dialer.common.Assert;
+
+
+/**
+ * Value type holding references to all data that could be provided for the call composer.
+ *
+ * <p>Note: Either the subject, the image data, or both must be specified, e.g.
+ *
+ * <pre>
+ * OutgoingCallComposerData.builder.build(); // throws exception, no data set
+ * OutgoingCallComposerData
+ * .setSubject(subject)
+ * .build(); // Success
+ * OutgoingCallComposerData
+ * .setImageData(uri, contentType)
+ * .build(); // Success
+ * OutgoingCallComposerData
+ * .setSubject(subject)
+ * .setImageData(uri, contentType)
+ * .build(); // Success
+ * </pre>
+ */
+
+public abstract class OutgoingCallComposerData {
+
+ public static Builder builder() {
+ return new AutoValue_OutgoingCallComposerData.Builder();
+ }
+
+ public boolean hasImageData() {
+ return getImageUri() != null && getImageContentType() != null;
+ }
+
+ @Nullable
+ public abstract String getSubject();
+
+ @Nullable
+ public abstract Uri getImageUri();
+
+ @Nullable
+ public abstract String getImageContentType();
+
+ /** Builds instances of {@link OutgoingCallComposerData}. */
+
+ public abstract static class Builder {
+ public abstract Builder setSubject(String subject);
+
+ public Builder setImageData(@NonNull Uri imageUri, @NonNull String imageContentType) {
+ setImageUri(Assert.isNotNull(imageUri));
+ setImageContentType(Assert.isNotNull(imageContentType));
+ return this;
+ }
+
+ abstract Builder setImageUri(Uri imageUri);
+
+ abstract Builder setImageContentType(String imageContentType);
+
+ abstract OutgoingCallComposerData autoBuild();
+
+ /**
+ * Returns the OutgoingCallComposerData from this builder.
+ *
+ * @return the OutgoingCallComposerData.
+ * @throws IllegalStateException if neither {@link #setSubject(String)} nor {@link
+ * #setImageData(Uri, String)} were called.
+ */
+ public OutgoingCallComposerData build() {
+ OutgoingCallComposerData data = autoBuild();
+ Assert.checkState(data.getSubject() != null || data.hasImageData());
+ return data;
+ }
+ }
+}
diff --git a/java/com/android/dialer/enrichedcall/Session.java b/java/com/android/dialer/enrichedcall/Session.java
new file mode 100644
index 000000000..b0439fae9
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/Session.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall;
+
+import android.support.annotation.NonNull;
+import com.android.dialer.enrichedcall.EnrichedCallManager.State;
+import com.android.dialer.multimedia.MultimediaData;
+
+/** Holds state information and data about enriched calling sessions. */
+public interface Session {
+
+ /** Id used for sessions that fail to start. */
+ long NO_SESSION_ID = -1;
+
+ /**
+ * An id for the specific case when sending a message fails so early that a message id isn't
+ * created.
+ */
+ String MESSAGE_ID_COULD_NOT_CREATE_ID = "messageIdCouldNotCreateId";
+
+ /**
+ * Returns the id associated with this session, or {@link #NO_SESSION_ID} if this represents a
+ * session that failed to start.
+ */
+ long getSessionId();
+
+ /** Returns the number associated with the remote end of this session. */
+ @NonNull
+ String getRemoteNumber();
+
+ /** Returns the {@link State} for this session. */
+ @State
+ int getState();
+
+ /** Returns the {@link MultimediaData} associated with this session. */
+ @NonNull
+ MultimediaData getMultimediaData();
+
+ /** Returns type of this session, based on some arbitrarily defined type. */
+ int getType();
+
+ /**
+ * Sets the {@link MultimediaData} for this session.
+ *
+ *
+ * @throws IllegalArgumentException if the type is invalid
+ */
+ void setSessionData(@NonNull MultimediaData multimediaData, int type);
+}
diff --git a/java/com/android/dialer/enrichedcall/StubEnrichedCallModule.java b/java/com/android/dialer/enrichedcall/StubEnrichedCallModule.java
new file mode 100644
index 000000000..39c55d040
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/StubEnrichedCallModule.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 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 com.android.dialer.enrichedcall;
+
+import dagger.Module;
+import dagger.Provides;
+import javax.inject.Singleton;
+
+/** Module which binds {@link EnrichedCallManagerStub}. */
+@Module
+public class StubEnrichedCallModule {
+
+ @Provides
+ @Singleton
+ static EnrichedCallManager provideEnrichedCallManager() {
+ return new EnrichedCallManagerStub();
+ }
+}
diff --git a/java/com/android/dialer/enrichedcall/extensions/StateExtension.java b/java/com/android/dialer/enrichedcall/extensions/StateExtension.java
new file mode 100644
index 000000000..8a4f6409d
--- /dev/null
+++ b/java/com/android/dialer/enrichedcall/extensions/StateExtension.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 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 com.android.dialer.enrichedcall.extensions;
+
+import android.support.annotation.NonNull;
+import com.android.dialer.common.Assert;
+import com.android.dialer.enrichedcall.EnrichedCallManager;
+import com.android.dialer.enrichedcall.EnrichedCallManager.State;
+
+/** Extends the {@link State} to include a toString method. */
+public class StateExtension {
+
+ /** Returns the string representation for the given {@link State}. */
+ @NonNull
+ public static String toString(@State int callComposerState) {
+ if (callComposerState == EnrichedCallManager.STATE_NONE) {
+ return "STATE_NONE";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_STARTING) {
+ return "STATE_STARTING";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_STARTED) {
+ return "STATE_STARTED";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_START_FAILED) {
+ return "STATE_START_FAILED";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_MESSAGE_SENT) {
+ return "STATE_MESSAGE_SENT";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_MESSAGE_FAILED) {
+ return "STATE_MESSAGE_FAILED";
+ }
+ if (callComposerState == EnrichedCallManager.STATE_CLOSED) {
+ return "STATE_CLOSED";
+ }
+ Assert.checkArgument(false, "Unexpected callComposerState: %d", callComposerState);
+ return null;
+ }
+}