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();
}
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);
}
}
}
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;
}
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;
}
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;
}
Aggregations