QaFormActivity.java

2.0 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.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);2627        EditText password = new EditText(this);28        password.setHint("Password");29        password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);30        password.setAutofillHints("password");31        password.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);3233        // 2FA field for the OTP chip QA path (E2-fix). The hint goes via34        // the framework -- the parser also walks idEntry / hint / text as a35        // fallback when the hint is missing on real-world forms.36        EditText otp = new EditText(this);37        otp.setHint("2FA Code");38        otp.setInputType(InputType.TYPE_CLASS_NUMBER);39        otp.setAutofillHints("otp");40        otp.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);4142        LinearLayout layout = new LinearLayout(this);43        layout.setOrientation(LinearLayout.VERTICAL);44        layout.setPadding(48, 96, 48, 0);45        layout.addView(username);46        layout.addView(password);47        layout.addView(otp);48        setContentView(layout);49    }50}