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 | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 20 | import android.content.Intent; |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 21 | import android.os.PersistableBundle; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 22 | import android.provider.VoicemailContract.Voicemails; |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 23 | import android.support.annotation.MainThread; |
| 24 | import android.support.annotation.NonNull; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 25 | import android.support.annotation.Nullable; |
| 26 | import android.telecom.PhoneAccountHandle; |
| 27 | import android.telephony.TelephonyManager; |
| 28 | import java.util.List; |
| 29 | |
| 30 | /** Public interface for the voicemail module */ |
| 31 | public interface VoicemailClient { |
| 32 | |
| 33 | /** |
Eric Erfanian | 9050823 | 2017-03-24 09:31:16 -0700 | [diff] [blame] | 34 | * Whether the voicemail module is enabled (OS has support and not disabled by flags, etc.). This |
| 35 | * does not mean the carrier has support or user has enabled the feature. |
| 36 | */ |
| 37 | boolean isVoicemailModuleEnabled(); |
| 38 | |
| 39 | /** |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 40 | * Broadcast to tell the client to upload local database changes to the server. Since the dialer |
| 41 | * UI and the client are in the same package, the {@link |
| 42 | * android.content.Intent#ACTION_PROVIDER_CHANGED} will always be a self-change even if the UI is |
| 43 | * external to the client. |
| 44 | */ |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 45 | String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD"; |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 46 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 47 | /** Common key for passing {@link PhoneAccountHandle} in bundles. */ |
| 48 | String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle"; |
| 49 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 50 | /** |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 51 | * Broadcast from the client to inform the app to show a legacy voicemail notification. This |
| 52 | * broadcast is same as {@link TelephonyManager#ACTION_SHOW_VOICEMAIL_NOTIFICATION}. |
| 53 | */ |
| 54 | String ACTION_SHOW_LEGACY_VOICEMAIL = |
| 55 | "com.android.voicemail.VoicemailClient.ACTION_SHOW_LEGACY_VOICEMAIL"; |
| 56 | |
| 57 | /** |
Eric Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 58 | * Boolean extra send with {@link #ACTION_SHOW_LEGACY_VOICEMAIL}, indicating that the notification |
| 59 | * is sent by legacy mode and should not be suppressed even when VVM is activated |
| 60 | */ |
| 61 | String EXTRA_IS_LEGACY_MODE = "is_legacy_mode"; |
| 62 | |
| 63 | /** |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 64 | * Secret code to launch the voicemail config activity intended for OEMs and Carriers. {@code |
| 65 | * *#*#VVMCONFIG#*#*} |
| 66 | */ |
| 67 | String VOICEMAIL_SECRET_CODE = "886266344"; |
| 68 | |
| 69 | /** |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 70 | * Whether the visual voicemail service is enabled for the {@code phoneAccountHandle}. "Enable" |
| 71 | * means the user "wants" to have this service on, and does not mean the service is actually |
| 72 | * functional(For example, the service is blocked on the carrier side. The service will be |
| 73 | * "enabled" but all it will do is show the error). |
| 74 | */ |
| 75 | boolean isVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle); |
| 76 | |
| 77 | /** |
| 78 | * Enable or disable visual voicemail service for the {@code phoneAccountHandle}. Setting to |
| 79 | * enabled will initiate provisioning and activation. Setting to disabled will initiate |
| 80 | * deactivation. |
| 81 | */ |
| 82 | void setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled); |
| 83 | |
| 84 | /** |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 85 | * Appends the selection to ignore voicemails from non-active OMTP voicemail package. In OC there |
| 86 | * can be multiple packages handling OMTP voicemails which represents the same source of truth. |
| 87 | * These packages should mark their voicemails as {@link Voicemails#IS_OMTP_VOICEMAIL} and only |
| 88 | * the voicemails from {@link TelephonyManager#getVisualVoicemailPackageName()} should be shown. |
| 89 | * For example, the user synced voicemails with DialerA, and then switched to DialerB, voicemails |
| 90 | * from DialerA should be ignored as they are no longer current. Voicemails from {@link |
| 91 | * #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as they are voicemail source only valid pre-OC. |
| 92 | */ |
| 93 | void appendOmtpVoicemailSelectionClause( |
| 94 | Context context, StringBuilder where, List<String> selectionArgs); |
Eric Erfanian | fc37b02 | 2017-03-21 10:11:17 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Appends the selection to ignore voicemail status from non-active OMTP voicemail package. The |
| 98 | * {@link android.provider.VoicemailContract.Status#SOURCE_TYPE} is checked against a list of |
| 99 | * known OMTP types. Voicemails from {@link #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as |
| 100 | * they are voicemail source only valid pre-OC. |
| 101 | * |
| 102 | * @see #appendOmtpVoicemailSelectionClause(Context, StringBuilder, List) |
| 103 | */ |
| 104 | void appendOmtpVoicemailStatusSelectionClause( |
| 105 | Context context, StringBuilder where, List<String> selectionArgs); |
| 106 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 107 | /** |
| 108 | * @return the class name of the {@link android.preference.PreferenceFragment} for voicemail |
| 109 | * settings, or {@code null} if dialer cannot control voicemail settings. Always return {@code |
| 110 | * null} before OC. |
| 111 | */ |
| 112 | @Nullable |
| 113 | String getSettingsFragment(); |
| 114 | |
| 115 | boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle); |
| 116 | |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 117 | /** |
| 118 | * @return if the voicemail archive feature is available on the current device. This depends on |
| 119 | * whether the server side flag is turned on for the feature, and if the OS meets the |
| 120 | * requirement for this feature. |
| 121 | */ |
| 122 | boolean isVoicemailArchiveAvailable(Context context); |
| 123 | |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 124 | void setVoicemailArchiveEnabled( |
| 125 | Context context, PhoneAccountHandle phoneAccountHandle, boolean value); |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 126 | |
| 127 | /** |
mdooley | ec1a970 | 2017-10-27 16:20:32 -0700 | [diff] [blame^] | 128 | * @return if the voicemail transcription feature is available on the current device. This depends |
| 129 | * on whether the server side flag is turned on for the feature, and if the OS meets the |
| 130 | * requirement for this feature. |
| 131 | */ |
| 132 | boolean isVoicemailTranscriptionAvailable(Context context); |
| 133 | |
| 134 | /** @return if the voicemail donation setting has been enabled by the user. */ |
| 135 | boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account); |
| 136 | |
| 137 | /** |
Eric Erfanian | d8046e5 | 2017-04-06 09:41:50 -0700 | [diff] [blame] | 138 | * @return an intent that will launch the activity to change the voicemail PIN. The PIN is used |
| 139 | * when calling into the mailbox. |
| 140 | */ |
| 141 | Intent getSetPinIntent(Context context, PhoneAccountHandle phoneAccountHandle); |
Eric Erfanian | 8369df0 | 2017-05-03 10:27:13 -0700 | [diff] [blame] | 142 | |
| 143 | /** |
| 144 | * Whether the client is activated and handling visual voicemail for the {@code |
| 145 | * phoneAccountHandle}. "Enable" is the intention to use VVM. For example VVM can be enabled but |
| 146 | * prevented from working because the carrier blocked it, or a connection problem is blocking the |
| 147 | * provisioning. Being "activated" means all setup are completed, and VVM is expected to work. |
| 148 | */ |
| 149 | boolean isActivated(Context context, PhoneAccountHandle phoneAccountHandle); |
Eric Erfanian | ff2ad7f | 2017-07-27 10:45:54 -0700 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * Called when {@link #VOICEMAIL_SECRET_CODE} is dialed. {@code context} will be a broadcast |
| 153 | * receiver context. |
| 154 | */ |
| 155 | @MainThread |
| 156 | void showConfigUi(@NonNull Context context); |
| 157 | |
| 158 | @NonNull |
| 159 | PersistableBundle getConfig( |
| 160 | @NonNull Context context, @Nullable PhoneAccountHandle phoneAccountHandle); |
| 161 | |
| 162 | @MainThread |
| 163 | void onBoot(@NonNull Context context); |
| 164 | |
| 165 | @MainThread |
| 166 | void onShutdown(@NonNull Context context); |
Eric Erfanian | fc0eb8c | 2017-08-31 06:57:16 -0700 | [diff] [blame] | 167 | |
| 168 | void onTosAccepted(Context context); |
Eric Erfanian | d5e47f6 | 2017-03-15 14:41:07 -0700 | [diff] [blame] | 169 | } |