Search in sources :

Example 26 with AccessibilityManager

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;
    }
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) UserInfo(android.content.pm.UserInfo) ParcelableString(com.android.internal.util.ParcelableString) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager)

Example 27 with AccessibilityManager

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;
}
Also used : Context(android.content.Context) AccessibilityManager(android.view.accessibility.AccessibilityManager) MotionEvent(android.view.MotionEvent) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Event(com.android.calendar.Event) Time(android.text.format.Time) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 28 with AccessibilityManager

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);
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 29 with AccessibilityManager

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);
    }
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) ITransientNotification(android.app.ITransientNotification) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Example 30 with AccessibilityManager

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;
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager)

Aggregations

AccessibilityManager (android.view.accessibility.AccessibilityManager)118 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)47 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)43 MediumTest (android.test.suitebuilder.annotation.MediumTest)20 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)18 ArrayList (java.util.ArrayList)12 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)7 ITransientNotification (android.app.ITransientNotification)6 Notification (android.app.Notification)6 UserInfo (android.content.pm.UserInfo)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 ParcelableString (com.android.internal.util.ParcelableString)6 SuppressLint (android.annotation.SuppressLint)5 ServiceInfo (android.content.pm.ServiceInfo)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 Context (android.content.Context)4 AttachInfo (android.view.View.AttachInfo)4 IAccessibilityManagerClient (android.view.accessibility.IAccessibilityManagerClient)4 ApplicationInfo (android.content.pm.ApplicationInfo)3 Paint (android.graphics.Paint)3