Java Code Examples for android.view.accessibility.AccessibilityEvent#isFullScreen()

The following examples show how to use android.view.accessibility.AccessibilityEvent#isFullScreen() . 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: AccessibilityService.java    From FreezeYou with Apache License 2.0 4 votes vote down vote up
@SuppressLint("SwitchIntDef")
@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
    int type = accessibilityEvent.getEventType();
    switch (type) {
        case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
            if (accessibilityEvent.isFullScreen()) {
                CharSequence pkgName = accessibilityEvent.getPackageName();
                if (pkgName != null) {
                    boolean isScreenOn = true;
                    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
                    if (pm != null) {
                        isScreenOn = pm.isScreenOn();
                    }
                    String pkgNameString = pkgName.toString();
                    String previousPkg = MainApplication.getCurrentPackage();
                    if (isScreenOn &&
                            !"".equals(pkgNameString) &&
                            !"com.android.systemui".equals(pkgNameString) &&
                            !"com.android.packageinstaller".equals(pkgNameString) &&
                            !"android".equals(pkgNameString)) {
                        MainApplication.setCurrentPackage(pkgNameString);
                        if (!pkgNameString.equals(previousPkg)
                                && new AppPreferences(getApplicationContext()).getBoolean("freezeOnceQuit", false)
                                && OneKeyListUtils.existsInOneKeyList(getApplicationContext(), getString(R.string.sFreezeOnceQuit), previousPkg)) {
                            FUFUtils.processFreezeAction(getApplicationContext(), previousPkg, null, null, false, null, false);
                        }

                        onLeaveApplications(previousPkg, pkgNameString);//检测+执行
                    }

                    onApplicationsForeground(previousPkg, pkgNameString);//检测+执行

                    addUpUseTimes(pkgNameString);//使用次数计数(增加)

                }
            }
            break;
        default:
            break;
    }
}
 
Example 2
Source File: AccessibilityEventUtils.java    From brailleback with Apache License 2.0 4 votes vote down vote up
/**
 * @return If the <code>first</code> event is equal to the <code>second</code>.
 */
public static boolean eventEquals(AccessibilityEvent first, AccessibilityEvent second) {
    // TODO: The framework should implement AccessibilityEvent#equals()
    if (first == null || second == null) {
        return false;
    }
    if (first.getEventType() != second.getEventType()) {
        return false;
    }
    if (first.getPackageName() == null) {
        if (second.getPackageName() != null) {
            return false;
        }
    } else if (!first.getPackageName().equals(second.getPackageName())) {
        return false;
    }
    if (first.getClassName() == null) {
        if (second.getClassName() != null) {
            return false;
        }
    } else if (!first.getClassName().equals(second.getClassName())) {
        return false;
    }
    if (!first.getText().equals(second.getText())) {
        // The result of getText() is never null.
        return false;
    }
    if (first.getContentDescription() == null) {
        if (second.getContentDescription() != null) {
            return false;
        }
    } else if (!first.getContentDescription().equals(second.getContentDescription())) {
        return false;
    }
    if (first.getBeforeText() == null) {
        if (second.getBeforeText() != null) {
            return false;
        }
    } else if (!first.getBeforeText().equals(second.getBeforeText())) {
        return false;
    }
    if (first.getParcelableData() != null) {
        // Parcelable data may not implement equals() correctly.
        return false;
    }
    if (first.getAddedCount() != second.getAddedCount()) {
        return false;
    }
    if (first.isChecked() != second.isChecked()) {
        return false;
    }
    if (first.isEnabled() != second.isEnabled()) {
        return false;
    }
    if (first.getFromIndex() != second.getFromIndex()) {
        return false;
    }
    if (first.isFullScreen() != second.isFullScreen()) {
        return false;
    }
    if (first.getCurrentItemIndex() != second.getCurrentItemIndex()) {
        return false;
    }
    if (first.getItemCount() != second.getItemCount()) {
        return false;
    }
    if (first.isPassword() != second.isPassword()) {
        return false;
    }
    if (first.getRemovedCount() != second.getRemovedCount()) {
        return false;
    }
    if (first.getEventTime() != second.getEventTime()) {
        return false;
    }
    return true;
}