• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    * 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    */
38   String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD";
39   /** Common key for passing {@link PhoneAccountHandle} in bundles. */
40   String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle";
41   /**
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";
47   /**
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";
52   /**
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   /**
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    */
isVoicemailModuleEnabled()62   boolean isVoicemailModuleEnabled();
63 
64   /**
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    */
hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle)68   boolean hasCarrierSupport(Context context, PhoneAccountHandle phoneAccountHandle);
69 
70   /**
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    */
isVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle)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    */
setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled)83   void setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
84 
85   /**
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    */
appendOmtpVoicemailSelectionClause( Context context, StringBuilder where, List<String> selectionArgs)94   void appendOmtpVoicemailSelectionClause(
95       Context context, StringBuilder where, List<String> selectionArgs);
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    */
appendOmtpVoicemailStatusSelectionClause( Context context, StringBuilder where, List<String> selectionArgs)105   void appendOmtpVoicemailStatusSelectionClause(
106       Context context, StringBuilder where, List<String> selectionArgs);
107 
isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle)108   boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
109 
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    */
isVoicemailArchiveAvailable(Context context)115   boolean isVoicemailArchiveAvailable(Context context);
116 
setVoicemailArchiveEnabled( Context context, PhoneAccountHandle phoneAccountHandle, boolean value)117   void setVoicemailArchiveEnabled(
118       Context context, PhoneAccountHandle phoneAccountHandle, boolean value);
119 
120   /**
121    * @return if the voicemail transcription feature is available on the current device. This depends
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.
124    */
isVoicemailTranscriptionAvailable(Context context, PhoneAccountHandle account)125   boolean isVoicemailTranscriptionAvailable(Context context, PhoneAccountHandle account);
126 
127   /** @return if the voicemail transcription setting has been enabled by the user. */
isVoicemailTranscriptionEnabled(Context context, PhoneAccountHandle account)128   boolean isVoicemailTranscriptionEnabled(Context context, PhoneAccountHandle account);
129 
130   /** @return if the voicemail donation feature is available. */
isVoicemailDonationAvailable(Context context, PhoneAccountHandle account)131   boolean isVoicemailDonationAvailable(Context context, PhoneAccountHandle account);
132 
133   /** @return if the voicemail donation setting has been enabled by the user. */
isVoicemailDonationEnabled(Context context, PhoneAccountHandle account)134   boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account);
135 
setVoicemailTranscriptionEnabled( Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled)136   void setVoicemailTranscriptionEnabled(
137       Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
138 
setVoicemailDonationEnabled( Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled)139   void setVoicemailDonationEnabled(
140       Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
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    */
isActivated(Context context, PhoneAccountHandle phoneAccountHandle)148   boolean isActivated(Context context, PhoneAccountHandle phoneAccountHandle);
149 
150   /**
151    * Called when {@link #VOICEMAIL_SECRET_CODE} is dialed. {@code context} will be a broadcast
152    * receiver context.
153    */
154   @MainThread
showConfigUi(@onNull Context context)155   void showConfigUi(@NonNull Context context);
156 
157   @NonNull
getConfig( @onNull Context context, @Nullable PhoneAccountHandle phoneAccountHandle)158   PersistableBundle getConfig(
159       @NonNull Context context, @Nullable PhoneAccountHandle phoneAccountHandle);
160 
161   @MainThread
onBoot(@onNull Context context)162   void onBoot(@NonNull Context context);
163 
164   @MainThread
onShutdown(@onNull Context context)165   void onShutdown(@NonNull Context context);
166 
167   @MainThread
addActivationStateListener(ActivationStateListener listener)168   void addActivationStateListener(ActivationStateListener listener);
169 
170   @MainThread
removeActivationStateListener(ActivationStateListener listener)171   void removeActivationStateListener(ActivationStateListener listener);
172 
173   /** Provides interface to change the PIN used to access the mailbox by calling. */
createPinChanger(Context context, PhoneAccountHandle phoneAccountHandle)174   PinChanger createPinChanger(Context context, PhoneAccountHandle phoneAccountHandle);
175 
onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle)176   void onTosAccepted(Context context, PhoneAccountHandle phoneAccountHandle);
177 
hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle)178   boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle);
179 
180   /**
181    * @return arbitrary carrier configuration String value associate with the indicated key. See
182    *     {@code CarrierConfigKeys.java}
183    */
184   @Nullable
getCarrierConfigString(Context context, PhoneAccountHandle phoneAccountHandle, String key)185   String getCarrierConfigString(Context context, PhoneAccountHandle phoneAccountHandle, String key);
186 
187   /** Listener for changes in {@link #isActivated(Context, PhoneAccountHandle)} */
188   interface ActivationStateListener {
189     @MainThread
onActivationStateChanged(PhoneAccountHandle phoneAccountHandle, boolean isActivated)190     void onActivationStateChanged(PhoneAccountHandle phoneAccountHandle, boolean isActivated);
191   }
192 }
193