Skip to content

Commit

Permalink
fix: Revert the clearCache change for API 33+ (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Jan 10, 2024
1 parent c61c868 commit 719122f
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package io.appium.uiautomator2.utils;

import android.accessibilityservice.AccessibilityService;
import android.os.Build;
import android.os.SystemClock;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
Expand All @@ -28,8 +26,6 @@
import java.util.List;
import java.util.Objects;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import io.appium.uiautomator2.common.exceptions.UiAutomator2Exception;
import io.appium.uiautomator2.core.UiAutomatorBridge;
import io.appium.uiautomator2.model.internal.CustomUiDevice;
Expand All @@ -49,13 +45,8 @@ public class AXWindowHelpers {
*/
private static void clearAccessibilityCache() {
try {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
AccessibilityService accessibilityService = getInstrumentation().getContext().getSystemService(AccessibilityService.class);
accessibilityService.clearCache();
} else {
// This call invokes `AccessibilityInteractionClient.getInstance().clearCache();` method
UiAutomatorBridge.getInstance().getUiAutomation().setServiceInfo(null);
}
// This call invokes `AccessibilityInteractionClient.getInstance().clearCache();` method
UiAutomatorBridge.getInstance().getUiAutomation().setServiceInfo(null);
} catch (NullPointerException npe) {
// it is fine
// ignore
Expand Down

0 comments on commit 719122f

Please sign in to comment.