Java Code Examples for android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS

The following examples show how to use android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS . 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: UiAutomationConnection.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void registerUiTestAutomationServiceLocked(IAccessibilityServiceClient client,
        int flags) {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
            ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    final AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
            | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS
            | AccessibilityServiceInfo.FLAG_FORCE_DIRECT_BOOT_AWARE;
    info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
            | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
            | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
            | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.registerUiTestAutomationService(mToken, client, info, flags);
        mClient = client;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
    }
}
 
Example 3
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 4
Source File: AccessibilityService.java    From Status with Apache License 2.0 6 votes vote down vote up
@Override
protected void onServiceConnected() {
    super.onServiceConnected();

    packageManager = getPackageManager();

    volumeReceiver = new VolumeReceiver(this);
    registerReceiver(volumeReceiver, new IntentFilter("android.media.VOLUME_CHANGED_ACTION"));

    notifications = new ArrayList<>();
    AccessibilityServiceInfo config = new AccessibilityServiceInfo();
    config.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
    config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;

    setServiceInfo(config);
}
 
Example 5
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 6
Source File: UiAutomatorBridge.java    From za-Farmer with MIT License 5 votes vote down vote up
public void setCompressedLayoutHierarchy(boolean compressed) {
    AccessibilityServiceInfo info = mUiAutomation.getServiceInfo();
    if (compressed)
        info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
    else
        info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
    mUiAutomation.setServiceInfo(info);
}
 
Example 7
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
private void setMonitorEventTypes(int eventTypes, boolean includeNotImporantViews, boolean requestEnhancedWebAccessibility) {
    if (eventTypes != mLastMonitoredEventTypes || includeNotImporantViews != mLastIncludeNotImporantViews || requestEnhancedWebAccessibility != mLastRequestEnhancedWebAccessibility) {

        Ln.d("SERVICE: mLastMonitoredEventTypes=%s, eventTypes=%s", mLastMonitoredEventTypes, eventTypes);

        mLastMonitoredEventTypes = eventTypes;
        mLastIncludeNotImporantViews = includeNotImporantViews;
        mLastRequestEnhancedWebAccessibility = requestEnhancedWebAccessibility;
        AccessibilityServiceInfo params = getServiceInfo();
        if (params == null) {
            Ln.w("DAMNIT, somethimes this shit happens: serviceparams returned are null!");
        } else {
            params.eventTypes = mLastMonitoredEventTypes;
            if (includeNotImporantViews) {
                params.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
            } else {
                params.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
            }

            if (mLastRequestEnhancedWebAccessibility) {
                params.flags |= AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
            } else {
                params.flags &= ~AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
            }

            setServiceInfo(params);
        }
    }
}
 
Example 8
Source File: TimeCatMonitorService.java    From timecat with Apache License 2.0 5 votes vote down vote up
private void setCapabilities(boolean isPengYouQuan) {
    int flag = 0;
    flag = mAccessibilityServiceInfo.flags;
    if (isPengYouQuan) {
        mAccessibilityServiceInfo.flags = flag | (AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS);
    } else {
        mAccessibilityServiceInfo.flags = flag & (~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS);
    }
    this.setServiceInfo(mAccessibilityServiceInfo);
}
 
Example 9
Source File: SaiyAccessibilityService.java    From Saiy-PS with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
     * Set the content this service should be receiving
     */
    private void setDynamicContent() {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "setDynamicContent: interceptGoogle: " + initInterceptGoogle);
            MyLog.i(CLS_NAME, "setDynamicContent: announceNotifications: " + initAnnounceNotifications);
        }

        if (!initInterceptGoogle && !initAnnounceNotifications) {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "setDynamicContent: none required: finishing");
            }

//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//                this.disableSelf();
//            }
//
//            this.stopSelf();

        } else {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "setDynamicContent: updating content");
            }

            final AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo();

            serviceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
            serviceInfo.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
            serviceInfo.notificationTimeout = UPDATE_TIMEOUT;

            if (initInterceptGoogle && initAnnounceNotifications) {
                serviceInfo.eventTypes = AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
                        | AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
                        | AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
            } else if (initInterceptGoogle) {
                serviceInfo.packageNames = new String[]{Installed.PACKAGE_NAME_GOOGLE_NOW};
                serviceInfo.eventTypes = AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
                        | AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED;
            } else {
                serviceInfo.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
            }

            this.setServiceInfo(serviceInfo);
        }
    }