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