summaryrefslogtreecommitdiff
path: root/src/com/android/server/telecom/RoleManagerAdapter.java
blob: 8fdfb1189cb2943f3df10218dfeffca99735bfff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.server.telecom;

import android.content.Intent;
import android.os.UserHandle;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.IntConsumer;

/**
 * Provides a means of wrapping {@code RoleManager} operations which Telecom uses to aid in testing
 * and remove direct dependencies.
 */
public interface RoleManagerAdapter {

    /**
     * The name of the dialer role.
     *
     * @see Intent#ACTION_DIAL
     */
    String ROLE_DIALER = "android.app.role.DIALER";

    /**
     * Returns the package name of the app which fills the {@link android.app.role.RoleManager} call
     * redirection role.
     * @return the package name of the app filling the role, {@code null} otherwise}.
     */
    String getDefaultCallRedirectionApp(UserHandle userHandle);

    /**
     * Override the {@link android.app.role.RoleManager} call redirection app with another value.
     * Used for testing purposes only.
     * @param packageName Package name of the app to fill the call redirection role.  Where
     *                    {@code null}, the override is removed.
     */
    void setTestDefaultCallRedirectionApp(String packageName);

    /**
     * Returns the package name of the app which fills the {@link android.app.role.RoleManager} call
     * screening role.
     * @return the package name of the app filling the role, {@code null} otherwise}.
     */
    String getDefaultCallScreeningApp(UserHandle userHandle);

    /**
     * Override the {@link android.app.role.RoleManager} call screening app with another value.
     * Used for testing purposes only.
     * @param packageName Package name of the app to fill the call screening role.  Where
     *                    {@code null}, the override is removed.
     */
    void setTestDefaultCallScreeningApp(String packageName);

    /**
     * Returns the package name of the app which fills the {@link android.app.role.RoleManager}
     * {@link android.app.role.RoleManager#ROLE_DIALER} role.
     * @return the package name of the app filling the role, {@code null} otherwise}.
     */
    String getDefaultDialerApp(int user);

    /**
     * Observe changes to the package name of the app which fills the
     * {@link android.app.role.RoleManager} {@link android.app.role.RoleManager#ROLE_DIALER} role.
     */
    void observeDefaultDialerApp(Executor executor, IntConsumer observer);

    /**
     * Override the {@link android.app.role.RoleManager} default dialer app with another value.
     * Used for testing purposes only.
     * @param packageName Package name of the app to fill the default dialer role.  Where
     *                    {@code null}, the override is removed.
     */
    void setTestDefaultDialer(String packageName);

    /**
     * @return List of package names of companion apps, or empty list if there are none.
     */
    List<String> getCallCompanionApps();

    /**
     * Set a package to be added to the list of the companion apps. Used for testing purposes only.
     * @param packageName Package name of the app to be added or removed as an override call
     *                    companion app.
     * @param isAdded {@code true} if the specified package should be added, {@code false} if it
     *                            should be removed.
     */
    void addOrRemoveTestCallCompanionApp(String packageName, boolean isAdded);

    /**
     * Using role manager needs to know the current user handle.  Need to make sure the role manager
     * adapter can pass this to role manager.  As it changes, we'll pass it in.
     * @param currentUserHandle The new user handle.
     */
    void setCurrentUserHandle(UserHandle currentUserHandle);

    /**
     * Returns the application label that corresponds to the given package name.
     * @param packageName A valid package name.
     * @return Application label for the given package name, or null if not found.
     */
    String getApplicationLabelForPackageName(String packageName);
}