package ru.kusoft.qsafe; import android.app.*; import android.content.*; import android.graphics.Bitmap; import android.view.*; import android.widget.*; import junit.framework.TestCase; import org.json.*; import java.lang.reflect.Field; public class ScreenSecurityTests extends TestCase { private final Instrumentation instrument=androidx.test.platform.app.InstrumentationRegistry.getInstrumentation(); private MainActivity activity; private void main(Runnable work){instrument.runOnMainSync(work);instrument.waitForIdleSync();} private AlertDialog dialog()throws Exception{Field f=MainActivity.class.getDeclaredField("dialog");f.setAccessible(true);return (AlertDialog)f.get(activity);} private void secure(Window w){assertTrue((w.getAttributes().flags&WindowManager.LayoutParams.FLAG_SECURE)!=0);} private View text(View v,String target){if(v instanceof TextView&&((TextView)v).getText().toString().equals(target))return v;if(v instanceof ViewGroup){ViewGroup g=(ViewGroup)v;for(int i=0;i{((EditText)activity.findViewById(R.id.master_password)).setText("synthetic screenshot password!");activity.findViewById(R.id.open_vault).performClick();}); long end=System.currentTimeMillis()+20000;while(System.currentTimeMillis()((View)card.getParent().getParent()).performClick());secure(activity.getWindow()); View remove=text(activity.getWindow().getDecorView(),"Удалить карточку");assertNotNull(remove);main(remove::performClick);secure(dialog().getWindow());main(activity::finish); Intent autofill=new Intent(c,AutofillActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("domain","example.test").putExtra("targetPackage","example.browser");activity=(MainActivity)instrument.startActivitySync(autofill);secure(activity.getWindow());open(); View choice=text(activity.getWindow().getDecorView(),"Security synthetic\nsecurity@example.test");assertNotNull(choice);main(choice::performClick);secure(dialog().getWindow()); main(()->activity.moveTaskToBack(true));long end=System.currentTimeMillis()+10000; while(dialog()!=null&&System.currentTimeMillis()