Permalink
Browse files

Android: Fix memory leak in AccessibilityInfoModule

Summary:
This change fixes a memory leak in `AccessibilityInfoModule`.

Our tooling detected this memory leak. After this commit, we no longer see the leak in the tool. We've been using the change in our app.

Adam Comella
Microsoft Corp.
Closes #14171

Differential Revision: D5128845

Pulled By: javache

fbshipit-source-id: b604902188eb8cc029b1ad39d087e199ae26877c
  • Loading branch information...
rigdern authored and facebook-github-bot committed May 25, 2017
1 parent 9dc0385 commit e9ae31dfd6312b1d98eef34b4a8d366b7482bdb1
@@ -43,8 +43,8 @@ public void onTouchExplorationStateChanged(boolean enabled) {
public AccessibilityInfoModule(ReactApplicationContext context) {
super(context);
mAccessibilityManager = (AccessibilityManager) getReactApplicationContext()
.getSystemService(Context.ACCESSIBILITY_SERVICE);
Context appContext = context.getApplicationContext();
mAccessibilityManager = (AccessibilityManager) appContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
mEnabled = mAccessibilityManager.isTouchExplorationEnabled();
if (Build.VERSION.SDK_INT >= 19) {
mTouchExplorationStateChangeListener = new ReactTouchExplorationStateChangeListener();
@@ -92,6 +92,12 @@ public void initialize() {
updateAndSendChangeEvent(mAccessibilityManager.isTouchExplorationEnabled());
}
@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
getReactApplicationContext().removeLifecycleEventListener(this);
}
@Override
public void onHostDestroy() {
}

0 comments on commit e9ae31d

Please sign in to comment.