blob: be9ab11fb3a27cb5c571610f8d17fc12852ad9b5 [file] [log] [blame]
Sean Pontd00aefb2020-01-07 12:05:09 -08001/*
2 * Copyright 2020 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 android.service.quickaccesswallet;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
Sean Pont72fc25f2020-02-11 19:02:44 -080021import android.annotation.TestApi;
Sean Pontd00aefb2020-01-07 12:05:09 -080022import android.content.Context;
23import android.content.Intent;
24
Sean Pontd00aefb2020-01-07 12:05:09 -080025/**
26 * Facilitates accessing cards from the {@link QuickAccessWalletService}.
27 *
28 * @hide
29 */
Sean Pont72fc25f2020-02-11 19:02:44 -080030@TestApi
Sean Pontd00aefb2020-01-07 12:05:09 -080031public interface QuickAccessWalletClient {
32
33 /**
34 * Create a client for accessing wallet cards from the {@link QuickAccessWalletService}. If the
35 * service is unavailable, {@link #isWalletServiceAvailable()} will return false.
36 */
37 @NonNull
38 static QuickAccessWalletClient create(@NonNull Context context) {
39 return new QuickAccessWalletClientImpl(context);
40 }
41
42 /**
Sean Pont72fc25f2020-02-11 19:02:44 -080043 * @return true if the {@link QuickAccessWalletService} is available. This means that the
44 * default NFC payment application has an exported service that can provide cards to the Quick
45 * Access Wallet. However, it does not mean that (1) the call will necessarily be successful,
46 * nor does it mean that cards may be displayed at this time. Addition checks are required:
47 * <ul>
48 * <li>If {@link #isWalletFeatureAvailable()} is false, cards should not be displayed
49 * <li>If the device is locked and {@link #isWalletFeatureAvailableWhenDeviceLocked} is
50 * false, cards should not be displayed while the device remains locked. (A message
51 * prompting the user to unlock to view cards may be appropriate).</li>
52 * </ul>
Sean Pontd00aefb2020-01-07 12:05:09 -080053 */
54 boolean isWalletServiceAvailable();
55
56 /**
Sean Pont72fc25f2020-02-11 19:02:44 -080057 * Wallet cards should not be displayed if:
58 * <ul>
59 * <li>The wallet service is unavailable</li>
60 * <li>The device is not provisioned, ie user setup is incomplete</li>
61 * <li>If the wallet feature has been disabled by the user</li>
62 * <li>If the phone has been put into lockdown mode</li>
63 * </ul>
64 * <p>
65 * Quick Access Wallet implementers should call this method before calling
66 * {@link #getWalletCards} to ensure that cards may be displayed.
67 */
68 boolean isWalletFeatureAvailable();
69
70 /**
71 * Wallet cards may not be displayed on the lock screen if the user has opted to hide
72 * notifications or sensitive content on the lock screen.
73 * <ul>
74 * <li>The device is not provisioned, ie user setup is incomplete</li>
75 * <li>If the wallet feature has been disabled by the user</li>
76 * <li>If the phone has been put into lockdown mode</li>
77 * </ul>
78 *
79 * <p>
80 * Quick Access Wallet implementers should call this method before calling
81 * {@link #getWalletCards} if the device is currently locked.
82 *
83 * @return true if cards may be displayed on the lock screen.
84 */
85 boolean isWalletFeatureAvailableWhenDeviceLocked();
86
87 /**
Sean Pontd00aefb2020-01-07 12:05:09 -080088 * Get wallet cards from the {@link QuickAccessWalletService}.
89 */
90 void getWalletCards(
91 @NonNull GetWalletCardsRequest request,
Sean Pont72fc25f2020-02-11 19:02:44 -080092 @NonNull OnWalletCardsRetrievedCallback callback);
93
94 /**
95 * Callback for getWalletCards
96 */
97 interface OnWalletCardsRetrievedCallback {
98 void onWalletCardsRetrieved(@NonNull GetWalletCardsResponse response);
99
100 void onWalletCardRetrievalError(@NonNull GetWalletCardsError error);
101 }
Sean Pontd00aefb2020-01-07 12:05:09 -0800102
103 /**
104 * Notify the {@link QuickAccessWalletService} service that a wallet card was selected.
105 */
106 void selectWalletCard(@NonNull SelectWalletCardRequest request);
107
108 /**
109 * Notify the {@link QuickAccessWalletService} service that the Wallet was dismissed.
110 */
111 void notifyWalletDismissed();
112
113 /**
114 * Unregister event listener.
115 */
Sean Pont72fc25f2020-02-11 19:02:44 -0800116 void addWalletServiceEventListener(@NonNull WalletServiceEventListener listener);
Sean Pontd00aefb2020-01-07 12:05:09 -0800117
118 /**
119 * Unregister event listener
120 */
Sean Pont72fc25f2020-02-11 19:02:44 -0800121 void removeWalletServiceEventListener(@NonNull WalletServiceEventListener listener);
122
123 /**
124 * A listener for {@link WalletServiceEvent walletServiceEvents}
125 */
126 interface WalletServiceEventListener {
127 void onWalletServiceEvent(@NonNull WalletServiceEvent event);
128 }
129
130 /**
131 * Unregister all event listeners and disconnect from the service.
132 */
133 void disconnect();
Sean Pontd00aefb2020-01-07 12:05:09 -0800134
135 /**
136 * The manifest entry for the QuickAccessWalletService may also publish information about the
137 * activity that hosts the Wallet view. This is typically the home screen of the Wallet
138 * application.
139 */
140 @Nullable
Sean Pont72fc25f2020-02-11 19:02:44 -0800141 Intent createWalletIntent();
Sean Pontd00aefb2020-01-07 12:05:09 -0800142
143 /**
144 * The manifest entry for the {@link QuickAccessWalletService} may publish the activity that
145 * hosts the settings
146 */
147 @Nullable
Sean Pont72fc25f2020-02-11 19:02:44 -0800148 Intent createWalletSettingsIntent();
Sean Pontd00aefb2020-01-07 12:05:09 -0800149}