use of android.graphics.Region in project android_frameworks_base by ResurrectionRemix.
the class AccessibilityInteractionController method focusSearchUiThread.
private void focusSearchUiThread(Message message) {
final int flags = message.arg1;
final int accessibilityViewId = message.arg2;
SomeArgs args = (SomeArgs) message.obj;
final int direction = args.argi2;
final int interactionId = args.argi3;
final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
final MagnificationSpec spec = (MagnificationSpec) args.arg2;
final Region interactiveRegion = (Region) args.arg3;
args.recycle();
AccessibilityNodeInfo next = null;
try {
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
return;
}
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
View root = null;
if (accessibilityViewId != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
root = findViewByAccessibilityId(accessibilityViewId);
} else {
root = mViewRootImpl.mView;
}
if (root != null && isShown(root)) {
View nextView = root.focusSearch(direction);
if (nextView != null) {
next = nextView.createAccessibilityNodeInfo();
}
}
} finally {
try {
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
applyAppScaleAndMagnificationSpecIfNeeded(next, spec);
// system process and obtained from a pool when read from parcel.
if (spec != null && android.os.Process.myPid() != Binder.getCallingPid()) {
spec.recycle();
}
adjustIsVisibleToUserIfNeeded(next, interactiveRegion);
callback.setFindAccessibilityNodeInfoResult(next, interactionId);
} catch (RemoteException re) {
/* ignore - the other side will time out */
}
// the system process and instantiated when read from parcel.
if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) {
interactiveRegion.recycle();
}
}
}
use of android.graphics.Region in project android_frameworks_base by ResurrectionRemix.
the class AccessibilityInteractionController method findAccessibilityNodeInfoByAccessibilityIdUiThread.
private void findAccessibilityNodeInfoByAccessibilityIdUiThread(Message message) {
final int flags = message.arg1;
SomeArgs args = (SomeArgs) message.obj;
final int accessibilityViewId = args.argi1;
final int virtualDescendantId = args.argi2;
final int interactionId = args.argi3;
final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
final MagnificationSpec spec = (MagnificationSpec) args.arg2;
final Region interactiveRegion = (Region) args.arg3;
args.recycle();
List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
infos.clear();
try {
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
return;
}
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
View root = null;
if (accessibilityViewId == AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
root = mViewRootImpl.mView;
} else {
root = findViewByAccessibilityId(accessibilityViewId);
}
if (root != null && isShown(root)) {
mPrefetcher.prefetchAccessibilityNodeInfos(root, virtualDescendantId, flags, infos);
}
} finally {
try {
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
applyAppScaleAndMagnificationSpecIfNeeded(infos, spec);
// system process and obtained from a pool when read from parcel.
if (spec != null && android.os.Process.myPid() != Binder.getCallingPid()) {
spec.recycle();
}
adjustIsVisibleToUserIfNeeded(infos, interactiveRegion);
callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
infos.clear();
} catch (RemoteException re) {
/* ignore - the other side will time out */
}
// the system process and instantiated when read from parcel.
if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) {
interactiveRegion.recycle();
}
}
}
use of android.graphics.Region in project android_frameworks_base by ResurrectionRemix.
the class View method applyDrawableToTransparentRegion.
/**
* Given a Drawable whose bounds have been set to draw into this view,
* update a Region being computed for
* {@link #gatherTransparentRegion(android.graphics.Region)} so
* that any non-transparent parts of the Drawable are removed from the
* given transparent region.
*
* @param dr The Drawable whose transparency is to be applied to the region.
* @param region A Region holding the current transparency information,
* where any parts of the region that are set are considered to be
* transparent. On return, this region will be modified to have the
* transparency information reduced by the corresponding parts of the
* Drawable that are not transparent.
* {@hide}
*/
public void applyDrawableToTransparentRegion(Drawable dr, Region region) {
if (DBG) {
Log.i("View", "Getting transparent region for: " + this);
}
final Region r = dr.getTransparentRegion();
final Rect db = dr.getBounds();
final AttachInfo attachInfo = mAttachInfo;
if (r != null && attachInfo != null) {
final int w = getRight() - getLeft();
final int h = getBottom() - getTop();
if (db.left > 0) {
//Log.i("VIEW", "Drawable left " + db.left + " > view 0");
r.op(0, 0, db.left, h, Region.Op.UNION);
}
if (db.right < w) {
//Log.i("VIEW", "Drawable right " + db.right + " < view " + w);
r.op(db.right, 0, w, h, Region.Op.UNION);
}
if (db.top > 0) {
//Log.i("VIEW", "Drawable top " + db.top + " > view 0");
r.op(0, 0, w, db.top, Region.Op.UNION);
}
if (db.bottom < h) {
//Log.i("VIEW", "Drawable bottom " + db.bottom + " < view " + h);
r.op(0, db.bottom, w, h, Region.Op.UNION);
}
final int[] location = attachInfo.mTransparentLocation;
getLocationInWindow(location);
r.translate(location[0], location[1]);
region.op(r, Region.Op.INTERSECT);
} else {
region.op(db, Region.Op.DIFFERENCE);
}
}
use of android.graphics.Region in project android_frameworks_base by ResurrectionRemix.
the class AccessibilityInteractionController method findAccessibilityNodeInfosByViewIdUiThread.
private void findAccessibilityNodeInfosByViewIdUiThread(Message message) {
final int flags = message.arg1;
final int accessibilityViewId = message.arg2;
SomeArgs args = (SomeArgs) message.obj;
final int interactionId = args.argi1;
final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
final MagnificationSpec spec = (MagnificationSpec) args.arg2;
final String viewId = (String) args.arg3;
final Region interactiveRegion = (Region) args.arg4;
args.recycle();
final List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
infos.clear();
try {
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
return;
}
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
View root = null;
if (accessibilityViewId != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
root = findViewByAccessibilityId(accessibilityViewId);
} else {
root = mViewRootImpl.mView;
}
if (root != null) {
final int resolvedViewId = root.getContext().getResources().getIdentifier(viewId, null, null);
if (resolvedViewId <= 0) {
return;
}
if (mAddNodeInfosForViewId == null) {
mAddNodeInfosForViewId = new AddNodeInfosForViewId();
}
mAddNodeInfosForViewId.init(resolvedViewId, infos);
root.findViewByPredicate(mAddNodeInfosForViewId);
mAddNodeInfosForViewId.reset();
}
} finally {
try {
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
applyAppScaleAndMagnificationSpecIfNeeded(infos, spec);
// system process and obtained from a pool when read from parcel.
if (spec != null && android.os.Process.myPid() != Binder.getCallingPid()) {
spec.recycle();
}
adjustIsVisibleToUserIfNeeded(infos, interactiveRegion);
callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
} catch (RemoteException re) {
/* ignore - the other side will time out */
}
// the system process and instantiated when read from parcel.
if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) {
interactiveRegion.recycle();
}
}
}
use of android.graphics.Region in project android_frameworks_base by ResurrectionRemix.
the class AccessibilityInteractionController method findFocusUiThread.
private void findFocusUiThread(Message message) {
final int flags = message.arg1;
final int focusType = message.arg2;
SomeArgs args = (SomeArgs) message.obj;
final int interactionId = args.argi1;
final int accessibilityViewId = args.argi2;
final int virtualDescendantId = args.argi3;
final IAccessibilityInteractionConnectionCallback callback = (IAccessibilityInteractionConnectionCallback) args.arg1;
final MagnificationSpec spec = (MagnificationSpec) args.arg2;
final Region interactiveRegion = (Region) args.arg3;
args.recycle();
AccessibilityNodeInfo focused = null;
try {
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
return;
}
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags;
View root = null;
if (accessibilityViewId != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
root = findViewByAccessibilityId(accessibilityViewId);
} else {
root = mViewRootImpl.mView;
}
if (root != null && isShown(root)) {
switch(focusType) {
case AccessibilityNodeInfo.FOCUS_ACCESSIBILITY:
{
View host = mViewRootImpl.mAccessibilityFocusedHost;
// of the root from which to start the search, then the search failed.
if (host == null || !ViewRootImpl.isViewDescendantOf(host, root)) {
break;
}
// The focused view not shown, we failed.
if (!isShown(host)) {
break;
}
// If the host has a provider ask this provider to search for the
// focus instead fetching all provider nodes to do the search here.
AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider();
if (provider != null) {
if (mViewRootImpl.mAccessibilityFocusedVirtualView != null) {
focused = AccessibilityNodeInfo.obtain(mViewRootImpl.mAccessibilityFocusedVirtualView);
}
} else if (virtualDescendantId == AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
focused = host.createAccessibilityNodeInfo();
}
}
break;
case AccessibilityNodeInfo.FOCUS_INPUT:
{
View target = root.findFocus();
if (target == null || !isShown(target)) {
break;
}
AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
if (provider != null) {
focused = provider.findFocus(focusType);
}
if (focused == null) {
focused = target.createAccessibilityNodeInfo();
}
}
break;
default:
throw new IllegalArgumentException("Unknown focus type: " + focusType);
}
}
} finally {
try {
mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
applyAppScaleAndMagnificationSpecIfNeeded(focused, spec);
// system process and obtained from a pool when read from parcel.
if (spec != null && android.os.Process.myPid() != Binder.getCallingPid()) {
spec.recycle();
}
adjustIsVisibleToUserIfNeeded(focused, interactiveRegion);
callback.setFindAccessibilityNodeInfoResult(focused, interactionId);
} catch (RemoteException re) {
/* ignore - the other side will time out */
}
// the system process and instantiated when read from parcel.
if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) {
interactiveRegion.recycle();
}
}
}
Aggregations