Java Code Examples for android.accessibilityservice.AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS

The following examples show how to use android.accessibilityservice.AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessibilityServiceImpl.java    From SoloPi with Apache License 2.0 6 votes vote down vote up
private void setServiceInfoToTouchBlockMode() {
    AccessibilityServiceInfo info = getServiceInfo();
    if (info == null) {
        LogUtil.e(TAG, "ServiceInfo为空");
        return;
    }
    info.flags = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS |
            AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY |
            AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
            AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS |
            AccessibilityServiceInfo.DEFAULT |
            AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;

    LogUtil.d(TAG, "辅助功能进入触摸监控模式");
    setServiceInfo(info);
}
 
Example 2
Source File: UiAutomatorBridge.java    From JsDroidCmd with Mozilla Public License 2.0 6 votes vote down vote up
public void setFastMode(boolean compressed) {
	this.fastMode = compressed;
	AccessibilityServiceInfo info = mUiAutomation.getServiceInfo();
	if (compressed) {
		// 只加载重要的,高速模式
		info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
		if (UiDevice.API_LEVEL_ACTUAL >= Build.VERSION_CODES.LOLLIPOP) {
			info.flags |= AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
		}
	} else {
		// 加载不重要的,慢速模式
		info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
		if (UiDevice.API_LEVEL_ACTUAL >= Build.VERSION_CODES.LOLLIPOP) {
			info.flags &= ~AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
		}

	}
	mUiAutomation.setServiceInfo(info);
}
 
Example 3
Source File: AccessibilityServiceImpl.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
private void setServiceToNormalMode() {
    AccessibilityServiceInfo info = getServiceInfo();
    if (info == null) {
        LogUtil.e(TAG, "ServiceInfo为空");
        return;
    }
    info.flags = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS |
            AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
            AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY |
            AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS |
            AccessibilityServiceInfo.DEFAULT;

    LogUtil.d(TAG, "辅助功能进入正常模式");
    setServiceInfo(info);
}
 
Example 4
Source File: UiDevice.java    From za-Farmer with MIT License 5 votes vote down vote up
/** Private constructor. Clients should use {@link UiDevice#getInstance(Instrumentation)}. */
private UiDevice(Instrumentation instrumentation) {
    mInstrumentation = instrumentation;
    UiAutomation uiAutomation = instrumentation.getUiAutomation();
    mUiAutomationBridge = new InstrumentationUiAutomatorBridge(
            instrumentation.getContext(), uiAutomation);

    // Enable multi-window support for API level 21 and up
    if (UiDevice.API_LEVEL_ACTUAL >= Build.VERSION_CODES.LOLLIPOP) {
        // Subscribe to window information
        AccessibilityServiceInfo info = uiAutomation.getServiceInfo();
        info.flags |= AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
        uiAutomation.setServiceInfo(info);
    }
}
 
Example 5
Source File: TimeCatMonitorService.java    From timecat with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    back = getVirtualNavigationKey(this, "accessibility_back", "com.android.systemui", "");
    home = getVirtualNavigationKey(this, "accessibility_home", "com.android.systemui", "");
    recent = getVirtualNavigationKey(this, "accessibility_recent", "com.android.systemui", "");
    readSettingFromSp();

    ArcTipViewController.getInstance().addActionListener(actionListener);

    mRunningTaskUtil = new RunningTaskUtil(this);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constants.BROADCAST_TIMECAT_MONITOR_SERVICE_MODIFIED);
    intentFilter.addAction(Constants.REFRESH_WHITE_LIST_BROADCAST);
    intentFilter.addAction(Constants.FLOAT_REFRESH_WHITE_LIST_BROADCAST);
    intentFilter.addAction(Constants.UNIVERSAL_COPY_BROADCAST);
    intentFilter.addAction(Constants.UNIVERSAL_COPY_BROADCAST_DELAY);
    intentFilter.addAction(Constants.SCREEN_CAPTURE_OVER_BROADCAST);
    intentFilter.addAction(Constants.EFFECT_AFTER_REBOOT_BROADCAST);
    intentFilter.addAction(Constants.MONITOR_CLICK_BROADCAST);
    registerReceiver(timeCatBroadcastReceiver, intentFilter);


    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    registerReceiver(mScreenReceiver, filter);

    handler = new Handler();
    handler.post(new Runnable() {
        @Override
        public void run() {
            try {
                startService(new Intent(TimeCatMonitorService.this, ListenClipboardService.class));
                if (showFloatView) {
                    String packageName;
                    if (!TextUtils.isEmpty(mCurrentPackage)) {
                        packageName = mCurrentPackage;
                    } else {
                        ComponentName task = mRunningTaskUtil.getTopActivtyFromLolipopOnwards();
                        packageName = task.getPackageName();
                    }
                    if (floatWhiteList != null && floatWhiteList.contains(packageName)) {
                        ArcTipViewController.getInstance().remove();
                    } else {
                        if (ArcTipViewController.getInstance().isRemoved()) {
                            ArcTipViewController.getInstance().showHideFloatImageView();
                        } else {
                            ArcTipViewController.getInstance().show();
                        }
                    }
                }
                keepAccessibilityOpen();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            handler.postDelayed(this, 3000);
        }
    });
    mAccessibilityServiceInfo = new AccessibilityServiceInfo();
    mAccessibilityServiceInfo.feedbackType = FEEDBACK_GENERIC;
    mAccessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED | AccessibilityEvent.TYPE_VIEW_LONG_CLICKED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
    int flag = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        flag = flag | AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        flag = flag | AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS;
    }
    mAccessibilityServiceInfo.flags = flag;
    mAccessibilityServiceInfo.notificationTimeout = 100;
    setServiceInfo(mAccessibilityServiceInfo);

    readWhiteList();
    readFloatWhiteList();

    keepAccessibilityOpen();

}