use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method getPermittedAccessibilityServicesForUser.
@Override
public List getPermittedAccessibilityServicesForUser(int userId) {
if (!mHasFeature) {
return null;
}
synchronized (this) {
List<String> result = null;
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedAccessiblityServices;
if (fromAdmin != null) {
if (result == null) {
result = new ArrayList<>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
}
}
}
// If we have a permitted list add all system accessibility services.
if (result != null) {
long id = mInjector.binderClearCallingIdentity();
try {
UserInfo user = getUserInfo(userId);
if (user.isManagedProfile()) {
userId = user.profileGroupId;
}
AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
if (installedServices != null) {
for (AccessibilityServiceInfo service : installedServices) {
ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
result.add(serviceInfo.packageName);
}
}
}
} finally {
mInjector.binderRestoreCallingIdentity(id);
}
}
return result;
}
}
use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.
the class MonthWeekEventsView method onHoverEvent.
@Override
public boolean onHoverEvent(MotionEvent event) {
Context context = getContext();
// only send accessibility events if accessibility and exploration are
// on.
AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
return super.onHoverEvent(event);
}
if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
Time hover = getDayFromLocation(event.getX());
if (hover != null && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) != 0)) {
Long millis = hover.toMillis(true);
String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
accessEvent.getText().add(date);
if (mShowDetailsInMonth && mEvents != null) {
int dayStart = SPACING_WEEK_NUMBER + mPadding;
int dayPosition = (int) ((event.getX() - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
ArrayList<Event> events = mEvents.get(dayPosition);
List<CharSequence> text = accessEvent.getText();
for (Event e : events) {
text.add(e.getTitleAndLocation() + ". ");
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
if (!e.allDay) {
flags |= DateUtils.FORMAT_SHOW_TIME;
if (DateFormat.is24HourFormat(context)) {
flags |= DateUtils.FORMAT_24HOUR;
}
} else {
flags |= DateUtils.FORMAT_UTC;
}
text.add(Utils.formatDateRange(context, e.startMillis, e.endMillis, flags) + ". ");
}
}
sendAccessibilityEventUnchecked(accessEvent);
mLastHoverTime = hover;
}
}
return true;
}
use of android.view.accessibility.AccessibilityManager in project Etar-Calendar by Etar-Group.
the class EventInfoFragment method sendAccessibilityEvent.
private void sendAccessibilityEvent() {
AccessibilityManager am = (AccessibilityManager) getActivity().getSystemService(Service.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_FOCUSED);
event.setClassName(getClass().getName());
event.setPackageName(getActivity().getPackageName());
List<CharSequence> text = event.getText();
addFieldToAccessibilityEvent(text, mTitle, null);
addFieldToAccessibilityEvent(text, mWhenDateTime, null);
addFieldToAccessibilityEvent(text, mWhere, null);
addFieldToAccessibilityEvent(text, null, mDesc);
if (mResponseRadioGroup.getVisibility() == View.VISIBLE) {
int id = mResponseRadioGroup.getCheckedRadioButtonId();
if (id != View.NO_ID) {
text.add(((TextView) getView().findViewById(R.id.response_label)).getText());
text.add((((RadioButton) (mResponseRadioGroup.findViewById(id))).getText() + PERIOD_SPACE));
}
}
am.sendAccessibilityEvent(event);
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class NotificationManagerService method sendAccessibilityEvent.
void sendAccessibilityEvent(Notification notification, CharSequence packageName) {
AccessibilityManager manager = AccessibilityManager.getInstance(getContext());
if (!manager.isEnabled()) {
return;
}
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
event.setPackageName(packageName);
event.setClassName(Notification.class.getName());
event.setParcelableData(notification);
CharSequence tickerText = notification.tickerText;
if (!TextUtils.isEmpty(tickerText)) {
event.getText().add(tickerText);
}
try {
manager.sendAccessibilityEvent(event);
} catch (IllegalStateException e) {
Slog.e(TAG, "sendAccessibilityEvent failed.", e);
}
}
use of android.view.accessibility.AccessibilityManager in project android_frameworks_base by DirtyUnicorns.
the class View method requestAccessibilityFocus.
/**
* Call this to try to give accessibility focus to this view.
*
* A view will not actually take focus if {@link AccessibilityManager#isEnabled()}
* returns false or the view is no visible or the view already has accessibility
* focus.
*
* See also {@link #focusSearch(int)}, which is what you call to say that you
* have focus, and you want your parent to look for the next one.
*
* @return Whether this view actually took accessibility focus.
*
* @hide
*/
public boolean requestAccessibilityFocus() {
AccessibilityManager manager = AccessibilityManager.getInstance(mContext);
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) {
return false;
}
if ((mViewFlags & VISIBILITY_MASK) != VISIBLE) {
return false;
}
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) == 0) {
mPrivateFlags2 |= PFLAG2_ACCESSIBILITY_FOCUSED;
ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl != null) {
viewRootImpl.setAccessibilityFocus(this, null);
}
invalidate();
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
}
return false;
}
Aggregations