Example usage for android.accessibilityservice AccessibilityServiceInfo FLAG_REQUEST_TOUCH_EXPLORATION_MODE

List of usage examples for android.accessibilityservice AccessibilityServiceInfo FLAG_REQUEST_TOUCH_EXPLORATION_MODE

Introduction

In this page you can find the example usage for android.accessibilityservice AccessibilityServiceInfo FLAG_REQUEST_TOUCH_EXPLORATION_MODE.

Prototype

int FLAG_REQUEST_TOUCH_EXPLORATION_MODE

To view the source code for android.accessibilityservice AccessibilityServiceInfo FLAG_REQUEST_TOUCH_EXPLORATION_MODE.

Click Source Link

Document

This flag requests that the system gets into touch exploration mode.

Usage

From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java

/**
 * Registers listeners, sets service info, loads preferences. This should be
 * called from {@link #onServiceConnected} and when ScreenSpeak resumes from a
 * suspended state./*from w  w w  .j a v  a  2 s  . co  m*/
 */
private void resumeInfrastructure() {
    if (isServiceActive()) {
        if (LogUtils.LOG_LEVEL <= Log.ERROR) {
            Log.e(LOGTAG, "Attempted to resume while not suspended");
        }
        return;
    }

    setServiceState(SERVICE_STATE_ACTIVE);
    stopForeground(true);

    final AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType |= AccessibilityServiceInfo.FEEDBACK_SPOKEN;
    info.feedbackType |= AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
    info.feedbackType |= AccessibilityServiceInfo.FEEDBACK_HAPTIC;
    info.flags |= AccessibilityServiceInfo.DEFAULT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY;
        info.flags |= AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
        info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        info.flags |= AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
    }
    info.notificationTimeout = 0;

    // Ensure the initial touch exploration request mode is correct.
    if (mSupportsTouchScreen && SharedPreferencesUtils.getBooleanPref(mPrefs, getResources(),
            R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default)) {
        info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
    }

    setServiceInfo(info);

    if (mRingerModeAndScreenMonitor != null) {
        registerReceiver(mRingerModeAndScreenMonitor, mRingerModeAndScreenMonitor.getFilter());
        // It could now be confused with the current screen state
        mRingerModeAndScreenMonitor.updateScreenState();
    }

    if (mVolumeMonitor != null) {
        registerReceiver(mVolumeMonitor, mVolumeMonitor.getFilter());
    }

    if (mBatteryMonitor != null) {
        registerReceiver(mBatteryMonitor, mBatteryMonitor.getFilter());
    }

    if (mPackageReceiver != null) {
        registerReceiver(mPackageReceiver, mPackageReceiver.getFilter());
        if (mLabelManager != null) {
            mLabelManager.ensureDataConsistency();
        }
    }

    if (mSideTapManager != null) {
        registerReceiver(mSideTapManager, SideTapManager.getFilter());
    }

    mPrefs.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener);

    // Add the broadcast listener for gestures.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_PERFORM_GESTURE_ACTION);
    registerReceiver(mActiveReceiver, filter, PERMISSION_SCREENSPEAK, null);

    // Enable the proxy activity for long-press search.
    final PackageManager packageManager = getPackageManager();
    final ComponentName shortcutProxy = new ComponentName(this, ShortcutProxyActivity.class);
    packageManager.setComponentEnabledSetting(shortcutProxy, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
            PackageManager.DONT_KILL_APP);

    reloadPreferences();

    if (mDimScreenController.isDimmingEnabled()) {
        mDimScreenController.makeScreenDim();
    }
}

From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java

/**
 * Attempts to change the state of touch exploration.
 * <p>//from  w w w .  ja  v a 2  s  .c  o m
 * Should only be called if {@link #mSupportsTouchScreen} is true.
 *
 * @param requestedState {@code true} to request exploration.
 */
private void requestTouchExploration(boolean requestedState) {
    final AccessibilityServiceInfo info = getServiceInfo();
    if (info == null) {
        if (LogUtils.LOG_LEVEL <= Log.ERROR) {
            Log.e(LOGTAG, "Failed to change touch exploration request state, service info was null");
        }
        return;
    }

    final boolean currentState = ((info.flags
            & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0);
    if (currentState == requestedState) {
        return;
    }

    if (requestedState) {
        info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
    } else {
        info.flags &= ~AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
    }

    setServiceInfo(info);
}

From source file:com.google.android.marvin.mytalkback.TalkBackService.java

/**
 * Attempts to change the state of touch exploration.
 * <p>//  w w w . ja v a 2  s.c  o m
 * Should only be called if {@link #SUPPORTS_TOUCH_PREF} is true.
 *
 * @param requestedState {@code true} to request exploration.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void requestTouchExploration(boolean requestedState) {
    final AccessibilityServiceInfo info = getServiceInfo();
    if (info == null) {
        LogUtils.log(this, Log.ERROR,
                "Failed to change touch exploration request state, service info was null");
        return;
    }

    final boolean currentState = ((info.flags
            & AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE) != 0);
    if (currentState == requestedState) {
        return;
    }

    if (requestedState) {
        info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
    } else {
        info.flags &= ~AccessibilityServiceInfo.FLAG_REQUEST_TOUCH_EXPLORATION_MODE;
    }

    setServiceInfo(info);
}