Search in sources :

Example 46 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by AOSPA.

the class ViewRootImpl method getAccessibilityFocusedRect.

private boolean getAccessibilityFocusedRect(Rect bounds) {
    final AccessibilityManager manager = AccessibilityManager.getInstance(mView.mContext);
    if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
        return false;
    }
    final View host = mAccessibilityFocusedHost;
    if (host == null || host.mAttachInfo == null) {
        return false;
    }
    final AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider();
    if (provider == null) {
        host.getBoundsOnScreen(bounds, true);
    } else if (mAccessibilityFocusedVirtualView != null) {
        mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
    } else {
        return false;
    }
    // Transform the rect into window-relative coordinates.
    final AttachInfo attachInfo = mAttachInfo;
    bounds.offset(0, attachInfo.mViewRootImpl.mScrollY);
    bounds.offset(-attachInfo.mWindowLeft, -attachInfo.mWindowTop);
    if (!bounds.intersect(0, 0, attachInfo.mViewRootImpl.mWidth, attachInfo.mViewRootImpl.mHeight)) {
        // If no intersection, set bounds to empty.
        bounds.setEmpty();
    }
    return !bounds.isEmpty();
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AttachInfo(android.view.View.AttachInfo) AccessibilityNodeProvider(android.view.accessibility.AccessibilityNodeProvider)

Example 47 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project YhLibraryForAndroid by android-coco.

the class AgentWebView method setAccessibilityEnabled.

private void setAccessibilityEnabled(boolean enabled) {
    AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    try {
        Method setAccessibilityState = am.getClass().getDeclaredMethod("setAccessibilityState", boolean.class);
        setAccessibilityState.setAccessible(true);
        setAccessibilityState.invoke(am, enabled);
        setAccessibilityState.setAccessible(false);
    } catch (Throwable e) {
        if (LogUtils.isDebug()) {
            LogUtils.e(TAG, "setAccessibilityEnabled", e);
        }
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) Method(java.lang.reflect.Method)

Example 48 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_packages_apps_Dialer by LineageOS.

the class CallCardPresenter method sendAccessibilityEvent.

static boolean sendAccessibilityEvent(Context context, InCallScreen inCallScreen) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled()) {
        LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "accessibility is off");
        return false;
    }
    if (inCallScreen == null) {
        LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "incallscreen is null");
        return false;
    }
    Fragment fragment = inCallScreen.getInCallScreenFragment();
    if (fragment == null || fragment.getView() == null || fragment.getView().getParent() == null) {
        LogUtil.w("CallCardPresenter.sendAccessibilityEvent", "fragment/view/parent is null");
        return false;
    }
    DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    boolean screenIsOn = display.getState() == Display.STATE_ON;
    LogUtil.d("CallCardPresenter.sendAccessibilityEvent", "screen is on: %b", screenIsOn);
    if (!screenIsOn) {
        return false;
    }
    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
    inCallScreen.dispatchPopulateAccessibilityEvent(event);
    View view = inCallScreen.getInCallScreenFragment().getView();
    view.getParent().requestSendAccessibilityEvent(view, event);
    return true;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) DisplayManager(android.hardware.display.DisplayManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Fragment(android.support.v4.app.Fragment) View(android.view.View) Display(android.view.Display)

Example 49 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_packages_apps_Settings by omnirom.

the class MagnificationPreferenceFragment method getConfigurationWarningStringForSecureSettingsKey.

static CharSequence getConfigurationWarningStringForSecureSettingsKey(String key, Context context) {
    if (!Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(key)) {
        return null;
    }
    if (Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 0) {
        return null;
    }
    final AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    final String assignedId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT);
    if (!TextUtils.isEmpty(assignedId) && !MAGNIFICATION_COMPONENT_ID.equals(assignedId)) {
        final ComponentName assignedComponentName = ComponentName.unflattenFromString(assignedId);
        final List<AccessibilityServiceInfo> activeServices = am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
        final int serviceCount = activeServices.size();
        for (int i = 0; i < serviceCount; i++) {
            final AccessibilityServiceInfo info = activeServices.get(i);
            if (info.getComponentName().equals(assignedComponentName)) {
                final CharSequence assignedServiceName = info.getResolveInfo().loadLabel(context.getPackageManager());
                return context.getString(R.string.accessibility_screen_magnification_navbar_configuration_warning, assignedServiceName);
            }
        }
    }
    return null;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) ComponentName(android.content.ComponentName)

Example 50 with AccessibilityManager

use of android.view.accessibility.AccessibilityManager in project android_packages_apps_Settings by omnirom.

the class ShortcutServicePickerFragment method getCandidates.

@Override
protected List<? extends DefaultAppInfo> getCandidates() {
    final AccessibilityManager accessibilityManager = getContext().getSystemService(AccessibilityManager.class);
    final List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
    final int numInstalledServices = installedServices.size();
    List<DefaultAppInfo> candidates = new ArrayList<>(numInstalledServices);
    for (int i = 0; i < numInstalledServices; i++) {
        AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
        candidates.add(new DefaultAppInfo(mPm, UserHandle.myUserId(), installedServiceInfo.getComponentName(), (String) installedServiceInfo.loadSummary(mPm.getPackageManager()), true));
    }
    return candidates;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) ArrayList(java.util.ArrayList) DefaultAppInfo(com.android.settings.applications.defaultapps.DefaultAppInfo)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)170 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)54 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)49 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 ArrayList (java.util.ArrayList)26 ServiceInfo (android.content.pm.ServiceInfo)20 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 ComponentName (android.content.ComponentName)16 Drawable (android.graphics.drawable.Drawable)10 Bundle (android.os.Bundle)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 SuppressLint (android.annotation.SuppressLint)7 Context (android.content.Context)7 SwitchPreference (android.support.v14.preference.SwitchPreference)7 ListPreference (android.support.v7.preference.ListPreference)7 Preference (android.support.v7.preference.Preference)7 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6