QaFormActivity.java

2.1 KB · raw

1package com.peachpasswords.qa;23import android.app.Activity;4import android.os.Bundle;5import android.text.InputType;6import android.view.View;7import android.widget.EditText;8import android.widget.LinearLayout;910/**11 * Minimal native login form for emulator autofill QA. Java on purpose: the12 * androidTest APK ships without the Kotlin runtime, so a standalone13 * `am start` launch of this activity must not need it. Lives in the test14 * package: a different package from the Peach autofill service, so the15 * framework will happily send fill requests for it.16 */17public class QaFormActivity extends Activity {18    @Override19    protected void onCreate(Bundle savedInstanceState) {20        super.onCreate(savedInstanceState);21        EditText username = new EditText(this);22        username.setId(android.R.id.edit);23        username.setHint("Username");24        username.setAutofillHints("username");25        username.setContentDescription("Username field");26        username.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);2728        EditText password = new EditText(this);29        password.setHint("Password");30        password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);31        password.setAutofillHints("password");32        password.setContentDescription("Password field");33        password.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);3435        // 2FA field for the OTP chip QA path (E2-fix). The hint goes via36        // the framework -- the parser also walks idEntry / hint / text as a37        // fallback when the hint is missing on real-world forms.38        EditText otp = new EditText(this);39        otp.setHint("2FA Code");40        otp.setInputType(InputType.TYPE_CLASS_NUMBER);41        otp.setAutofillHints("otp");42        otp.setContentDescription("2FA code field");43        otp.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);4445        LinearLayout layout = new LinearLayout(this);46        layout.setOrientation(LinearLayout.VERTICAL);47        layout.setPadding(48, 96, 48, 0);48        layout.addView(username);49        layout.addView(password);50        layout.addView(otp);51        setContentView(layout);52    }53}