blob: 5b382f1dc1e2c7387dde697e562d8f7910ba38ba [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 /**
33 * Broadcast to tell the client to upload local database changes to the server. Since the dialer
34 * UI and the client are in the same package, the {@link
35 * android.content.Intent#ACTION_PROVIDER_CHANGED} will always be a self-change even if the UI is
36 * external to the client.
37 */
Eric Erfanian8369df02017-05-03 10:27:13 -070038 String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD";
Eric Erfaniand8046e52017-04-06 09:41:50 -070039 /** Common key for passing {@link PhoneAccountHandle} in bundles. */
40 String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle";
Eric Erfaniand5e47f62017-03-15 14:41:07 -070041 /**
Eric Erfanian8369df02017-05-03 10:27:13 -070042 * Broadcast from the client to inform the app to show a legacy voicemail notification. This
43 * broadcast is same as {@link TelephonyManager#ACTION_SHOW_VOICEMAIL_NOTIFICATION}.
44 */
45 String ACTION_SHOW_LEGACY_VOICEMAIL =
46 "com.android.voicemail.VoicemailClient.ACTION_SHOW_LEGACY_VOICEMAIL";
Eric Erfanian8369df02017-05-03 10:27:13 -070047 /**
Eric Erfanianfc0eb8c2017-08-31 06:57:16 -070048 * Boolean extra send with {@link #ACTION_SHOW_LEGACY_VOICEMAIL}, indicating that the notification
49 * is sent by legacy mode and should not be suppressed even when VVM is activated
50 */
51 String EXTRA_IS_LEGACY_MODE = "is_legacy_mode";
Eric Erfanianfc0eb8c2017-08-31 06:57:16 -070052 /**
Eric Erfanianff2ad7f2017-07-27 10:45:54 -070053 * Secret code to launch the voicemail config activity intended for OEMs and Carriers. {@code
54 * *#*#VVMCONFIG#*#*}
55 */
56 String VOICEMAIL_SECRET_CODE = "886266344";
57
58 /**
uabdullaha7530f82018-03-16 17:32:54 -070059 * Whether the voicemail module is enabled (OS has support and not disabled by flags, etc.). This
60 * does not mean the carrier has support or user has enabled the feature.
61 */
62 boolean isVoicemailModuleEnabled();
63
64 /**
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -080065 * Whether visual voicemail is supported by the carrier for the {@code phoneAccountHandle}. This
66 * is purely based on the MCCMNC, and a single account might still be disabled by the carrier.
67 */
68 boolean hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle);
69
70 /**
Eric Erfanian8369df02017-05-03 10:27:13 -070071 * Whether the visual voicemail service is enabled for the {@code phoneAccountHandle}. "Enable"
72 * means the user "wants" to have this service on, and does not mean the service is actually
73 * functional(For example, the service is blocked on the carrier side. The service will be
74 * "enabled" but all it will do is show the error).
75 */
76 boolean isVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
77
78 /**
79 * Enable or disable visual voicemail service for the {@code phoneAccountHandle}. Setting to
80 * enabled will initiate provisioning and activation. Setting to disabled will initiate
81 * deactivation.
82 */
83 void setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
84
85 /**
Eric Erfaniand5e47f62017-03-15 14:41:07 -070086 * Appends the selection to ignore voicemails from non-active OMTP voicemail package. In OC there
87 * can be multiple packages handling OMTP voicemails which represents the same source of truth.
88 * These packages should mark their voicemails as {@link Voicemails#IS_OMTP_VOICEMAIL} and only
89 * the voicemails from {@link TelephonyManager#getVisualVoicemailPackageName()} should be shown.
90 * For example, the user synced voicemails with DialerA, and then switched to DialerB, voicemails
91 * from DialerA should be ignored as they are no longer current. Voicemails from {@link
92 * #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as they are voicemail source only valid pre-OC.
93 */
94 void appendOmtpVoicemailSelectionClause(
95 Context context, StringBuilder where, List<String> selectionArgs);
Eric Erfanianfc37b022017-03-21 10:11:17 -070096
97 /**
98 * Appends the selection to ignore voicemail status from non-active OMTP voicemail package. The
99 * {@link android.provider.VoicemailContract.Status#SOURCE_TYPE} is checked against a list of
100 * known OMTP types. Voicemails from {@link #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as
101 * they are voicemail source only valid pre-OC.
102 *
103 * @see #appendOmtpVoicemailSelectionClause(Context, StringBuilder, List)
104 */
105 void appendOmtpVoicemailStatusSelectionClause(
106 Context context, StringBuilder where, List<String> selectionArgs);
107
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700108 boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
109
Eric Erfaniand8046e52017-04-06 09:41:50 -0700110 /**
111 * @return if the voicemail archive feature is available on the current device. This depends on
112 * whether the server side flag is turned on for the feature, and if the OS meets the
113 * requirement for this feature.
114 */
115 boolean isVoicemailArchiveAvailable(Context context);
116
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700117 void setVoicemailArchiveEnabled(
118 Context context, PhoneAccountHandle phoneAccountHandle, boolean value);
Eric Erfaniand8046e52017-04-06 09:41:50 -0700119
120 /**
mdooleyec1a9702017-10-27 16:20:32 -0700121 * @return if the voicemail transcription feature is available on the current device. This depends
uabdullaha7530f82018-03-16 17:32:54 -0700122 * on whether the server side flag is turned on for the feature, visual voicemail is activated
123 * and enabled and if the OS meets the requirement for this feature.
mdooleyec1a9702017-10-27 16:20:32 -0700124 */
uabdullaha7530f82018-03-16 17:32:54 -0700125 boolean isVoicemailTranscriptionAvailable(Context context, PhoneAccountHandle account);
126
127 /** @return if the voicemail transcription setting has been enabled by the user. */
128 boolean isVoicemailTranscriptionEnabled(Context context, PhoneAccountHandle account);
mdooleyec1a9702017-10-27 16:20:32 -0700129
mdooley96f71f72017-11-01 15:26:50 -0700130 /** @return if the voicemail donation feature is available. */
uabdullaha7530f82018-03-16 17:32:54 -0700131 boolean isVoicemailDonationAvailable(Context context, PhoneAccountHandle account);
mdooley96f71f72017-11-01 15:26:50 -0700132
mdooleyec1a9702017-10-27 16:20:32 -0700133 /** @return if the voicemail donation setting has been enabled by the user. */
134 boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account);
135
uabdullaha7530f82018-03-16 17:32:54 -0700136 void setVoicemailTranscriptionEnabled(
137 Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
138
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -0800139 void setVoicemailDonationEnabled(
140 Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
Eric Erfanian8369df02017-05-03 10:27:13 -0700141
142 /**
143 * Whether the client is activated and handling visual voicemail for the {@code
144 * phoneAccountHandle}. "Enable" is the intention to use VVM. For example VVM can be enabled but
145 * prevented from working because the carrier blocked it, or a connection problem is blocking the
146 * provisioning. Being "activated" means all setup are completed, and VVM is expected to work.
147 */
148 boolean isActivated(Context context, PhoneAccountHandle phoneAccountHandle);
Eric Erfanianff2ad7f2017-07-27 10:45:54 -0700149
150 /**
151 * Called when {@link #VOICEMAIL_SECRET_CODE} is dialed. {@code context} will be a broadcast
152 * receiver context.
153 */
154 @MainThread
155 void showConfigUi(@NonNull Context context);
156
157 @NonNull
158 PersistableBundle getConfig(
159 @NonNull Context context, @Nullable PhoneAccountHandle phoneAccountHandle);
160
161 @MainThread
162 void onBoot(@NonNull Context context);
163
164 @MainThread
165 void onShutdown(@NonNull Context context);
Eric Erfanianfc0eb8c2017-08-31 06:57:16 -0700166
Zachary Heidepriem7547d3e2017-11-06 19:10:44 -0800167 @MainThread
168 void addActivationStateListener(ActivationStateListener listener);
169
170 @MainThread
171 void removeActivationStateListener(ActivationStateListener listener);
172
173 /** Provides interface to change the PIN used to access the mailbox by calling. */
174 PinChanger createPinChanger(Context context, PhoneAccountHandle phoneAccountHandle);
175
mdooley22ff3382017-11-16 21:25:00 -0800176 void onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle);
177
mdooley7e1a0d12017-11-17 11:02:48 -0800178 boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle);
179
mdooley22ff3382017-11-16 21:25:00 -0800180 /**
181 * @return arbitrary carrier configuration String value associate with the indicated key. See
182 * {@code CarrierConfigKeys.java}
183 */
184 @Nullable
185 String getCarrierConfigString(Context context, PhoneAccountHandle phoneAccountHandle, String key);
uabdullaha7530f82018-03-16 17:32:54 -0700186
187 /** Listener for changes in {@link #isActivated(Context, PhoneAccountHandle)} */
188 interface ActivationStateListener {
189 @MainThread
190 void onActivationStateChanged(PhoneAccountHandle phoneAccountHandle, boolean isActivated);
191 }
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700192}