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; 20 import android.os.PersistableBundle; 21 import android.provider.VoicemailContract.Voicemails; 22 import android.support.annotation.MainThread; 23 import android.support.annotation.NonNull; 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 * 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 /** 39 * 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 */ 44 String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD"; 45 46 /** Common key for passing {@link PhoneAccountHandle} in bundles. */ 47 String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle"; 48 49 /** 50 * 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 /** 57 * 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 /** 63 * 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 /** 69 * 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 /** 75 * 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 /** 90 * 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); 100 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 112 boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle); 113 114 /** 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 121 void setVoicemailArchiveEnabled( 122 Context context, PhoneAccountHandle phoneAccountHandle, boolean value); 123 124 /** 125 * @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 131 /** @return if the voicemail donation feature is available. */ 132 boolean isVoicemailDonationAvailable(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 void setVoicemailDonationEnabled( 138 Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled); 139 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); 147 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); 164 165 /** 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 180 void onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle); 181 182 boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle); 183 184 /** 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); 190 } 191