blob: 1ce7ef75ad46df7b9e93817e6b15d9c9154cfb5a [file] [log] [blame]
Eric Erfaniand5e47f62017-03-15 14:41:07 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.voicemail;
18
19import android.content.Context;
Eric Erfanianff2ad7f2017-07-27 10:45:54 -070020import android.os.PersistableBundle;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070021import android.provider.VoicemailContract.Voicemails;
Eric Erfanianff2ad7f2017-07-27 10:45:54 -070022import android.support.annotation.MainThread;
23import android.support.annotation.NonNull;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070024import android.support.annotation.Nullable;
25import android.telecom.PhoneAccountHandle;
26import android.telephony.TelephonyManager;
27import java.util.List;
28
29/** Public interface for the voicemail module */
30public interface VoicemailClient {
31
32 /**
Eric Erfanian90508232017-03-24 09:31:16 -070033 * Whether the voicemail module is enabled (OS has support and not disabled by flags, etc.). This
34 * does not mean the carrier has support or user has enabled the feature.
35 */
36 boolean isVoicemailModuleEnabled();
37
38 /**
Eric Erfaniand5e47f62017-03-15 14:41:07 -070039 * Broadcast to tell the client to upload local database changes to the server. Since the dialer
40 * UI and the client are in the same package, the {@link
41 * android.content.Intent#ACTION_PROVIDER_CHANGED} will always be a self-change even if the UI is
42 * external to the client.
43 */
Eric Erfanian8369df02017-05-03 10:27:13 -070044 String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD";
Eric Erfaniand5e47f62017-03-15 14:41:07 -070045
Eric Erfaniand8046e52017-04-06 09:41:50 -070046 /** Common key for passing {@link PhoneAccountHandle} in bundles. */
47 String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle";
48
Eric Erfaniand5e47f62017-03-15 14:41:07 -070049 /**
Eric Erfanian8369df02017-05-03 10:27:13 -070050 * Broadcast from the client to inform the app to show a legacy voicemail notification. This
51 * broadcast is same as {@link TelephonyManager#ACTION_SHOW_VOICEMAIL_NOTIFICATION}.
52 */
53 String ACTION_SHOW_LEGACY_VOICEMAIL =
54 "com.android.voicemail.VoicemailClient.ACTION_SHOW_LEGACY_VOICEMAIL";
55
56 /**
Eric Erfanianfc0eb8c2017-08-31 06:57:16 -070057 * Boolean extra send with {@link #ACTION_SHOW_LEGACY_VOICEMAIL}, indicating that the notification
58 * is sent by legacy mode and should not be suppressed even when VVM is activated
59 */
60 String EXTRA_IS_LEGACY_MODE = "is_legacy_mode";
61
62 /**
Eric Erfanianff2ad7f2017-07-27 10:45:54 -070063 * Secret code to launch the voicemail config activity intended for OEMs and Carriers. {@code
64 * *#*#VVMCONFIG#*#*}
65 */
66 String VOICEMAIL_SECRET_CODE = "886266344";
67
68 /**
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -080069 * Whether visual voicemail is supported by the carrier for the {@code phoneAccountHandle}. This
70 * is purely based on the MCCMNC, and a single account might still be disabled by the carrier.
71 */
72 boolean hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle);
73
74 /**
Eric Erfanian8369df02017-05-03 10:27:13 -070075 * Whether the visual voicemail service is enabled for the {@code phoneAccountHandle}. "Enable"
76 * means the user "wants" to have this service on, and does not mean the service is actually
77 * functional(For example, the service is blocked on the carrier side. The service will be
78 * "enabled" but all it will do is show the error).
79 */
80 boolean isVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
81
82 /**
83 * Enable or disable visual voicemail service for the {@code phoneAccountHandle}. Setting to
84 * enabled will initiate provisioning and activation. Setting to disabled will initiate
85 * deactivation.
86 */
87 void setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
88
89 /**
Eric Erfaniand5e47f62017-03-15 14:41:07 -070090 * Appends the selection to ignore voicemails from non-active OMTP voicemail package. In OC there
91 * can be multiple packages handling OMTP voicemails which represents the same source of truth.
92 * These packages should mark their voicemails as {@link Voicemails#IS_OMTP_VOICEMAIL} and only
93 * the voicemails from {@link TelephonyManager#getVisualVoicemailPackageName()} should be shown.
94 * For example, the user synced voicemails with DialerA, and then switched to DialerB, voicemails
95 * from DialerA should be ignored as they are no longer current. Voicemails from {@link
96 * #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as they are voicemail source only valid pre-OC.
97 */
98 void appendOmtpVoicemailSelectionClause(
99 Context context, StringBuilder where, List<String> selectionArgs);
Eric Erfanianfc37b022017-03-21 10:11:17 -0700100
101 /**
102 * Appends the selection to ignore voicemail status from non-active OMTP voicemail package. The
103 * {@link android.provider.VoicemailContract.Status#SOURCE_TYPE} is checked against a list of
104 * known OMTP types. Voicemails from {@link #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as
105 * they are voicemail source only valid pre-OC.
106 *
107 * @see #appendOmtpVoicemailSelectionClause(Context, StringBuilder, List)
108 */
109 void appendOmtpVoicemailStatusSelectionClause(
110 Context context, StringBuilder where, List<String> selectionArgs);
111
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700112 boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
113
Eric Erfaniand8046e52017-04-06 09:41:50 -0700114 /**
115 * @return if the voicemail archive feature is available on the current device. This depends on
116 * whether the server side flag is turned on for the feature, and if the OS meets the
117 * requirement for this feature.
118 */
119 boolean isVoicemailArchiveAvailable(Context context);
120
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700121 void setVoicemailArchiveEnabled(
122 Context context, PhoneAccountHandle phoneAccountHandle, boolean value);
Eric Erfaniand8046e52017-04-06 09:41:50 -0700123
124 /**
mdooleyec1a9702017-10-27 16:20:32 -0700125 * @return if the voicemail transcription feature is available on the current device. This depends
126 * on whether the server side flag is turned on for the feature, and if the OS meets the
127 * requirement for this feature.
128 */
129 boolean isVoicemailTranscriptionAvailable(Context context);
130
mdooley96f71f72017-11-01 15:26:50 -0700131 /** @return if the voicemail donation feature is available. */
132 boolean isVoicemailDonationAvailable(Context context);
133
mdooleyec1a9702017-10-27 16:20:32 -0700134 /** @return if the voicemail donation setting has been enabled by the user. */
135 boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account);
136
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -0800137 void setVoicemailDonationEnabled(
138 Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
Eric Erfanian8369df02017-05-03 10:27:13 -0700139
140 /**
141 * Whether the client is activated and handling visual voicemail for the {@code
142 * phoneAccountHandle}. "Enable" is the intention to use VVM. For example VVM can be enabled but
143 * prevented from working because the carrier blocked it, or a connection problem is blocking the
144 * provisioning. Being "activated" means all setup are completed, and VVM is expected to work.
145 */
146 boolean isActivated(Context context, PhoneAccountHandle phoneAccountHandle);
Eric Erfanianff2ad7f2017-07-27 10:45:54 -0700147
148 /**
149 * Called when {@link #VOICEMAIL_SECRET_CODE} is dialed. {@code context} will be a broadcast
150 * receiver context.
151 */
152 @MainThread
153 void showConfigUi(@NonNull Context context);
154
155 @NonNull
156 PersistableBundle getConfig(
157 @NonNull Context context, @Nullable PhoneAccountHandle phoneAccountHandle);
158
159 @MainThread
160 void onBoot(@NonNull Context context);
161
162 @MainThread
163 void onShutdown(@NonNull Context context);
Eric Erfanianfc0eb8c2017-08-31 06:57:16 -0700164
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -0800165 /** Listener for changes in {@link #isActivated(Context, PhoneAccountHandle)} */
166 interface ActivationStateListener {
167 @MainThread
168 void onActivationStateChanged(PhoneAccountHandle phoneAccountHandle, boolean isActivated);
169 }
170
171 @MainThread
172 void addActivationStateListener(ActivationStateListener listener);
173
174 @MainThread
175 void removeActivationStateListener(ActivationStateListener listener);
176
177 /** Provides interface to change the PIN used to access the mailbox by calling. */
178 PinChanger createPinChanger(Context context, PhoneAccountHandle phoneAccountHandle);
179
mdooley22ff3382017-11-16 21:25:00 -0800180 void onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle);
181
mdooley7e1a0d12017-11-17 11:02:48 -0800182 boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle);
183
mdooley22ff3382017-11-16 21:25:00 -0800184 /**
185 * @return arbitrary carrier configuration String value associate with the indicated key. See
186 * {@code CarrierConfigKeys.java}
187 */
188 @Nullable
189 String getCarrierConfigString(Context context, PhoneAccountHandle phoneAccountHandle, String key);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700190}