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.PrefixPaymentService1; 22 import com.android.nfc.service.PrefixPaymentService2; 23 24 public class PrefixPaymentEmulatorActivity extends BaseEmulatorActivity { 25 private static final int STATE_IDLE = 0; 26 private static final int STATE_SERVICE1_SETTING_UP = 1; 27 private static final int STATE_SERVICE2_SETTING_UP = 2; 28 29 private int mState = STATE_IDLE; 30 31 @Override onCreate(Bundle savedInstanceState)32 protected void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 } 35 36 @Override onResume()37 protected void onResume() { 38 super.onResume(); 39 mState = STATE_SERVICE1_SETTING_UP; 40 setupServices(PrefixPaymentService1.COMPONENT); 41 } 42 43 @Override onServicesSetup()44 protected void onServicesSetup() { 45 if (mState == STATE_SERVICE1_SETTING_UP) { 46 mState = STATE_SERVICE2_SETTING_UP; 47 setupServices( 48 PrefixPaymentService1.COMPONENT, PrefixPaymentService2.COMPONENT); 49 return; 50 } 51 makeDefaultWalletRoleHolder(); 52 } 53 54 @Override onApduSequenceComplete(ComponentName component, long duration)55 protected void onApduSequenceComplete(ComponentName component, long duration) { 56 if (component.equals(PrefixPaymentService1.COMPONENT)) { 57 setTestPassed(); 58 } 59 } 60 61 @Override getPreferredServiceComponent()62 public ComponentName getPreferredServiceComponent() { 63 return PrefixPaymentService1.COMPONENT; 64 } 65 } 66