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.os.Bundle; 20 21 import com.android.nfc.service.PaymentService1; 22 import com.android.nfc.service.PaymentService2; 23 24 public class ForegroundPaymentEmulatorActivity extends BaseEmulatorActivity { 25 26 @Override onCreate(Bundle savedInstanceState)27 protected void onCreate(Bundle savedInstanceState) { 28 super.onCreate(savedInstanceState); 29 } 30 31 @Override onResume()32 protected void onResume() { 33 super.onResume(); 34 setupServices(PaymentService2.COMPONENT, PaymentService1.COMPONENT); 35 } 36 37 @Override onServicesSetup()38 protected void onServicesSetup() { 39 makeDefaultWalletRoleHolder(); 40 mCardEmulation.setPreferredService( 41 this, PaymentService2.COMPONENT); 42 } 43 44 @Override onPause()45 protected void onPause() { 46 super.onPause(); 47 mCardEmulation.unsetPreferredService(this); 48 } 49 50 @Override onApduSequenceComplete(ComponentName component, long duration)51 public void onApduSequenceComplete(ComponentName component, long duration) { 52 if (component.equals(PaymentService2.COMPONENT)) { 53 setTestPassed(); 54 } 55 } 56 57 /* Gets preferred service description */ 58 @Override getPreferredServiceComponent()59 public ComponentName getPreferredServiceComponent() { 60 return PaymentService2.COMPONENT; 61 } 62 } 63