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.TransportService2; 23 import com.android.nfc.utils.HceUtils; 24 import com.android.nfc.service.LargeNumAidsService; 25 26 import java.util.ArrayList; 27 28 public class LargeNumAidsEmulatorActivity extends BaseEmulatorActivity { 29 @Override onCreate(Bundle savedInstanceState)30 protected void onCreate(Bundle savedInstanceState) { 31 super.onCreate(savedInstanceState); 32 } 33 34 @Override onApduSequenceComplete(ComponentName component, long duration)35 public void onApduSequenceComplete(ComponentName component, long duration) { 36 if (component.equals(LargeNumAidsService.COMPONENT)) { 37 setTestPassed(); 38 } 39 } 40 41 @Override onResume()42 protected void onResume() { 43 super.onResume(); 44 setupServices(LargeNumAidsService.COMPONENT); 45 } 46 47 @Override onServicesSetup()48 protected void onServicesSetup() { 49 ArrayList<String> aids = new ArrayList<String>(); 50 for (int i = 0; i < 256; i++) { 51 aids.add( 52 HceUtils.LARGE_NUM_AIDS_PREFIX 53 + String.format("%02X", i) 54 + HceUtils.LARGE_NUM_AIDS_POSTFIX); 55 } 56 mCardEmulation.registerAidsForService( 57 LargeNumAidsService.COMPONENT, 58 CardEmulation.CATEGORY_OTHER, 59 aids); 60 } 61 62 @Override onPause()63 protected void onPause() { 64 super.onPause(); 65 mCardEmulation.unsetPreferredService(this); 66 } 67 68 @Override getPreferredServiceComponent()69 public ComponentName getPreferredServiceComponent(){ 70 return LargeNumAidsService.COMPONENT; 71 } 72 } 73