Offset 1, 37 lines modifiedOffset 1, 33 lines modified
  
1 package·com.android.textclassifier;1 package·com.android.textclassifier;
  
2 import·java.util.concurrent.Future; 
3 import·android.ext.services.notification.Assistant$$ExternalSyntheticLambda3;2 import·android.ext.services.notification.Assistant$$ExternalSyntheticLambda2;
4 import·java.util.concurrent.Executor;3 import·java.util.concurrent.Executor;
5 import·com.google.common.base.Supplier;4 import·com.google.common.base.Supplier;
 5 import·com.android.textclassifier.common.ModelFileManager$$ExternalSyntheticLambda0;
6 import·java.util.concurrent.ExecutionException; 
7 import·android.util.Log; 
8 import·com.android.textclassifier.common.base.TcLog; 
9 import·android.ext.services.notification.Assistant$$ExternalSyntheticLambda2; 
10 import·com.android.textclassifier.common.TextSelectionCompat;6 import·com.android.textclassifier.common.TextClassifierServiceExecutors;
 7 import·java.util.Iterator;
 8 import·java.util.Map;
 9 import·java.util.LinkedHashMap;
 10 import·com.android.textclassifier.utils.IndentingPrintWriter;
 11 import·java.io.PrintWriter;
11 import·java.io.FileDescriptor;12 import·java.io.FileDescriptor;
12 import·android.view.textclassifier.TextClassificationContext;13 import·android.view.textclassifier.TextClassificationContext;
13 import·com.google.common.util.concurrent.ListenableFuture;14 import·com.google.common.util.concurrent.ListenableFuture;
14 import·android.os.CancellationSignal$OnCancelListener;15 import·android.os.CancellationSignal$OnCancelListener;
15 import·android.os.CancellationSignal;16 import·android.os.CancellationSignal;
16 import·com.android.textclassifier.common.statsd.TextClassifierApiUsageLogger$Session;17 import·com.android.textclassifier.common.statsd.TextClassifierApiUsageLogger$Session;
17 import·android.service.textclassifier.TextClassifierService$Callback;18 import·android.service.textclassifier.TextClassifierService$Callback;
18 import·com.google.common.util.concurrent.FutureCallback;19 import·com.google.common.util.concurrent.FutureCallback;
19 import·com.google.common.util.concurrent.Futures;20 import·com.google.common.util.concurrent.Futures;
20 import·com.google.common.util.concurrent.MoreExecutors;21 import·com.google.common.util.concurrent.MoreExecutors;
21 import·java.util.concurrent.Callable;22 import·java.util.concurrent.Callable;
22 import·com.google.common.util.concurrent.AbstractListeningExecutorService;23 import·com.google.common.util.concurrent.AbstractListeningExecutorService;
23 import·android.content.Context;24 import·android.content.Context;
24 import·java.util.Iterator; 
25 import·java.util.Map; 
26 import·java.util.LinkedHashMap; 
27 import·com.android.textclassifier.utils.IndentingPrintWriter; 
28 import·java.io.PrintWriter; 
29 import·android.view.textclassifier.TextLinks;25 import·android.view.textclassifier.TextLinks;
30 import·android.view.textclassifier.TextLinks$Request;26 import·android.view.textclassifier.TextLinks$Request;
31 import·android.view.textclassifier.ConversationActions;27 import·android.view.textclassifier.ConversationActions;
32 import·android.view.textclassifier.ConversationActions$Request;28 import·android.view.textclassifier.ConversationActions$Request;
33 import·android.view.textclassifier.TextClassification;29 import·android.view.textclassifier.TextClassification;
34 import·android.view.textclassifier.TextClassification$Request;30 import·android.view.textclassifier.TextClassification$Request;
35 import·android.view.textclassifier.TextClassifierEvent;31 import·android.view.textclassifier.TextClassifierEvent;
Offset 42, 23 lines modifiedOffset 38, 22 lines modified
42 import·android.view.textclassifier.TextLanguage$Request;38 import·android.view.textclassifier.TextLanguage$Request;
43 import·android.view.textclassifier.TextSelection;39 import·android.view.textclassifier.TextSelection;
44 import·android.view.textclassifier.TextSelection$Request;40 import·android.view.textclassifier.TextSelection$Request;
45 import·android.view.textclassifier.TextClassificationSessionId;41 import·android.view.textclassifier.TextClassificationSessionId;
46 import·com.android.textclassifier.common.statsd.TextClassifierApiUsageLogger;42 import·com.android.textclassifier.common.statsd.TextClassifierApiUsageLogger;
47 import·com.android.textclassifier.common.TextClassifierSettings;43 import·com.android.textclassifier.common.TextClassifierSettings;
48 import·androidx.collection.LruCache;44 import·androidx.collection.LruCache;
49 import·com.android.textclassifier.downloader.ModelDownloadManager;45 import·com.android.textclassifier.common.ModelFileManager;
50 import·com.google.common.util.concurrent.ListeningExecutorService;46 import·com.google.common.util.concurrent.ListeningExecutorService;
51 import·android.service.textclassifier.TextClassifierService;47 import·android.service.textclassifier.TextClassifierService;
  
