1 /*
2  * Copyright (C) 2024 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 package com.android.nfc.emulator;
17 
18 import android.content.ComponentName;
19 import android.nfc.cardemulation.CardEmulation;
20 import android.os.Bundle;
21 
22 import com.android.nfc.service.PaymentServiceDynamicAids;
23 import com.android.nfc.utils.HceUtils;
24 
25 import java.util.ArrayList;
26 
27 public class DynamicAidEmulatorActivity extends BaseEmulatorActivity {
28 
29     @Override
onCreate(Bundle savedInstanceState)30     protected void onCreate(Bundle savedInstanceState) {
31         super.onCreate(savedInstanceState);
32     }
33 
34     @Override
onResume()35     protected void onResume() {
36         super.onResume();
37         setupServices(PaymentServiceDynamicAids.COMPONENT);
38     }
39 
40     @Override
onServicesSetup()41     protected void onServicesSetup() {
42         ArrayList<String> paymentAids = new ArrayList<String>();
43         paymentAids.add(HceUtils.PPSE_AID);
44         paymentAids.add(HceUtils.VISA_AID);
45         // Register a different set of AIDs for the foreground
46         mCardEmulation.registerAidsForService(
47                 PaymentServiceDynamicAids.COMPONENT,
48                 CardEmulation.CATEGORY_PAYMENT,
49                 paymentAids);
50         makeDefaultWalletRoleHolder();
51     }
52 
53     @Override
onApduSequenceComplete(ComponentName component, long duration)54     protected void onApduSequenceComplete(ComponentName component, long duration) {
55         if (component.equals(PaymentServiceDynamicAids.COMPONENT)) {
56             setTestPassed();
57         }
58     }
59 
60     @Override
getPreferredServiceComponent()61     public ComponentName getPreferredServiceComponent() {
62         return PaymentServiceDynamicAids.COMPONENT;
63     }
64 }
65