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 19 import android.app.Instrumentation; 20 import android.content.Intent; 21 import android.nfc.NfcAdapter; 22 import android.util.Log; 23 24 import androidx.test.platform.app.InstrumentationRegistry; 25 import androidx.test.uiautomator.UiObject; 26 import androidx.test.uiautomator.UiObjectNotFoundException; 27 import androidx.test.uiautomator.UiScrollable; 28 import androidx.test.uiautomator.UiSelector; 29 30 import com.android.nfc.utils.NfcSnippet; 31 32 import com.google.android.mobly.snippet.rpc.AsyncRpc; 33 import com.google.android.mobly.snippet.rpc.Rpc; 34 35 public class NfcEmulatorDeviceSnippet extends NfcSnippet { 36 37 static String sRfOnAction = "com.android.nfc_extras.action.RF_FIELD_ON_DETECTED"; 38 private BaseEmulatorActivity mActivity; 39 40 private static final long TIMEOUT_MS = 10_000L; 41 42 /** Opens single Non Payment emulator */ 43 @Rpc(description = "Open single non payment emulator activity") startSingleNonPaymentEmulatorActivity()44 public void startSingleNonPaymentEmulatorActivity() { 45 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 46 47 Intent intent = new Intent(Intent.ACTION_MAIN); 48 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 49 intent.setClassName( 50 instrumentation.getTargetContext(), 51 SingleNonPaymentEmulatorActivity.class.getName()); 52 53 mActivity = (SingleNonPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 54 } 55 56 /** Opens single payment emulator activity */ 57 @Rpc(description = "Open single payment emulator activity") startSinglePaymentEmulatorActivity()58 public void startSinglePaymentEmulatorActivity() { 59 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 60 61 Intent intent = new Intent(Intent.ACTION_MAIN); 62 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 63 intent.setClassName( 64 instrumentation.getTargetContext(), SinglePaymentEmulatorActivity.class.getName()); 65 66 mActivity = (SinglePaymentEmulatorActivity) instrumentation.startActivitySync(intent); 67 } 68 69 /** Opens dual payment emulator activity */ 70 @Rpc(description = "Opens dual payment emulator activity") startDualPaymentEmulatorActivity()71 public void startDualPaymentEmulatorActivity() { 72 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 73 74 Intent intent = new Intent(Intent.ACTION_MAIN); 75 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 76 intent.setClassName( 77 instrumentation.getTargetContext(), DualPaymentEmulatorActivity.class.getName()); 78 79 mActivity = (DualPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 80 } 81 82 /** Opens foreground payment emulator activity */ 83 @Rpc(description = "Opens foreground payment emulator activity") startForegroundPaymentEmulatorActivity()84 public void startForegroundPaymentEmulatorActivity() { 85 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 86 87 Intent intent = new Intent(Intent.ACTION_MAIN); 88 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 89 intent.setClassName( 90 instrumentation.getTargetContext(), 91 ForegroundPaymentEmulatorActivity.class.getName()); 92 93 mActivity = (ForegroundPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 94 } 95 96 /** Opens dynamic AID emulator activity */ 97 @Rpc(description = "Opens dynamic AID emulator activity") startDynamicAidEmulatorActivity()98 public void startDynamicAidEmulatorActivity() { 99 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 100 101 Intent intent = new Intent(Intent.ACTION_MAIN); 102 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 103 intent.setClassName( 104 instrumentation.getTargetContext(), DynamicAidEmulatorActivity.class.getName()); 105 106 mActivity = (DynamicAidEmulatorActivity) instrumentation.startActivitySync(intent); 107 } 108 109 /** Opens prefix payment emulator activity */ 110 @Rpc(description = "Opens prefix payment emulator activity") startPrefixPaymentEmulatorActivity()111 public void startPrefixPaymentEmulatorActivity() { 112 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 113 114 Intent intent = new Intent(Intent.ACTION_MAIN); 115 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 116 intent.setClassName( 117 instrumentation.getTargetContext(), PrefixPaymentEmulatorActivity.class.getName()); 118 119 mActivity = (PrefixPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 120 } 121 122 /** Opens prefix payment emulator 2 activity */ 123 @Rpc(description = "Opens prefix payment emulator 2 activity") startPrefixPaymentEmulator2Activity()124 public void startPrefixPaymentEmulator2Activity() { 125 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 126 127 Intent intent = new Intent(Intent.ACTION_MAIN); 128 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 129 intent.setClassName( 130 instrumentation.getTargetContext(), PrefixPaymentEmulator2Activity.class.getName()); 131 132 mActivity = (PrefixPaymentEmulator2Activity) instrumentation.startActivitySync(intent); 133 } 134 135 /** Opens dual non payment activity */ 136 @Rpc(description = "Opens dual non-payment prefix emulator activity") startDualNonPaymentPrefixEmulatorActivity()137 public void startDualNonPaymentPrefixEmulatorActivity() { 138 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 139 140 Intent intent = new Intent(Intent.ACTION_MAIN); 141 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 142 intent.setClassName( 143 instrumentation.getTargetContext(), 144 DualNonPaymentPrefixEmulatorActivity.class.getName()); 145 146 mActivity = 147 (DualNonPaymentPrefixEmulatorActivity) instrumentation.startActivitySync(intent); 148 } 149 150 /** Opens off host emulator activity */ 151 @Rpc(description = "Open off host emulator activity") startOffHostEmulatorActivity(boolean enableObserveMode)152 public void startOffHostEmulatorActivity(boolean enableObserveMode) { 153 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 154 155 Intent intent = new Intent(Intent.ACTION_MAIN); 156 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 157 intent.setClassName( 158 instrumentation.getTargetContext(), OffHostEmulatorActivity.class.getName()); 159 intent.putExtra(OffHostEmulatorActivity.EXTRA_ENABLE_OBSERVE_MODE, enableObserveMode); 160 161 mActivity = (OffHostEmulatorActivity) instrumentation.startActivitySync(intent); 162 } 163 164 /** Opens screen on only off host emulator activity */ 165 @Rpc(description = "Open screen-on only off host emulator activity") startScreenOnOnlyOffHostEmulatorActivity()166 public void startScreenOnOnlyOffHostEmulatorActivity() { 167 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 168 169 Intent intent = new Intent(Intent.ACTION_MAIN); 170 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 171 intent.setClassName( 172 instrumentation.getTargetContext(), 173 ScreenOnOnlyOffHostEmulatorActivity.class.getName()); 174 175 mActivity = (ScreenOnOnlyOffHostEmulatorActivity) instrumentation.startActivitySync(intent); 176 } 177 178 /** Opens on and off host emulator activity */ 179 @Rpc(description = "Open on and off host emulator activity") startOnAndOffHostEmulatorActivity()180 public void startOnAndOffHostEmulatorActivity() { 181 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 182 183 Intent intent = new Intent(Intent.ACTION_MAIN); 184 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 185 intent.setClassName( 186 instrumentation.getTargetContext(), OnAndOffHostEmulatorActivity.class.getName()); 187 188 mActivity = (OnAndOffHostEmulatorActivity) instrumentation.startActivitySync(intent); 189 } 190 191 /** Opens dual non-payment emulator activity */ 192 @Rpc(description = "Opens dual non-payment emulator activity") startDualNonPaymentEmulatorActivity()193 public void startDualNonPaymentEmulatorActivity() { 194 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 195 196 Intent intent = new Intent(Intent.ACTION_MAIN); 197 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 198 intent.setClassName( 199 instrumentation.getTargetContext(), DualNonPaymentEmulatorActivity.class.getName()); 200 201 mActivity = (DualNonPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 202 } 203 204 /** Opens foreground non-payment emulator activity */ 205 @Rpc(description = "Opens foreground non-payment emulator activity") startForegroundNonPaymentEmulatorActivity()206 public void startForegroundNonPaymentEmulatorActivity() { 207 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 208 209 Intent intent = new Intent(Intent.ACTION_MAIN); 210 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 211 intent.setClassName( 212 instrumentation.getTargetContext(), 213 ForegroundNonPaymentEmulatorActivity.class.getName()); 214 215 mActivity = 216 (ForegroundNonPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 217 } 218 219 /** Opens throughput emulator activity */ 220 @Rpc(description = "Opens throughput emulator activity") startThroughputEmulatorActivity()221 public void startThroughputEmulatorActivity() { 222 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 223 224 Intent intent = new Intent(Intent.ACTION_MAIN); 225 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 226 intent.setClassName( 227 instrumentation.getTargetContext(), ThroughputEmulatorActivity.class.getName()); 228 229 mActivity = (ThroughputEmulatorActivity) instrumentation.startActivitySync(intent); 230 } 231 232 /** Opens tap test emulator activity */ 233 @Rpc(description = "Opens tap test emulator activity") startTapTestEmulatorActivity()234 public void startTapTestEmulatorActivity() { 235 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 236 237 Intent intent = new Intent(Intent.ACTION_MAIN); 238 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 239 intent.setClassName( 240 instrumentation.getTargetContext(), TapTestEmulatorActivity.class.getName()); 241 242 mActivity = (TapTestEmulatorActivity) instrumentation.startActivitySync(intent); 243 } 244 245 /** Opens large num AIDs emulator activity */ 246 @Rpc(description = "Opens large num AIDs emulator activity") startLargeNumAidsEmulatorActivity()247 public void startLargeNumAidsEmulatorActivity() { 248 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 249 250 Intent intent = new Intent(Intent.ACTION_MAIN); 251 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 252 intent.setClassName( 253 instrumentation.getTargetContext(), LargeNumAidsEmulatorActivity.class.getName()); 254 255 mActivity = (LargeNumAidsEmulatorActivity) instrumentation.startActivitySync(intent); 256 } 257 258 /** Opens screen off emulator activity */ 259 @Rpc(description = "Opens screen off emulator activity") startScreenOffPaymentEmulatorActivity()260 public void startScreenOffPaymentEmulatorActivity() { 261 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 262 263 Intent intent = new Intent(Intent.ACTION_MAIN); 264 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 265 intent.setClassName( 266 instrumentation.getTargetContext(), 267 ScreenOffPaymentEmulatorActivity.class.getName()); 268 269 mActivity = (ScreenOffPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 270 } 271 272 /** Opens conflicting non-payment emulator activity */ 273 @Rpc(description = "Opens conflicting non-payment emulator activity") startConflictingNonPaymentEmulatorActivity()274 public void startConflictingNonPaymentEmulatorActivity() { 275 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 276 277 Intent intent = new Intent(Intent.ACTION_MAIN); 278 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 279 intent.setClassName( 280 instrumentation.getTargetContext(), 281 ConflictingNonPaymentEmulatorActivity.class.getName()); 282 mActivity = 283 (ConflictingNonPaymentEmulatorActivity) instrumentation.startActivitySync(intent); 284 } 285 286 /** Opens conflicting non-payment prefix emulator activity */ 287 @Rpc(description = "Opens conflicting non-payment prefix emulator activity") startConflictingNonPaymentPrefixEmulatorActivity()288 public void startConflictingNonPaymentPrefixEmulatorActivity() { 289 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 290 291 Intent intent = new Intent(Intent.ACTION_MAIN); 292 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 293 intent.setClassName( 294 instrumentation.getTargetContext(), 295 ConflictingNonPaymentPrefixEmulatorActivity.class.getName()); 296 mActivity = 297 (ConflictingNonPaymentPrefixEmulatorActivity) 298 instrumentation.startActivitySync(intent); 299 } 300 301 /** Opens protocol params emulator activity */ 302 @Rpc(description = "Opens protocol params emulator activity") startProtocolParamsEmulatorActivity()303 public void startProtocolParamsEmulatorActivity() { 304 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 305 306 Intent intent = new Intent(Intent.ACTION_MAIN); 307 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 308 intent.setClassName( 309 instrumentation.getTargetContext(), ProtocolParamsEmulatorActivity.class.getName()); 310 311 mActivity = (ProtocolParamsEmulatorActivity) instrumentation.startActivitySync(intent); 312 } 313 314 315 @Rpc(description = "Returns if observe mode is supported.") isObserveModeSupported()316 public boolean isObserveModeSupported() { 317 NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext); 318 if (adapter == null) { 319 return false; 320 } 321 return adapter.isObserveModeSupported(); 322 } 323 324 @Rpc(description = "Returns if observe mode is enabled.") isObserveModeEnabled()325 public boolean isObserveModeEnabled() { 326 return mActivity.isObserveModeEnabled(); 327 } 328 329 @Rpc(description = "Set observe mode.") setObserveModeEnabled(boolean enable)330 public boolean setObserveModeEnabled(boolean enable) { 331 if (mActivity != null && isObserveModeSupported()) { 332 return mActivity.setObserveModeEnabled(enable); 333 } 334 return false; 335 } 336 337 /** Open polling loop emulator activity for Type A */ 338 @Rpc(description = "Open polling loop emulator activity for polling loop A test") startPollingLoopAEmulatorActivity()339 public void startPollingLoopAEmulatorActivity() { 340 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 341 Intent intent = 342 buildPollingLoopEmulatorIntent(instrumentation, NfcAdapter.FLAG_READER_NFC_A); 343 mActivity = (PollingLoopEmulatorActivity) instrumentation.startActivitySync(intent); 344 } 345 346 /** Open polling loop emulator activity for Type B */ 347 @Rpc(description = "Open polling loop emulator activity for polling loop B test") startPollingLoopBEmulatorActivity()348 public void startPollingLoopBEmulatorActivity() { 349 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 350 Intent intent = 351 buildPollingLoopEmulatorIntent(instrumentation, NfcAdapter.FLAG_READER_NFC_B); 352 mActivity = (PollingLoopEmulatorActivity) instrumentation.startActivitySync(intent); 353 } 354 355 /** Open polling loop emulator activity for Type A and B */ 356 @Rpc(description = "Open polling loop emulator activity for polling loop A/B test") startPollingLoopABEmulatorActivity()357 public void startPollingLoopABEmulatorActivity() { 358 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 359 Intent intent = 360 buildPollingLoopEmulatorIntent( 361 instrumentation, 362 NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B); 363 mActivity = (PollingLoopEmulatorActivity) instrumentation.startActivitySync(intent); 364 } 365 366 /** Open polling loop emulator activity for Type A and B */ 367 @Rpc(description = "Open polling loop emulator activity for custom polling frame test") startCustomPollingFrameEmulatorActivity(String customFrame)368 public void startCustomPollingFrameEmulatorActivity(String customFrame) { 369 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 370 Intent intent = 371 buildPollingLoopEmulatorIntent( 372 instrumentation, 373 NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B); 374 intent.putExtra(PollingLoopEmulatorActivity.NFC_CUSTOM_FRAME_KEY, customFrame); 375 mActivity = (PollingLoopEmulatorActivity) instrumentation.startActivitySync(intent); 376 } 377 378 @Rpc(description = "Open two polling frame emulator activity for two readers test\"") startTwoPollingFrameEmulatorActivity()379 public void startTwoPollingFrameEmulatorActivity() { 380 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 381 382 Intent intent = new Intent(Intent.ACTION_MAIN); 383 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 384 intent.setClassName( 385 instrumentation.getTargetContext(), 386 TwoPollingFrameEmulatorActivity.class.getName()); 387 388 mActivity = (TwoPollingFrameEmulatorActivity) instrumentation.startActivitySync(intent); 389 } 390 391 /** Registers receiver that waits for RF field broadcast */ 392 @AsyncRpc(description = "Waits for RF field detected broadcast") asyncWaitForRfOnBroadcast(String callbackId, String eventName)393 public void asyncWaitForRfOnBroadcast(String callbackId, String eventName) { 394 registerSnippetBroadcastReceiver(callbackId, eventName, sRfOnAction); 395 } 396 397 /** Registers receiver for polling loop action */ 398 @AsyncRpc(description = "Waits for seen correct polling loop") asyncWaitsForSeenCorrectPollingLoop(String callbackId, String eventName)399 public void asyncWaitsForSeenCorrectPollingLoop(String callbackId, String eventName) { 400 registerSnippetBroadcastReceiver( 401 callbackId, 402 eventName, 403 PollingLoopEmulatorActivity.SEEN_CORRECT_POLLING_LOOP_ACTION); 404 } 405 406 /** Registers receiver for Test Pass event */ 407 @AsyncRpc(description = "Waits for Test Pass event") asyncWaitForTestPass(String callbackId, String eventName)408 public void asyncWaitForTestPass(String callbackId, String eventName) { 409 registerSnippetBroadcastReceiver( 410 callbackId, eventName, BaseEmulatorActivity.ACTION_TEST_PASSED); 411 } 412 413 /** Registers receiver for Role Held event */ 414 @AsyncRpc(description = "Waits for Role Held event") asyncWaitForRoleHeld(String callbackId, String eventName)415 public void asyncWaitForRoleHeld(String callbackId, String eventName) { 416 registerSnippetBroadcastReceiver( 417 callbackId, eventName, BaseEmulatorActivity.ACTION_ROLE_HELD); 418 } 419 420 /** Registers receiver for Screen Off event */ 421 @AsyncRpc(description = "Waits for Screen Off event") asyncWaitForScreenOff(String callbackId, String eventName)422 public void asyncWaitForScreenOff(String callbackId, String eventName) { 423 registerSnippetBroadcastReceiver(callbackId, eventName, Intent.ACTION_SCREEN_OFF); 424 } 425 426 /** Registers receiver for Screen On event */ 427 @AsyncRpc(description = "Waits for Screen On event") asyncWaitForScreenOn(String callbackId, String eventName)428 public void asyncWaitForScreenOn(String callbackId, String eventName) { 429 registerSnippetBroadcastReceiver(callbackId, eventName, Intent.ACTION_SCREEN_ON); 430 } 431 432 /** Sets the listen tech for the active emulator activity */ 433 @Rpc(description = "Set the listen tech for the emulator") setListenTech(Integer listenTech)434 public void setListenTech(Integer listenTech) { 435 if (mActivity == null) { 436 Log.e(TAG, "Activity is null."); 437 return; 438 } 439 mActivity.setListenTech(listenTech); 440 } 441 442 /** Resets the listen tech for the active emulator activity */ 443 @Rpc(description = "Reset the listen tech for the emulator") resetListenTech()444 public void resetListenTech() { 445 if (mActivity == null) { 446 Log.e(TAG, "Activity is null."); 447 return; 448 } 449 mActivity.resetListenTech(); 450 } 451 452 /** Automatically selects TransportService2 from list of services. */ 453 @Rpc(description = "Automatically selects TransportService2 from list of services.") selectItem()454 public void selectItem() { 455 Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); 456 457 String text = instrumentation.getTargetContext().getString(R.string.transportService2); 458 Log.d(TAG, text); 459 try { 460 UiScrollable listView = new UiScrollable(new UiSelector()); 461 listView.scrollTextIntoView(text); 462 listView.waitForExists(TIMEOUT_MS); 463 UiObject listViewItem = 464 listView.getChildByText( 465 new UiSelector().className(android.widget.TextView.class.getName()), 466 "" + text + ""); 467 if (listViewItem.exists()) { 468 listViewItem.click(); 469 Log.d(TAG, text + " ListView item was clicked."); 470 } else { 471 Log.e(TAG, "UI Object does not exist."); 472 } 473 } catch (UiObjectNotFoundException e) { 474 Log.e(TAG, "Ui Object not found."); 475 } 476 } 477 478 /** Closes emulator activity */ 479 @Rpc(description = "Close activity if one was opened.") closeActivity()480 public void closeActivity() { 481 if (mActivity != null) { 482 mActivity.finish(); 483 } 484 } 485 486 /** Wait for preferred service to be set */ 487 @Rpc(description = "Waits for preferred service to be set") waitForService()488 public void waitForService() { 489 if (mActivity != null) { 490 mActivity.waitForService(); 491 } 492 } 493 494 /** Builds intent to launch polling loop emulators */ buildPollingLoopEmulatorIntent(Instrumentation instrumentation, int nfcTech)495 private Intent buildPollingLoopEmulatorIntent(Instrumentation instrumentation, int nfcTech) { 496 Intent intent = new Intent(Intent.ACTION_MAIN); 497 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 498 intent.setClassName( 499 instrumentation.getTargetContext(), PollingLoopEmulatorActivity.class.getName()); 500 intent.putExtra(PollingLoopEmulatorActivity.NFC_TECH_KEY, nfcTech); 501 return intent; 502 } 503 } 504