blob: 97b824b274facf8f52e6e0c604bc3baa7f7255d6 [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 Erfaniand8046e52017-04-06 09:41:50 -070020import android.content.Intent;
Eric Erfaniand5e47f62017-03-15 14:41:07 -070021import android.provider.VoicemailContract.Voicemails;
22import android.support.annotation.Nullable;
23import android.telecom.PhoneAccountHandle;
24import android.telephony.TelephonyManager;
25import java.util.List;
26
27/** Public interface for the voicemail module */
28public interface VoicemailClient {
29
30 /**
Eric Erfanian90508232017-03-24 09:31:16 -070031 * Whether the voicemail module is enabled (OS has support and not disabled by flags, etc.). This
32 * does not mean the carrier has support or user has enabled the feature.
33 */
34 boolean isVoicemailModuleEnabled();
35
36 /**
Eric Erfaniand5e47f62017-03-15 14:41:07 -070037 * Broadcast to tell the client to upload local database changes to the server. Since the dialer
38 * UI and the client are in the same package, the {@link
39 * android.content.Intent#ACTION_PROVIDER_CHANGED} will always be a self-change even if the UI is
40 * external to the client.
41 */
Eric Erfanian8369df02017-05-03 10:27:13 -070042 String ACTION_UPLOAD = "com.android.voicemail.VoicemailClient.ACTION_UPLOAD";
Eric Erfaniand5e47f62017-03-15 14:41:07 -070043
Eric Erfaniand8046e52017-04-06 09:41:50 -070044 /** Common key for passing {@link PhoneAccountHandle} in bundles. */
45 String PARAM_PHONE_ACCOUNT_HANDLE = "phone_account_handle";
46
Eric Erfaniand5e47f62017-03-15 14:41:07 -070047 /**
Eric Erfanian8369df02017-05-03 10:27:13 -070048 * Broadcast from the client to inform the app to show a legacy voicemail notification. This
49 * broadcast is same as {@link TelephonyManager#ACTION_SHOW_VOICEMAIL_NOTIFICATION}.
50 */
51 String ACTION_SHOW_LEGACY_VOICEMAIL =
52 "com.android.voicemail.VoicemailClient.ACTION_SHOW_LEGACY_VOICEMAIL";
53
54 /**
55 * Whether the visual voicemail service is enabled for the {@code phoneAccountHandle}. "Enable"
56 * means the user "wants" to have this service on, and does not mean the service is actually
57 * functional(For example, the service is blocked on the carrier side. The service will be
58 * "enabled" but all it will do is show the error).
59 */
60 boolean isVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
61
62 /**
63 * Enable or disable visual voicemail service for the {@code phoneAccountHandle}. Setting to
64 * enabled will initiate provisioning and activation. Setting to disabled will initiate
65 * deactivation.
66 */
67 void setVoicemailEnabled(Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled);
68
69 /**
Eric Erfaniand5e47f62017-03-15 14:41:07 -070070 * Appends the selection to ignore voicemails from non-active OMTP voicemail package. In OC there
71 * can be multiple packages handling OMTP voicemails which represents the same source of truth.
72 * These packages should mark their voicemails as {@link Voicemails#IS_OMTP_VOICEMAIL} and only
73 * the voicemails from {@link TelephonyManager#getVisualVoicemailPackageName()} should be shown.
74 * For example, the user synced voicemails with DialerA, and then switched to DialerB, voicemails
75 * from DialerA should be ignored as they are no longer current. Voicemails from {@link
76 * #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as they are voicemail source only valid pre-OC.
77 */
78 void appendOmtpVoicemailSelectionClause(
79 Context context, StringBuilder where, List<String> selectionArgs);
Eric Erfanianfc37b022017-03-21 10:11:17 -070080
81 /**
82 * Appends the selection to ignore voicemail status from non-active OMTP voicemail package. The
83 * {@link android.provider.VoicemailContract.Status#SOURCE_TYPE} is checked against a list of
84 * known OMTP types. Voicemails from {@link #OMTP_VOICEMAIL_BLACKLIST} will also be ignored as
85 * they are voicemail source only valid pre-OC.
86 *
87 * @see #appendOmtpVoicemailSelectionClause(Context, StringBuilder, List)
88 */
89 void appendOmtpVoicemailStatusSelectionClause(
90 Context context, StringBuilder where, List<String> selectionArgs);
91
Eric Erfaniand5e47f62017-03-15 14:41:07 -070092 /**
93 * @return the class name of the {@link android.preference.PreferenceFragment} for voicemail
94 * settings, or {@code null} if dialer cannot control voicemail settings. Always return {@code
95 * null} before OC.
96 */
97 @Nullable
98 String getSettingsFragment();
99
100 boolean isVoicemailArchiveEnabled(Context context, PhoneAccountHandle phoneAccountHandle);
101
Eric Erfaniand8046e52017-04-06 09:41:50 -0700102 /**
103 * @return if the voicemail archive feature is available on the current device. This depends on
104 * whether the server side flag is turned on for the feature, and if the OS meets the
105 * requirement for this feature.
106 */
107 boolean isVoicemailArchiveAvailable(Context context);
108
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700109 void setVoicemailArchiveEnabled(
110 Context context, PhoneAccountHandle phoneAccountHandle, boolean value);
Eric Erfaniand8046e52017-04-06 09:41:50 -0700111
112 /**
113 * @return an intent that will launch the activity to change the voicemail PIN. The PIN is used
114 * when calling into the mailbox.
115 */
116 Intent getSetPinIntent(Context context, PhoneAccountHandle phoneAccountHandle);
Eric Erfanian8369df02017-05-03 10:27:13 -0700117
118 /**
119 * Whether the client is activated and handling visual voicemail for the {@code
120 * phoneAccountHandle}. "Enable" is the intention to use VVM. For example VVM can be enabled but
121 * prevented from working because the carrier blocked it, or a connection problem is blocking the
122 * provisioning. Being "activated" means all setup are completed, and VVM is expected to work.
123 */
124 boolean isActivated(Context context, PhoneAccountHandle phoneAccountHandle);
Eric Erfaniand5e47f62017-03-15 14:41:07 -0700125}