diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2015-06-04 02:20:36 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-04 02:21:09 +0000 |
| commit | b3876474399ae22ccfc8f04d7f9ab577517db370 (patch) | |
| tree | 0a821dfc7ab49470e85b00d0bc99a7f62a75db4c /core/java/android/view/AccessibilityInteractionController.java | |
| parent | b7c3e931cd2ef332f05a2bb78e7036d53aeab18c (diff) | |
| parent | 386a824384a0d5795a38d10d1d2c18e4e50f8c30 (diff) | |
| download | frameworks_base-b3876474399ae22ccfc8f04d7f9ab577517db370.zip frameworks_base-b3876474399ae22ccfc8f04d7f9ab577517db370.tar.gz frameworks_base-b3876474399ae22ccfc8f04d7f9ab577517db370.tar.bz2 | |
Merge "Make node retrieval methods in AccessibilityManagerService use separate Region instances to make them thread safe." into mnc-dev
Diffstat (limited to 'core/java/android/view/AccessibilityInteractionController.java')
| -rw-r--r-- | core/java/android/view/AccessibilityInteractionController.java | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java index 6e2d110..664c02a 100644 --- a/core/java/android/view/AccessibilityInteractionController.java +++ b/core/java/android/view/AccessibilityInteractionController.java @@ -19,6 +19,7 @@ package android.view; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; +import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -158,7 +159,9 @@ final class AccessibilityInteractionController { try { mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0; applyAppScaleAndMagnificationSpecIfNeeded(infos, spec); - if (spec != null) { + // Recycle if called from another process. Specs are cached in the + // 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); @@ -167,6 +170,12 @@ final class AccessibilityInteractionController { } catch (RemoteException re) { /* ignore - the other side will time out */ } + + // Recycle if called from the same process. Regions are obtained in + // the system process and instantiated when read from parcel. + if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) { + interactiveRegion.recycle(); + } } } @@ -244,7 +253,9 @@ final class AccessibilityInteractionController { try { mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0; applyAppScaleAndMagnificationSpecIfNeeded(infos, spec); - if (spec != null) { + // Recycle if called from another process. Specs are cached in the + // 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); @@ -252,6 +263,12 @@ final class AccessibilityInteractionController { } catch (RemoteException re) { /* ignore - the other side will time out */ } + + // Recycle if called from the same process. Regions are obtained in + // the system process and instantiated when read from parcel. + if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) { + interactiveRegion.recycle(); + } } } @@ -354,7 +371,9 @@ final class AccessibilityInteractionController { try { mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0; applyAppScaleAndMagnificationSpecIfNeeded(infos, spec); - if (spec != null) { + // Recycle if called from another process. Specs are cached in the + // 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); @@ -362,6 +381,12 @@ final class AccessibilityInteractionController { } catch (RemoteException re) { /* ignore - the other side will time out */ } + + // Recycle if called from the same process. Regions are obtained in + // the system process and instantiated when read from parcel. + if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) { + interactiveRegion.recycle(); + } } } @@ -468,7 +493,9 @@ final class AccessibilityInteractionController { try { mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0; applyAppScaleAndMagnificationSpecIfNeeded(focused, spec); - if (spec != null) { + // Recycle if called from another process. Specs are cached in the + // 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); @@ -476,6 +503,12 @@ final class AccessibilityInteractionController { } catch (RemoteException re) { /* ignore - the other side will time out */ } + + // Recycle if called from the same process. Regions are obtained in + // the system process and instantiated when read from parcel. + if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) { + interactiveRegion.recycle(); + } } } @@ -545,7 +578,9 @@ final class AccessibilityInteractionController { try { mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0; applyAppScaleAndMagnificationSpecIfNeeded(next, spec); - if (spec != null) { + // Recycle if called from another process. Specs are cached in the + // 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); @@ -553,6 +588,12 @@ final class AccessibilityInteractionController { } catch (RemoteException re) { /* ignore - the other side will time out */ } + + // Recycle if called from the same process. Regions are obtained in + // the system process and instantiated when read from parcel. + if (interactiveRegion != null && android.os.Process.myPid() == Binder.getCallingPid()) { + interactiveRegion.recycle(); + } } } |
