Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.voicemail; |
| 18 | |
| 19 | import android.content.Context; |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 20 | import android.os.PersistableBundle; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 21 | import android.provider.VoicemailContract.Voicemails; |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 22 | import android.support.annotation.MainThread; |
| 23 | import android.support.annotation.NonNull; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 24 | import android.support.annotation.Nullable; |
| 25 | import android.telecom.PhoneAccountHandle; |
| 26 | import android.telephony.TelephonyManager; |
| 27 | import java.util.List; |
| 28 | |
| 29 | /** Public interface for the voicemail module */ |
| 30 | public 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 Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 38 | String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD"; |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 39 | /** Common key for passing {@link PhoneAccountHandle} in bundles. */ |
| 40 | String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle"; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 41 | /** |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 42 | * 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 Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 47 | /** |
Eric Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 48 | * 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 Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 52 | /** |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 53 | * 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 | /** |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 59 | * 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 Heidepriem | 7547d3e | 2017-11-06 19:10:44 -0800 | [diff] [blame] | 65 | * 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 Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 71 | * 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 Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 86 | * 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 Erfanian | fc37b02 | 2017-03-21 10:11:17 -0700 | [diff] [blame] | 96 | |
| 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 Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 108 | boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle); |
| 109 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 110 | /** |
| 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 Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 117 | void setVoicemailArchiveEnabled( |
| 118 | Context context, PhoneAccountHandle phoneAccountHandle, boolean value); |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 119 | |
| 120 | /** |
mdooley | ec1a970 | 2017-10-27 16:20:32 -0700 | [diff] [blame] | 121 | * @return if the voicemail transcription feature is available on the current device. This depends |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 122 | * 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. |
mdooley | ec1a970 | 2017-10-27 16:20:32 -0700 | [diff] [blame] | 124 | */ |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 125 | 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); |
mdooley | ec1a970 | 2017-10-27 16:20:32 -0700 | [diff] [blame] | 129 | |
mdooley | 96f71f7 | 2017-11-01 15:26:50 -0700 | [diff] [blame] | 130 | /** @return if the voicemail donation feature is available. */ |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 131 | boolean isVoicemailDonationAvailable(Context context, PhoneAccountHandle account); |
mdooley | 96f71f7 | 2017-11-01 15:26:50 -0700 | [diff] [blame] | 132 | |
mdooley | ec1a970 | 2017-10-27 16:20:32 -0700 | [diff] [blame] | 133 | /** @return if the voicemail donation setting has been enabled by the user. */ |
| 134 | boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account); |
| 135 | |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 136 | void setVoicemailTranscriptionEnabled( |
| 137 | Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled); |
| 138 | |
Zachary Heidepriem | 7547d3e | 2017-11-06 19:10:44 -0800 | [diff] [blame] | 139 | void setVoicemailDonationEnabled( |
| 140 | Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled); |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 141 | |
| 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 Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 149 | |
| 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 Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 166 | |
Zachary Heidepriem | 7547d3e | 2017-11-06 19:10:44 -0800 | [diff] [blame] | 167 | @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 | |
mdooley | 22ff338 | 2017-11-16 21:25:00 -0800 | [diff] [blame] | 176 | void onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle); |
| 177 | |
mdooley | 7e1a0d1 | 2017-11-17 11:02:48 -0800 | [diff] [blame] | 178 | boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle); |
| 179 | |
mdooley | 22ff338 | 2017-11-16 21:25:00 -0800 | [diff] [blame] | 180 | /** |
| 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); |
uabdullah | a7530f8 | 2018-03-16 17:32:54 -0700 | [diff] [blame] | 186 | |
| 187 | /** Listener for changes in {@link #isActivated(Context, PhoneAccountHandle)} */ |
| 188 | interface ActivationStateListener { |
| 189 | @MainThread |
| 190 | void onActivationStateChanged(PhoneAccountHandle phoneAccountHandle, boolean isActivated); |
| 191 | } |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 192 | } |