52 public·final·class·DefaultTextClassifierService·extends·TextClassifierService48 public·final·class·DefaultTextClassifierService·extends·TextClassifierService
53 {49 {
54 ····private·final·DefaultTextClassifierService$Injector·injector;50 ····private·final·DefaultTextClassifierService$Injector·injector;
55 ····private·ListeningExecutorService·lowPriorityExecutor;51 ····private·ListeningExecutorService·lowPriorityExecutor;
56 ····private·ModelDownloadManager·modelDownloadManager; 
57 ····private·ModelFileManager·modelFileManager;52 ····private·ModelFileManager·modelFileManager;
58 ····private·ListeningExecutorService·normPriorityExecutor;53 ····private·ListeningExecutorService·normPriorityExecutor;
59 ····private·LruCache·sessionIdToContext;54 ····private·LruCache·sessionIdToContext;
60 ····private·TextClassifierSettings·settings;55 ····private·TextClassifierSettings·settings;
61 ····private·TextClassifierImpl·textClassifier;56 ····private·TextClassifierImpl·textClassifier;
62 ····private·TextClassifierApiUsageLogger·textClassifierApiUsageLogger;57 ····private·TextClassifierApiUsageLogger·textClassifierApiUsageLogger;
63 ····58 ····
Offset 67, 32 lines modifiedOffset 62, 14 lines modified
67 ········Objects.requireNonNull(textClassifier);62 ········Objects.requireNonNull(textClassifier);
68 ········final·TextClassifierEvent·textClassifierEvent·=·SelectionEventConverter.toTextClassifierEvent(selectionEvent);63 ········final·TextClassifierEvent·textClassifierEvent·=·SelectionEventConverter.toTextClassifierEvent(selectionEvent);
69 ········if·(textClassifierEvent·!=·null)·{64 ········if·(textClassifierEvent·!=·null)·{
70 ············textClassifier.onTextClassifierEvent(selectionEvent.getSessionId(),·textClassifierEvent);65 ············textClassifier.onTextClassifierEvent(selectionEvent.getSessionId(),·textClassifierEvent);
71 ········}66 ········}
72 ····}67 ····}
73 ····68 ····
74 ····public·static·void·$r8$lambda$eXpIopUKY8kIyJbvDtQTisEp18k(final·DefaultTextClassifierService·obj,·final·PrintWriter·printWriter)·{ 
75 ········Objects.requireNonNull(obj); 
76 ········final·IndentingPrintWriter·indentingPrintWriter·=·new·IndentingPrintWriter(printWriter); 
77 ········obj.textClassifier.dump(indentingPrintWriter); 
78 ········obj.modelDownloadManager.dump(indentingPrintWriter); 
79 ········indentingPrintWriter.println("DefaultTextClassifierService:"); 
80 ········indentingPrintWriter.increaseIndent(); 
81 ········indentingPrintWriter.println("sessionIdToContext:"); 
82 ········indentingPrintWriter.increaseIndent(); 
83 ········for·(final·Map.Entry<TextClassificationSessionId,·V>·entry·:·((LinkedHashMap)obj.sessionIdToContext.snapshot()).entrySet())·{ 
84 ············indentingPrintWriter.printPair(((TextClassificationSessionId)entry.getKey()).getValue(),·(Object)entry.getValue()); 
85 ········} 
86 ········indentingPrintWriter.decreaseIndent(); 
87 ········indentingPrintWriter.decreaseIndent(); 
88 ········indentingPrintWriter.println(); 
89 ········indentingPrintWriter.flush(); 
90 ····} 
91 ···· 
92 ····public·DefaultTextClassifierService()·{69 ····public·DefaultTextClassifierService()·{
93 ········this.injector·=·(DefaultTextClassifierService$Injector)new·DefaultTextClassifierService$InjectorImpl((Context)this,·(DefaultTextClassifierService$1)null);70 ········this.injector·=·(DefaultTextClassifierService$Injector)new·DefaultTextClassifierService$InjectorImpl((Context)this,·(DefaultTextClassifierService$1)null);
94 ····}71 ····}
95 ····72 ····
96 ····DefaultTextClassifierService(final·DefaultTextClassifierService$Injector·defaultTextClassifierService$Injector)·{73 ····DefaultTextClassifierService(final·DefaultTextClassifierService$Injector·defaultTextClassifierService$Injector)·{
97 ········Objects.requireNonNull(defaultTextClassifierService$Injector);74 ········Objects.requireNonNull(defaultTextClassifierService$Injector);
98 ········this.injector·=·defaultTextClassifierService$Injector;75 ········this.injector·=·defaultTextClassifierService$Injector;
Offset 112, 68 lines modifiedOffset 89, 59 lines modified
112 ········if·(textClassificationSessionId·==·null)·{89 ········if·(textClassificationSessionId·==·null)·{
113 ············return·null;90 ············return·null;
114 ········}91 ········}
115 ········return·(TextClassificationContext)this.sessionIdToContext.get((Object)textClassificationSessionId);92 ········return·(TextClassificationContext)this.sessionIdToContext.get((Object)textClassificationSessionId);
116 ····}93 ····}
117 ····94 ····
118 ····protected·void·dump(final·FileDescriptor·fileDescriptor,·final·PrintWriter·printWriter,·final·String[]·array)·{95 ····protected·void·dump(final·FileDescriptor·fileDescriptor,·final·PrintWriter·printWriter,·final·String[]·array)·{
 96 ········final·IndentingPrintWriter·indentingPrintWriter·=·new·IndentingPrintWriter(printWriter);
 97 ········this.textClassifier.dump(indentingPrintWriter);
 98 ········indentingPrintWriter.println("DefaultTextClassifierService:");
 99 ········indentingPrintWriter.increaseIndent();
 100 ········indentingPrintWriter.println("sessionIdToContext:");
 101 ········indentingPrintWriter.increaseIndent();
 102 ········for·(final·Map.Entry<TextClassificationSessionId,·V>·entry·:·((LinkedHashMap)this.sessionIdToContext.snapshot()).entrySet())·{
 103 ············indentingPrintWriter.printPair(((TextClassificationSessionId)entry.getKey()).getValue(),·(Object)entry.getValue());
119 ········try·{ 
120 ············final·ListeningExecutorService·lowPriorityExecutor·=·TextSelectionCompat.getLowPriorityExecutor(); 
121 ············try·{ 
122 ················final·ListenableFuture·submit·=·((AbstractListeningExecutorService)lowPriorityExecutor).submit((Runnable)new·Assistant$$ExternalSyntheticLambda2(this,·printWriter)); 
123 ················try·{ 
124 ····················((Future)submit).get(); 
125 ················} 
126 ················catch·(ExecutionException·|·InterruptedException·ex)·{ 
127 ····················final·Object·o2; 
128 ····················final·Object·o·=·o2; 
129 ····················final·boolean·enable_FULL_LOGGING·=·TcLog.ENABLE_FULL_LOGGING; 
130 ····················Log.e("androidtc",·"Failed·to·dump·Default·TextClassifierService",·(Throwable)o); 
131 ················} 
132 ············} 
133 ············catch·(ExecutionException·ex2)·{} 
134 ············catch·(InterruptedException·ex3)·{} 
135 ········}104 ········}
136 ········catch·(ExecutionException·ex4)·{} 
137 ········catch·(InterruptedException·ex5)·{}105 ········indentingPrintWriter.decreaseIndent();
 106 ········indentingPrintWriter.decreaseIndent();
 107 ········indentingPrintWriter.println();
 108 ········indentingPrintWriter.flush();
138 ····}109 ····}
139 ····110 ····
140 ····public·void·onClassifyText(final·TextClassificationSessionId·textClassificationSessionId,·final·TextClassification$Request·textClassification$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{111 ····public·void·onClassifyText(final·TextClassificationSessionId·textClassificationSessionId,·final·TextClassification$Request·textClassification$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{
141 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textClassification$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(2,·textClassificationSessionId),·cancellationSignal);112 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textClassification$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(2,·textClassificationSessionId),·cancellationSignal);
142 ····}113 ····}
143 ····114 ····
144 ····public·void·onCreate()·{115 ····public·void·onCreate()·{
145 ········super.onCreate();116 ········super.onCreate();
146 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);117 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);
147 ········final·TextClassifierSettings·settings·=·new·TextClassifierSettings();118 ········final·TextClassifierSettings·settings·=·new·TextClassifierSettings();
148 ········this.settings·=·settings;119 ········this.settings·=·settings;
149 ········this.modelFileManager·=·((DefaultTextClassifierService$InjectorImpl)this.injector).createModelFileManager(settings);120 ········this.modelFileManager·=·((DefaultTextClassifierService$InjectorImpl)this.injector).createModelFileManager(settings);
150 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);121 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);
151 ········this.normPriorityExecutor·=·TextSelectionCompat.getNormhPriorityExecutor();122 ········this.normPriorityExecutor·=·TextClassifierServiceExecutors.getNormhPriorityExecutor();
152 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);123 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)this.injector);
153 ········this.lowPriorityExecutor·=·TextSelectionCompat.getLowPriorityExecutor();124 ········this.lowPriorityExecutor·=·TextClassifierServiceExecutors.getLowPriorityExecutor();
154 ········this.textClassifier·=·((DefaultTextClassifierService$InjectorImpl)this.injector).createTextClassifierImpl(this.settings,·this.modelFileManager);125 ········this.textClassifier·=·((DefaultTextClassifierService$InjectorImpl)this.injector).createTextClassifierImpl(this.settings,·this.modelFileManager);
155 ········this.sessionIdToContext·=·new·LruCache(this.settings.getSessionIdToContextCacheSize());126 ········this.sessionIdToContext·=·new·LruCache(this.settings.getSessionIdToContextCacheSize());
156 ········(this.modelDownloadManager·=·new·ModelDownloadManager(((DefaultTextClassifierService$InjectorImpl)this.injector).getContext().getApplicationContext(),·this.settings,·TextSelectionCompat.getDownloaderExecutor())).onTextClassifierServiceCreated(); 
157 ········this.modelFileManager.addModelDownloaderModels(this.modelDownloadManager,·this.settings); 
158 ········final·DefaultTextClassifierService$Injector·injector·=·this.injector;127 ········final·DefaultTextClassifierService$Injector·injector·=·this.injector;
159 ········final·TextClassifierSettings·settings2·=·this.settings;128 ········final·TextClassifierSettings·settings2·=·this.settings;
160 ········final·ListeningExecutorService·lowPriorityExecutor·=·this.lowPriorityExecutor;129 ········final·ListeningExecutorService·lowPriorityExecutor·=·this.lowPriorityExecutor;
161 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)injector);130 ········Objects.requireNonNull((DefaultTextClassifierService$InjectorImpl)injector);
162 ········Objects.requireNonNull(settings2);131 ········Objects.requireNonNull(settings2);
163 ········this.textClassifierApiUsageLogger·=·new·TextClassifierApiUsageLogger((Supplier)new·DefaultTextClassifierService$InjectorImpl$$ExternalSyntheticLambda0(settings2),·(Executor)lowPriorityExecutor);132 ········this.textClassifierApiUsageLogger·=·new·TextClassifierApiUsageLogger((Supplier)new·ModelFileManager$$ExternalSyntheticLambda0(settings2,·1),·(Executor)lowPriorityExecutor);
164 ····}133 ····}
165 ····134 ····
166 ····public·void·onCreateTextClassificationSession(final·TextClassificationContext·textClassificationContext,·final·TextClassificationSessionId·textClassificationSessionId)·{135 ····public·void·onCreateTextClassificationSession(final·TextClassificationContext·textClassificationContext,·final·TextClassificationSessionId·textClassificationSessionId)·{
167 ········this.sessionIdToContext.put((Object)textClassificationSessionId,·(Object)textClassificationContext);136 ········this.sessionIdToContext.put((Object)textClassificationSessionId,·(Object)textClassificationContext);
168 ····}137 ····}
169 ····138 ····
170 ····public·void·onDestroy()·{139 ····public·void·onDestroy()·{
171 ········super.onDestroy();140 ········super.onDestroy();
172 ········this.modelDownloadManager.destroy(); 
173 ····}141 ····}
174 ····142 ····
175 ····public·void·onDestroyTextClassificationSession(final·TextClassificationSessionId·textClassificationSessionId)·{143 ····public·void·onDestroyTextClassificationSession(final·TextClassificationSessionId·textClassificationSessionId)·{
176 ········this.sessionIdToContext.remove((Object)textClassificationSessionId);144 ········this.sessionIdToContext.remove((Object)textClassificationSessionId);
177 ····}145 ····}
178 ····146 ····
179 ····public·void·onDetectLanguage(final·TextClassificationSessionId·textClassificationSessionId,·final·TextLanguage$Request·textLanguage$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{147 ····public·void·onDetectLanguage(final·TextClassificationSessionId·textClassificationSessionId,·final·TextLanguage$Request·textLanguage$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{
Offset 181, 22 lines modifiedOffset 149, 22 lines modified
181 ····}149 ····}
182 ····150 ····
183 ····public·void·onGenerateLinks(final·TextClassificationSessionId·textClassificationSessionId,·final·TextLinks$Request·textLinks$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{151 ····public·void·onGenerateLinks(final·TextClassificationSessionId·textClassificationSessionId,·final·TextLinks$Request·textLinks$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{
184 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textLinks$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(3,·textClassificationSessionId),·cancellationSignal);152 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textLinks$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(3,·textClassificationSessionId),·cancellationSignal);
185 ····}153 ····}
186 ····154 ····
187 ····public·void·onSelectionEvent(final·TextClassificationSessionId·textClassificationSessionId,·final·SelectionEvent·selectionEvent)·{155 ····public·void·onSelectionEvent(final·TextClassificationSessionId·textClassificationSessionId,·final·SelectionEvent·selectionEvent)·{
188 ········this.handleEvent((Runnable)new·Assistant$$ExternalSyntheticLambda3(this,·textClassificationSessionId,·selectionEvent));156 ········this.handleEvent((Runnable)new·Assistant$$ExternalSyntheticLambda2(this,·textClassificationSessionId,·selectionEvent));
189 ····}157 ····}
190 ····158 ····
191 ····public·void·onSuggestConversationActions(final·TextClassificationSessionId·textClassificationSessionId,·final·ConversationActions$Request·conversationActions$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{159 ····public·void·onSuggestConversationActions(final·TextClassificationSessionId·textClassificationSessionId,·final·ConversationActions$Request·conversationActions$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{
192 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·conversationActions$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(5,·textClassificationSessionId),·cancellationSignal);160 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·conversationActions$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(5,·textClassificationSessionId),·cancellationSignal);
193 ····}161 ····}
194 ····162 ····
195 ····public·void·onSuggestSelection(final·TextClassificationSessionId·textClassificationSessionId,·final·TextSelection$Request·textSelection$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{163 ····public·void·onSuggestSelection(final·TextClassificationSessionId·textClassificationSessionId,·final·TextSelection$Request·textSelection$Request,·final·CancellationSignal·cancellationSignal,·final·TextClassifierService$Callback·textClassifierService$Callback)·{
196 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textSelection$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(1,·textClassificationSessionId),·cancellationSignal);164 ········this.handleRequestAsync((Callable)new·DefaultTextClassifierService$$ExternalSyntheticLambda1(this,·textClassificationSessionId,·textSelection$Request),·textClassifierService$Callback,·this.textClassifierApiUsageLogger.createSession(1,·textClassificationSessionId),·cancellationSignal);
197 ····}165 ····}
198 ····166 ····
199 ····public·void·onTextClassifierEvent(final·TextClassificationSessionId·textClassificationSessionId,·final·TextClassifierEvent·textClassifierEvent)·{167 ····public·void·onTextClassifierEvent(final·TextClassificationSessionId·textClassificationSessionId,·final·TextClassifierEvent·textClassifierEvent)·{
200 ········this.handleEvent((Runnable)new·Assistant$$ExternalSyntheticLambda3(this,·textClassificationSessionId,·textClassifierEvent));168 ········this.handleEvent((Runnable)new·Assistant$$ExternalSyntheticLambda2(this,·textClassificationSessionId,·textClassifierEvent));
201 ····}169 ····}
202 }170 }