List of usage examples for android.accessibilityservice AccessibilityServiceInfo AccessibilityServiceInfo
public AccessibilityServiceInfo()
From source file:net.grayswander.rotationmanager.RotationManagerService.java
@Override protected void onServiceConnected() { super.onServiceConnected(); //Configure these here for compatibility with API 13 and below. AccessibilityServiceInfo config = new AccessibilityServiceInfo(); config.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; if (Build.VERSION.SDK_INT >= 16) //Just in case this helps config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS; setServiceInfo(config);//from w w w . j a v a 2 s. com this.context = getApplicationContext(); PreferenceManager.setDefaultValues(context, R.xml.preferences, false); configuration = new Configuration(this.context); this.resources = context.getResources(); }
From source file:com.mattprecious.notisync.service.NotificationService.java
@Override protected void onServiceConnected() { MyLog.d(TAG, "Service connected"); AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; info.flags = AccessibilityServiceInfo.DEFAULT; info.notificationTimeout = 100;/* w w w .ja v a 2 s . com*/ setServiceInfo(info); }
From source file:com.myStress.handlers.NotificationHandlerService.java
/** * Called when the service is started (usually after boot). We register the events we are interested in (change of notification) and also register to the start broadcast event, sent by myStress * Originally, we set the package filters to something that does not exist, so that we minimise the firing of the callback * After the start broadcast event will be received, the proper package names will be set for recording * @see android.accessibilityservice.AccessibilityService#onServiceConnected() *///from w ww . j av a 2s .c om @Override protected void onServiceConnected() { // register for any input from the accessbility service IntentFilter intentFilter = new IntentFilter("com.myStress.accessibility.start"); registerReceiver(SystemReceiver, intentFilter); // now switch off initially AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK; info.notificationTimeout = 100; Log.e("myStress", "NotificationHandlerService connected"); setServiceInfo(info); Translate.setClientId("myStress"); Translate.setClientSecret("ZwRLv7hsttnjqql26s7MglS8enqHG5Wi+uLfzt7Jsgw="); }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
@Override protected void onServiceConnected() { // get inital preferences watchFile = new File(getFilesDir() + "PrefsChanged.none"); if (!watchFile.exists()) { try {/*from www .ja v a 2 s . c o m*/ watchFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } watchFile.setLastModified(System.currentTimeMillis()); } loadPrefs(); AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL; info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; setServiceInfo(info); mHandler = new Handler(); queue = new LinkedList<queueItem>(); }
From source file:com.google.android.marvin.mytalkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state.//from ww w . ja v a 2 s .c o m */ private void resumeInfrastructure() { if (isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to resume while not suspended"); return; } setServiceState(ServiceState.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; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REPORT_VIEW_IDS; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_FILTER_KEY_EVENTS; info.notificationTimeout = 0; // Ensure the initial touch exploration request mode is correct. if (SUPPORTS_TOUCH_PREF && SharedPreferencesUtils.getBooleanPref(mPrefs, getResources(), R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default)) { info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_TOUCH_EXPLORATION_MODE; } setServiceInfo(info); if (mCallStateMonitor != null) { registerReceiver(mCallStateMonitor, mCallStateMonitor.getFilter()); } if (mRingerModeAndScreenMonitor != null) { registerReceiver(mRingerModeAndScreenMonitor, mRingerModeAndScreenMonitor.getFilter()); } if (mTextToSpeechManager != null) { mTextToSpeechManager.startDiscovery(); } if (mRadialMenuManager != null) { registerReceiver(mRadialMenuManager, mRadialMenuManager.getFilter()); } if (mVolumeMonitor != null) { registerReceiver(mVolumeMonitor, mVolumeMonitor.getFilter()); } mPrefs.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); // Add the broadcast listener for gestures. final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_PERFORM_GESTURE); registerReceiver(mActiveReceiver, filter, PERMISSION_TALKBACK, 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(); }
From source file:com.google.android.marvin.talkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state.//from w w w . j av a 2 s. c om */ private void resumeInfrastructure() { if (isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to resume while not suspended"); return; } setServiceState(ServiceState.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; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REPORT_VIEW_IDS; info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_FILTER_KEY_EVENTS; info.notificationTimeout = 0; // Ensure the initial touch exploration request mode is correct. if (SUPPORTS_TOUCH_PREF && SharedPreferencesUtils.getBooleanPref(mPrefs, getResources(), R.string.pref_explore_by_touch_key, R.bool.pref_explore_by_touch_default)) { info.flags |= AccessibilityServiceInfoCompatUtils.FLAG_REQUEST_TOUCH_EXPLORATION_MODE; } setServiceInfo(info); if (mCallStateMonitor != null) { registerReceiver(mCallStateMonitor, mCallStateMonitor.getFilter()); } if (mRingerModeAndScreenMonitor != null) { registerReceiver(mRingerModeAndScreenMonitor, mRingerModeAndScreenMonitor.getFilter()); } if (mTextToSpeechManager != null) { mTextToSpeechManager.startDiscovery(); } if (mRadialMenuManager != null) { registerReceiver(mRadialMenuManager, mRadialMenuManager.getFilter()); } if (mVolumeMonitor != null) { registerReceiver(mVolumeMonitor, mVolumeMonitor.getFilter()); } if (mPackageReceiver != null) { registerReceiver(mPackageReceiver, mPackageReceiver.getFilter()); if (mLabelManager != null) { mLabelManager.ensureDataConsistency(); } } mPrefs.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); // Add the broadcast listener for gestures. final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_PERFORM_GESTURE_ACTION); registerReceiver(mActiveReceiver, filter, PERMISSION_TALKBACK, 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(); }
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.//w w w.ja v a2s . 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.mytalkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state.//from w ww .j a v a2 s . c o m */ private void suspendInfrastructure() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend while already suspended"); return; } interruptAllFeedback(); setServiceState(ServiceState.SUSPENDED); setServiceInfo(new AccessibilityServiceInfo()); mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); unregisterReceiver(mActiveReceiver); if (mCallStateMonitor != null) { unregisterReceiver(mCallStateMonitor); } if (mRingerModeAndScreenMonitor != null) { unregisterReceiver(mRingerModeAndScreenMonitor); } if (mRadialMenuManager != null) { unregisterReceiver(mRadialMenuManager); mRadialMenuManager.clearCache(); } if (mVolumeMonitor != null) { unregisterReceiver(mVolumeMonitor); mVolumeMonitor.releaseControl(); } if (mShakeDetector != null) { mShakeDetector.setEnabled(false); } if (SUPPORTS_TOUCH_PREF) { final ContentResolver resolver = getContentResolver(); resolver.unregisterContentObserver(mTouchExploreObserver); } // Disable 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_DISABLED, PackageManager.DONT_KILL_APP); // Remove any pending notifications that shouldn't persist. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancelAll(); if (mTtsOverlay != null) { mTtsOverlay.hide(); } }
From source file:com.google.android.marvin.talkback.TalkBackService.java
/** * Registers listeners, sets service info, loads preferences. This should be * called from {@link #onServiceConnected} and when TalkBack resumes from a * suspended state./* www. j a va 2 s .c o m*/ */ private void suspendInfrastructure() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend while already suspended"); return; } interruptAllFeedback(); setServiceState(ServiceState.SUSPENDED); setServiceInfo(new AccessibilityServiceInfo()); mPrefs.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); unregisterReceiver(mActiveReceiver); if (mCallStateMonitor != null) { unregisterReceiver(mCallStateMonitor); } if (mRingerModeAndScreenMonitor != null) { unregisterReceiver(mRingerModeAndScreenMonitor); } if (mRadialMenuManager != null) { unregisterReceiver(mRadialMenuManager); mRadialMenuManager.clearCache(); } if (mVolumeMonitor != null) { unregisterReceiver(mVolumeMonitor); mVolumeMonitor.releaseControl(); } if (mPackageReceiver != null) { unregisterReceiver(mPackageReceiver); } if (mShakeDetector != null) { mShakeDetector.setEnabled(false); } if (SUPPORTS_TOUCH_PREF) { final ContentResolver resolver = getContentResolver(); resolver.unregisterContentObserver(mTouchExploreObserver); } // Disable 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_DISABLED, PackageManager.DONT_KILL_APP); // Remove any pending notifications that shouldn't persist. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancelAll(); if (mTtsOverlay != null) { mTtsOverlay.hide(); } }