Debian Codegraph @

core/java/android/view/textclassifier/SelectionSessionLogger.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.view.textclassifier;
18
19 import android.annotation.Nullable;
20
21 import com.android.internal.annotations.VisibleForTesting;
22
23 /**
24 * A helper for logging selection session events.
25 *
26 * @hide
27 */
28 public final class SelectionSessionLogger {
29 // Keep this in sync with the ResultIdUtils in libtextclassifier.
30 private static final String CLASSIFIER_ID = "androidtc";
31
32 static boolean isPlatformLocalTextClassifierSmartSelection(String signature) {
33 return SelectionSessionLogger.CLASSIFIER_ID.equals(
34 SelectionSessionLogger.SignatureParser.getClassifierId(signature));
35 }
36
37 /**
38 * Helper for creating and parsing string ids for
39 * {@link android.view.textclassifier.TextClassifierImpl}.
40 */
41 @VisibleForTesting
42 public static final class SignatureParser {
43
44 static String getClassifierId(@Nullable String signature) {
45 if (signature == null) {
46 return "";
47 }
48 final int end = signature.indexOf("|");
49 if (end >= 0) {
50 return signature.substring(0, end);
51 }
52 return "";
53 }
54 }
55 }