Commit ccd42cfc authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

[Selection] Avoid to inline SmartSelectionMetricsLogger on below P

No logic change, add @VerifiesOnP and make the version check at call site
of SmartSelectionMetricsLogger.create(), hopefully it will not try to
load SmartSelectionMetricsLogger class on below P, so it will avoid
class verification failure on below P.

Bug: 1021642
Test: Current tests should pass.
Change-Id: I4df098ef8e074b93629aeba12608efbfc636c850
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900290Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712792}
parent 94ef657e
......@@ -74,8 +74,10 @@ public class SmartSelectionClient implements SelectionClient {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
mProvider = new SmartSelectionProvider(callback, windowAndroid);
mCallback = callback;
mSmartSelectionMetricLogger =
SmartSelectionMetricsLogger.create(windowAndroid.getContext().get());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
mSmartSelectionMetricLogger =
SmartSelectionMetricsLogger.create(windowAndroid.getContext().get());
}
mNativeSmartSelectionClient =
SmartSelectionClientJni.get().init(SmartSelectionClient.this, webContents);
}
......
......@@ -13,6 +13,7 @@ import android.view.textclassifier.TextClassificationManager;
import android.view.textclassifier.TextClassifier;
import org.chromium.base.Log;
import org.chromium.base.annotations.VerifiesOnP;
import org.chromium.content_public.browser.SelectionClient;
import org.chromium.content_public.browser.SelectionMetricsLogger;
......@@ -26,6 +27,7 @@ import org.chromium.content_public.browser.SelectionMetricsLogger;
* that, we single tap on "City", Smart Selection reset get triggered, we need to log [1, 2). Spaces
* are ignored but we count each punctuation mark as a word.
*/
@VerifiesOnP
@TargetApi(Build.VERSION_CODES.P)
public class SmartSelectionMetricsLogger implements SelectionMetricsLogger {
private static final String TAG = "SmartSelectionLogger";
......@@ -38,7 +40,7 @@ public class SmartSelectionMetricsLogger implements SelectionMetricsLogger {
private SelectionIndicesConverter mConverter;
public static SmartSelectionMetricsLogger create(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P || context == null) {
if (context == null) {
return null;
}
return new SmartSelectionMetricsLogger(context);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment