Skip to content

Commit 83f984d

Browse files
committed
Remove GMS dependency, disable OCR permanently
Signed-off-by: Patryk Miś <[email protected]>
1 parent 7746c3a commit 83f984d

File tree

5 files changed

+6
-524
lines changed

5 files changed

+6
-524
lines changed

shared.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ dependencies {
4444

4545
// Google common
4646
implementation 'com.google.guava:guava:33.5.0-jre'
47-
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:19.0.1'
4847
implementation 'com.google.android.material:material:1.13.0'
4948

5049
// Support library

talkback/src/main/java/com/google/android/accessibility/talkback/actor/ImageCaptioner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ public void handleDialogDismiss() {}
425425
}
426426

427427
public static boolean supportsImageCaption(Context context) {
428-
return FeatureSupport.canTakeScreenShotByAccessibilityService()
429-
&& TalkbackFeatureSupport.supportDynamicFeatures();
428+
return false;
430429
}
431430

432431
/**

talkback/src/main/java/com/google/android/accessibility/talkback/imagecaption/CharacterCaptionRequest.java

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,21 @@
1616

1717
package com.google.android.accessibility.talkback.imagecaption;
1818

19-
import static com.google.android.accessibility.utils.caption.ImageCaptionUtils.CaptionType.OCR;
20-
2119
import android.accessibilityservice.AccessibilityService;
2220
import android.graphics.Bitmap;
23-
import android.text.TextUtils;
2421
import androidx.annotation.NonNull;
2522
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
26-
import com.google.android.accessibility.utils.Filter;
27-
import com.google.android.accessibility.utils.StringBuilderUtils;
2823
import com.google.android.accessibility.utils.caption.Result;
29-
import com.google.android.accessibility.utils.ocr.OcrController;
30-
import com.google.android.accessibility.utils.ocr.OcrController.OcrListener;
31-
import com.google.android.accessibility.utils.ocr.OcrInfo;
32-
import java.util.ArrayList;
3324
import java.util.List;
3425

3526
/**
36-
* A {@link CaptionRequest} for performing OCR (optical character recognition) to recognize text
37-
* from the screenshot.
27+
* A stub class for performing OCR (optical character recognition) to recognize text from the screenshot.
3828
*/
39-
public class CharacterCaptionRequest extends CaptionRequest implements OcrListener {
29+
public class CharacterCaptionRequest extends CaptionRequest {
4030

41-
private final OcrController ocrController;
4231
private final Bitmap screenCapture;
4332

44-
/** This object takes ownership of node, caller should not recycle. */
33+
/** Stub constructor */
4534
public CharacterCaptionRequest(
4635
int requestId,
4736
AccessibilityService service,
@@ -51,44 +40,13 @@ public CharacterCaptionRequest(
5140
@NonNull OnErrorListener onErrorListener,
5241
boolean isUserRequested) {
5342
super(requestId, node, onFinishListener, onErrorListener, isUserRequested);
54-
ocrController = new OcrController(this, /* needCropScreenshot= */ false);
5543
this.screenCapture = screenCapture;
5644
}
5745

5846
/**
59-
* Captures screen and performs ocr(optical character recognition) to recognize text for the given
60-
* node.
47+
* Stub method to capture screen and perform OCR (optical character recognition) to recognize text for the given node.
6148
*/
6249
@Override
63-
public void perform() {
64-
final List<OcrInfo> ocrInfos = new ArrayList<>();
65-
ocrInfos.add(new OcrInfo(node));
66-
onCaptionStart();
67-
ocrController.recognizeTextForNodes(
68-
screenCapture, ocrInfos, /* selectionBounds= */ null, Filter.node(node -> true));
69-
70-
runTimeoutRunnable();
71-
}
72-
73-
@Override
74-
public void onOcrStarted() {}
75-
76-
@Override
77-
public void onOcrFinished(List<OcrInfo> ocrResults) {
78-
stopTimeoutRunnable();
79-
if (ocrResults == null) {
80-
onError(ERROR_TEXT_RECOGNITION_NO_RESULT);
81-
return;
82-
}
50+
public void perform() {}
8351

84-
List<CharSequence> texts = new ArrayList<>();
85-
for (OcrInfo ocrResult : ocrResults) {
86-
String text = OcrController.getTextFromBlocks(ocrResult.getTextBlocks());
87-
if (TextUtils.isEmpty(text)) {
88-
continue;
89-
}
90-
texts.add(text);
91-
}
92-
onCaptionFinish(Result.create(OCR, StringBuilderUtils.getAggregateText(texts)));
93-
}
9452
}

0 commit comments

Comments
 (0)