本文整理了Java中android.app.Instrumentation.getUiAutomation()
方法的一些代码示例,展示了Instrumentation.getUiAutomation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.getUiAutomation()
方法的具体详情如下:
包路径:android.app.Instrumentation
类名称:Instrumentation
方法名:getUiAutomation
暂无
代码示例来源:origin: android-hacker/VirtualXposed
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public UiAutomation getUiAutomation() {
return base.getUiAutomation();
}
代码示例来源:origin: stackoverflow.com
@Override
public void setUp() throws Exception{
super.setUp();
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
AccessibilityNodeInfo root = instrumentation.getUiAutomation().getRootInActiveWindow();
}
代码示例来源:origin: darkskygit/VirtualApp
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public UiAutomation getUiAutomation() {
return base.getUiAutomation();
}
代码示例来源:origin: bzsome/VirtualApp-x326
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public UiAutomation getUiAutomation() {
return base.getUiAutomation();
}
代码示例来源:origin: Neamar/KISS
@Before
public void setUp() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getInstrumentation().getUiAutomation().executeShellCommand(
"pm grant " + mActivityRule.getActivity().getPackageName()
+ " android.permission.READ_CONTACTS");
}
mActivityRule.getActivity();
// Initialize to default preferences
KissApplication.getApplication(mActivityRule.getActivity()).getDataHandler().clearHistory();
PreferenceManager.getDefaultSharedPreferences(mActivityRule.getActivity()).edit().clear().apply();
PreferenceManager.setDefaultValues(mActivityRule.getActivity(), R.xml.preferences, true);
// Remove lock screen
Runnable wakeUpDevice = new Runnable() {
public void run() {
mActivityRule.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
};
mActivityRule.getActivity().runOnUiThread(wakeUpDevice);
}
}
代码示例来源:origin: jksiezni/permissive
private void grantAllPermissions() {
Context context = InstrumentationRegistry.getTargetContext();
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
for (int i = 0; i < packageInfo.requestedPermissions.length; ++i) {
if ((packageInfo.requestedPermissionsFlags[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
grantReal(uiAutomation, packageInfo.requestedPermissions[i]);
}
}
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "packageInfo not found for: " + context.getPackageName());
}
}
代码示例来源:origin: com.facebook.testing.screenshot/core
private void grantPermission(Context context, String permission) {
if (Build.VERSION.SDK_INT < 23) {
return;
}
UiAutomation automation = Registry.getRegistry().instrumentation.getUiAutomation();
String command =
String.format(Locale.ENGLISH, "pm grant %s %s", context.getPackageName(), permission);
ParcelFileDescriptor pfd = automation.executeShellCommand(command);
InputStream stream = new FileInputStream(pfd.getFileDescriptor());
try {
byte[] buffer = new byte[1024];
while (stream.read(buffer) != -1) {
// Consume stdout to ensure the command completes
}
} catch (IOException ignored) {
} finally {
try {
stream.close();
} catch (IOException ignored) {
}
}
}
代码示例来源:origin: nenick/espresso-macchiato
/**
* Safe way to remove granted permission to you app without app restart.
*/
public static void resetAllPermission() {
// permissions handling only available since android marshmallow
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand("pm reset-permissions");
EspWait.forDelay(DELAY_FOR_COMMAND_EXECUTION);
}
代码示例来源:origin: sebaslogen/CleanGUITestArchitecture
private static void grantWritePermissionsForScreenshots() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
try {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
String appPackage = getTargetContext().getPackageName();
instrumentation.getUiAutomation().executeShellCommand("pm grant " + appPackage
+ " android.permission.READ_EXTERNAL_STORAGE");
instrumentation.getUiAutomation().executeShellCommand("pm grant " + appPackage
+ " android.permission.WRITE_EXTERNAL_STORAGE");
} catch (Exception e) {
throw new RuntimeException(
"Exception while granting external storage access to application apk", e);
}
}
}
代码示例来源:origin: Eaway/AppCrawler
public static boolean record(String msg) {
List<AccessibilityWindowInfo> list = InstrumentationRegistry.getInstrumentation().getUiAutomation().getWindows();
for (AccessibilityWindowInfo win : list) {
Log.i(TAG_MAIN, win.getClass().getName());
代码示例来源:origin: xiaocong/android-uiautomator-server
public AutomatorServiceImpl() {
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
this.uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
Device.getInstance().init(device, uiAutomation);
}
/**
内容来源于网络,如有侵权,请联系作者删除!