blob: e97df84a832903a8ca70bedd89732641e179f218 [file] [log] [blame]
satok988323c2011-06-22 16:38:13 +09001/*
2 * Copyright (C) 2011 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
17package com.android.server;
18
19import com.android.internal.content.PackageMonitor;
20import com.android.internal.textservice.ISpellCheckerService;
21import com.android.internal.textservice.ISpellCheckerSession;
22import com.android.internal.textservice.ISpellCheckerSessionListener;
23import com.android.internal.textservice.ITextServicesManager;
24import com.android.internal.textservice.ITextServicesSessionListener;
25
26import android.content.ComponentName;
27import android.content.Context;
28import android.content.Intent;
29import android.content.ServiceConnection;
30import android.content.pm.PackageManager;
31import android.content.pm.ResolveInfo;
32import android.content.pm.ServiceInfo;
satok6be6d752011-07-28 20:40:38 +090033import android.os.Binder;
satok988323c2011-06-22 16:38:13 +090034import android.os.IBinder;
35import android.os.RemoteException;
36import android.os.SystemClock;
37import android.provider.Settings;
38import android.text.TextUtils;
39import android.service.textservice.SpellCheckerService;
40import android.util.Log;
41import android.util.Slog;
42import android.view.textservice.SpellCheckerInfo;
43
44import java.util.ArrayList;
45import java.util.HashMap;
46import java.util.HashSet;
47import java.util.List;
48
49public class TextServicesManagerService extends ITextServicesManager.Stub {
50 private static final String TAG = TextServicesManagerService.class.getSimpleName();
51 private static final boolean DBG = false;
52
53 private final Context mContext;
54 private boolean mSystemReady;
55 private final TextServicesMonitor mMonitor;
56 private final HashMap<String, SpellCheckerInfo> mSpellCheckerMap =
57 new HashMap<String, SpellCheckerInfo>();
58 private final ArrayList<SpellCheckerInfo> mSpellCheckerList = new ArrayList<SpellCheckerInfo>();
59 private final HashMap<String, SpellCheckerBindGroup> mSpellCheckerBindGroups =
60 new HashMap<String, SpellCheckerBindGroup>();
61
62 public void systemReady() {
63 if (!mSystemReady) {
64 mSystemReady = true;
65 }
66 }
67
68 public TextServicesManagerService(Context context) {
69 mSystemReady = false;
70 mContext = context;
71 mMonitor = new TextServicesMonitor();
72 mMonitor.register(context, true);
73 synchronized (mSpellCheckerMap) {
74 buildSpellCheckerMapLocked(context, mSpellCheckerList, mSpellCheckerMap);
75 }
satokdf5659d2011-07-29 18:38:21 +090076 SpellCheckerInfo sci = getCurrentSpellChecker(null);
77 if (sci == null) {
78 sci = findAvailSpellCheckerLocked(null, null);
79 if (sci != null) {
80 // Set the current spell checker if there is one or more spell checkers
81 // available. In this case, "sci" is the first one in the available spell
82 // checkers.
satok5b9b5a92011-08-02 12:24:44 +090083 setCurrentSpellCheckerLocked(sci.getId());
satokdf5659d2011-07-29 18:38:21 +090084 }
85 }
satok988323c2011-06-22 16:38:13 +090086 }
87
88 private class TextServicesMonitor extends PackageMonitor {
89 @Override
90 public void onSomePackagesChanged() {
91 synchronized (mSpellCheckerMap) {
92 buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap);
93 // TODO: Update for each locale
94 SpellCheckerInfo sci = getCurrentSpellChecker(null);
satokda317ef2011-07-26 08:02:45 +090095 if (sci == null) return;
satok988323c2011-06-22 16:38:13 +090096 final String packageName = sci.getPackageName();
97 final int change = isPackageDisappearing(packageName);
satok5b9b5a92011-08-02 12:24:44 +090098 if (// Package disappearing
99 change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE
100 // Package modified
101 || isPackageModified(packageName)) {
102 sci = findAvailSpellCheckerLocked(null, packageName);
103 if (sci != null) {
104 setCurrentSpellCheckerLocked(sci.getId());
105 }
satok988323c2011-06-22 16:38:13 +0900106 }
107 }
108 }
109 }
110
111 private static void buildSpellCheckerMapLocked(Context context,
112 ArrayList<SpellCheckerInfo> list, HashMap<String, SpellCheckerInfo> map) {
113 list.clear();
114 map.clear();
115 final PackageManager pm = context.getPackageManager();
116 List<ResolveInfo> services = pm.queryIntentServices(
117 new Intent(SpellCheckerService.SERVICE_INTERFACE), PackageManager.GET_META_DATA);
118 final int N = services.size();
119 for (int i = 0; i < N; ++i) {
120 final ResolveInfo ri = services.get(i);
121 final ServiceInfo si = ri.serviceInfo;
122 final ComponentName compName = new ComponentName(si.packageName, si.name);
123 if (!android.Manifest.permission.BIND_TEXT_SERVICE.equals(si.permission)) {
124 Slog.w(TAG, "Skipping text service " + compName
125 + ": it does not require the permission "
126 + android.Manifest.permission.BIND_TEXT_SERVICE);
127 continue;
128 }
129 if (DBG) Slog.d(TAG, "Add: " + compName);
130 final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri);
131 list.add(sci);
132 map.put(sci.getId(), sci);
133 }
satokda317ef2011-07-26 08:02:45 +0900134 if (DBG) {
135 Slog.d(TAG, "buildSpellCheckerMapLocked: " + list.size() + "," + map.size());
136 }
satok988323c2011-06-22 16:38:13 +0900137 }
138
139 // TODO: find an appropriate spell checker for specified locale
140 private SpellCheckerInfo findAvailSpellCheckerLocked(String locale, String prefPackage) {
141 final int spellCheckersCount = mSpellCheckerList.size();
142 if (spellCheckersCount == 0) {
143 Slog.w(TAG, "no available spell checker services found");
144 return null;
145 }
146 if (prefPackage != null) {
147 for (int i = 0; i < spellCheckersCount; ++i) {
148 final SpellCheckerInfo sci = mSpellCheckerList.get(i);
149 if (prefPackage.equals(sci.getPackageName())) {
satokda317ef2011-07-26 08:02:45 +0900150 if (DBG) {
151 Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
152 }
satok988323c2011-06-22 16:38:13 +0900153 return sci;
154 }
155 }
156 }
157 if (spellCheckersCount > 1) {
158 Slog.w(TAG, "more than one spell checker service found, picking first");
159 }
160 return mSpellCheckerList.get(0);
161 }
162
163 // TODO: Save SpellCheckerService by supported languages. Currently only one spell
164 // checker is saved.
165 @Override
166 public SpellCheckerInfo getCurrentSpellChecker(String locale) {
167 synchronized (mSpellCheckerMap) {
satokda317ef2011-07-26 08:02:45 +0900168 String curSpellCheckerId =
satok988323c2011-06-22 16:38:13 +0900169 Settings.Secure.getString(mContext.getContentResolver(),
170 Settings.Secure.SPELL_CHECKER_SERVICE);
satok562ab582011-07-25 10:12:21 +0900171 if (DBG) {
172 Slog.w(TAG, "getCurrentSpellChecker: " + curSpellCheckerId);
173 }
satok988323c2011-06-22 16:38:13 +0900174 if (TextUtils.isEmpty(curSpellCheckerId)) {
satokdf5659d2011-07-29 18:38:21 +0900175 return null;
satok988323c2011-06-22 16:38:13 +0900176 }
177 return mSpellCheckerMap.get(curSpellCheckerId);
178 }
179 }
180
181 @Override
satok5b9b5a92011-08-02 12:24:44 +0900182 public void getSpellCheckerService(String sciId, String locale,
satok988323c2011-06-22 16:38:13 +0900183 ITextServicesSessionListener tsListener, ISpellCheckerSessionListener scListener) {
184 if (!mSystemReady) {
185 return;
186 }
satok5b9b5a92011-08-02 12:24:44 +0900187 if (TextUtils.isEmpty(sciId) || tsListener == null || scListener == null) {
satok988323c2011-06-22 16:38:13 +0900188 Slog.e(TAG, "getSpellCheckerService: Invalid input.");
189 return;
190 }
satok988323c2011-06-22 16:38:13 +0900191 synchronized(mSpellCheckerMap) {
192 if (!mSpellCheckerMap.containsKey(sciId)) {
193 return;
194 }
satok5b9b5a92011-08-02 12:24:44 +0900195 final SpellCheckerInfo sci = mSpellCheckerMap.get(sciId);
satokdf5659d2011-07-29 18:38:21 +0900196 final int uid = Binder.getCallingUid();
satok988323c2011-06-22 16:38:13 +0900197 if (mSpellCheckerBindGroups.containsKey(sciId)) {
satok6be6d752011-07-28 20:40:38 +0900198 final SpellCheckerBindGroup bindGroup = mSpellCheckerBindGroups.get(sciId);
199 if (bindGroup != null) {
200 final InternalDeathRecipient recipient =
201 mSpellCheckerBindGroups.get(sciId).addListener(
satokdf5659d2011-07-29 18:38:21 +0900202 tsListener, locale, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900203 if (recipient == null) {
204 if (DBG) {
205 Slog.w(TAG, "Didn't create a death recipient.");
206 }
207 return;
208 }
209 if (bindGroup.mSpellChecker == null & bindGroup.mConnected) {
210 Slog.e(TAG, "The state of the spell checker bind group is illegal.");
211 bindGroup.removeAll();
212 } else if (bindGroup.mSpellChecker != null) {
213 if (DBG) {
satokdf5659d2011-07-29 18:38:21 +0900214 Slog.w(TAG, "Existing bind found. Return a spell checker session now. "
215 + "Listeners count = " + bindGroup.mListeners.size());
satok6be6d752011-07-28 20:40:38 +0900216 }
217 try {
218 final ISpellCheckerSession session =
219 bindGroup.mSpellChecker.getISpellCheckerSession(
220 recipient.mScLocale, recipient.mScListener);
satokdf5659d2011-07-29 18:38:21 +0900221 if (session != null) {
222 tsListener.onServiceConnected(session);
223 return;
224 } else {
225 if (DBG) {
226 Slog.w(TAG, "Existing bind already expired. ");
227 }
228 bindGroup.removeAll();
229 }
satok6be6d752011-07-28 20:40:38 +0900230 } catch (RemoteException e) {
231 Slog.e(TAG, "Exception in getting spell checker session: " + e);
232 bindGroup.removeAll();
233 }
234 }
235 }
satok988323c2011-06-22 16:38:13 +0900236 }
satok6be6d752011-07-28 20:40:38 +0900237 final long ident = Binder.clearCallingIdentity();
238 try {
satok5b9b5a92011-08-02 12:24:44 +0900239 startSpellCheckerServiceInnerLocked(sci, locale, tsListener, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900240 } finally {
241 Binder.restoreCallingIdentity(ident);
satok988323c2011-06-22 16:38:13 +0900242 }
satok988323c2011-06-22 16:38:13 +0900243 }
244 return;
245 }
246
satok6be6d752011-07-28 20:40:38 +0900247 private void startSpellCheckerServiceInnerLocked(SpellCheckerInfo info, String locale,
satokdf5659d2011-07-29 18:38:21 +0900248 ITextServicesSessionListener tsListener, ISpellCheckerSessionListener scListener,
249 int uid) {
250 if (DBG) {
251 Slog.w(TAG, "Start spell checker session inner locked.");
252 }
satok6be6d752011-07-28 20:40:38 +0900253 final String sciId = info.getId();
254 final InternalServiceConnection connection = new InternalServiceConnection(
255 sciId, locale, scListener);
256 final Intent serviceIntent = new Intent(SpellCheckerService.SERVICE_INTERFACE);
257 serviceIntent.setComponent(info.getComponent());
258 if (DBG) {
259 Slog.w(TAG, "bind service: " + info.getId());
260 }
261 if (!mContext.bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE)) {
262 Slog.e(TAG, "Failed to get a spell checker service.");
263 return;
264 }
265 final SpellCheckerBindGroup group = new SpellCheckerBindGroup(
satokdf5659d2011-07-29 18:38:21 +0900266 connection, tsListener, locale, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900267 mSpellCheckerBindGroups.put(sciId, group);
268 }
269
satok988323c2011-06-22 16:38:13 +0900270 @Override
satok562ab582011-07-25 10:12:21 +0900271 public SpellCheckerInfo[] getEnabledSpellCheckers() {
satokda317ef2011-07-26 08:02:45 +0900272 if (DBG) {
273 Slog.d(TAG, "getEnabledSpellCheckers: " + mSpellCheckerList.size());
274 for (int i = 0; i < mSpellCheckerList.size(); ++i) {
275 Slog.d(TAG, "EnabledSpellCheckers: " + mSpellCheckerList.get(i).getPackageName());
276 }
277 }
satok562ab582011-07-25 10:12:21 +0900278 return mSpellCheckerList.toArray(new SpellCheckerInfo[mSpellCheckerList.size()]);
279 }
280
281 @Override
satok988323c2011-06-22 16:38:13 +0900282 public void finishSpellCheckerService(ISpellCheckerSessionListener listener) {
satokda317ef2011-07-26 08:02:45 +0900283 if (DBG) {
284 Slog.d(TAG, "FinishSpellCheckerService");
285 }
satok988323c2011-06-22 16:38:13 +0900286 synchronized(mSpellCheckerMap) {
287 for (SpellCheckerBindGroup group : mSpellCheckerBindGroups.values()) {
288 if (group == null) continue;
289 group.removeListener(listener);
290 }
291 }
292 }
293
satokdf5659d2011-07-29 18:38:21 +0900294 @Override
satok5b9b5a92011-08-02 12:24:44 +0900295 public void setCurrentSpellChecker(String sciId) {
satokdf5659d2011-07-29 18:38:21 +0900296 synchronized(mSpellCheckerMap) {
297 if (mContext.checkCallingOrSelfPermission(
298 android.Manifest.permission.WRITE_SECURE_SETTINGS)
299 != PackageManager.PERMISSION_GRANTED) {
300 throw new SecurityException(
301 "Requires permission "
302 + android.Manifest.permission.WRITE_SECURE_SETTINGS);
303 }
satok5b9b5a92011-08-02 12:24:44 +0900304 setCurrentSpellCheckerLocked(sciId);
satokdf5659d2011-07-29 18:38:21 +0900305 }
306 }
307
satok5b9b5a92011-08-02 12:24:44 +0900308 private void setCurrentSpellCheckerLocked(String sciId) {
satok562ab582011-07-25 10:12:21 +0900309 if (DBG) {
satok5b9b5a92011-08-02 12:24:44 +0900310 Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
satok562ab582011-07-25 10:12:21 +0900311 }
satok5b9b5a92011-08-02 12:24:44 +0900312 if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId)) return;
satokdf5659d2011-07-29 18:38:21 +0900313 final long ident = Binder.clearCallingIdentity();
314 try {
315 Settings.Secure.putString(mContext.getContentResolver(),
satok5b9b5a92011-08-02 12:24:44 +0900316 Settings.Secure.SPELL_CHECKER_SERVICE, sciId);
satokdf5659d2011-07-29 18:38:21 +0900317 } finally {
318 Binder.restoreCallingIdentity(ident);
319 }
satok988323c2011-06-22 16:38:13 +0900320 }
321
322 // SpellCheckerBindGroup contains active text service session listeners.
323 // If there are no listeners anymore, the SpellCheckerBindGroup instance will be removed from
324 // mSpellCheckerBindGroups
325 private class SpellCheckerBindGroup {
satokdf5659d2011-07-29 18:38:21 +0900326 private final String TAG = SpellCheckerBindGroup.class.getSimpleName();
satok6be6d752011-07-28 20:40:38 +0900327 private final InternalServiceConnection mInternalConnection;
328 private final ArrayList<InternalDeathRecipient> mListeners =
satok988323c2011-06-22 16:38:13 +0900329 new ArrayList<InternalDeathRecipient>();
satok6be6d752011-07-28 20:40:38 +0900330 public ISpellCheckerService mSpellChecker;
331 public boolean mConnected;
satok988323c2011-06-22 16:38:13 +0900332
333 public SpellCheckerBindGroup(InternalServiceConnection connection,
334 ITextServicesSessionListener listener, String locale,
satokdf5659d2011-07-29 18:38:21 +0900335 ISpellCheckerSessionListener scListener, int uid) {
satok988323c2011-06-22 16:38:13 +0900336 mInternalConnection = connection;
satok6be6d752011-07-28 20:40:38 +0900337 mConnected = false;
satokdf5659d2011-07-29 18:38:21 +0900338 addListener(listener, locale, scListener, uid);
satok988323c2011-06-22 16:38:13 +0900339 }
340
341 public void onServiceConnected(ISpellCheckerService spellChecker) {
satokda317ef2011-07-26 08:02:45 +0900342 if (DBG) {
343 Slog.d(TAG, "onServiceConnected");
344 }
satok988323c2011-06-22 16:38:13 +0900345 synchronized(mSpellCheckerMap) {
346 for (InternalDeathRecipient listener : mListeners) {
347 try {
348 final ISpellCheckerSession session = spellChecker.getISpellCheckerSession(
349 listener.mScLocale, listener.mScListener);
350 listener.mTsListener.onServiceConnected(session);
351 } catch (RemoteException e) {
satokdf5659d2011-07-29 18:38:21 +0900352 Slog.e(TAG, "Exception in getting the spell checker session: " + e);
satok6be6d752011-07-28 20:40:38 +0900353 removeAll();
354 return;
satok988323c2011-06-22 16:38:13 +0900355 }
356 }
satok6be6d752011-07-28 20:40:38 +0900357 mSpellChecker = spellChecker;
358 mConnected = true;
satok988323c2011-06-22 16:38:13 +0900359 }
360 }
361
satok6be6d752011-07-28 20:40:38 +0900362 public InternalDeathRecipient addListener(ITextServicesSessionListener tsListener,
satokdf5659d2011-07-29 18:38:21 +0900363 String locale, ISpellCheckerSessionListener scListener, int uid) {
satokda317ef2011-07-26 08:02:45 +0900364 if (DBG) {
365 Slog.d(TAG, "addListener: " + locale);
366 }
satok6be6d752011-07-28 20:40:38 +0900367 InternalDeathRecipient recipient = null;
satok988323c2011-06-22 16:38:13 +0900368 synchronized(mSpellCheckerMap) {
369 try {
370 final int size = mListeners.size();
371 for (int i = 0; i < size; ++i) {
372 if (mListeners.get(i).hasSpellCheckerListener(scListener)) {
373 // do not add the lister if the group already contains this.
satok6be6d752011-07-28 20:40:38 +0900374 return null;
satok988323c2011-06-22 16:38:13 +0900375 }
376 }
satok6be6d752011-07-28 20:40:38 +0900377 recipient = new InternalDeathRecipient(
satokdf5659d2011-07-29 18:38:21 +0900378 this, tsListener, locale, scListener, uid);
satok988323c2011-06-22 16:38:13 +0900379 scListener.asBinder().linkToDeath(recipient, 0);
satokdf5659d2011-07-29 18:38:21 +0900380 mListeners.add(recipient);
satok988323c2011-06-22 16:38:13 +0900381 } catch(RemoteException e) {
382 // do nothing
383 }
384 cleanLocked();
385 }
satok6be6d752011-07-28 20:40:38 +0900386 return recipient;
satok988323c2011-06-22 16:38:13 +0900387 }
388
389 public void removeListener(ISpellCheckerSessionListener listener) {
satokda317ef2011-07-26 08:02:45 +0900390 if (DBG) {
satokdf5659d2011-07-29 18:38:21 +0900391 Slog.w(TAG, "remove listener: " + listener.hashCode());
satokda317ef2011-07-26 08:02:45 +0900392 }
satok988323c2011-06-22 16:38:13 +0900393 synchronized(mSpellCheckerMap) {
394 final int size = mListeners.size();
395 final ArrayList<InternalDeathRecipient> removeList =
396 new ArrayList<InternalDeathRecipient>();
397 for (int i = 0; i < size; ++i) {
398 final InternalDeathRecipient tempRecipient = mListeners.get(i);
399 if(tempRecipient.hasSpellCheckerListener(listener)) {
satokdf5659d2011-07-29 18:38:21 +0900400 if (DBG) {
401 Slog.w(TAG, "found existing listener.");
402 }
satok988323c2011-06-22 16:38:13 +0900403 removeList.add(tempRecipient);
404 }
405 }
406 final int removeSize = removeList.size();
407 for (int i = 0; i < removeSize; ++i) {
satokdf5659d2011-07-29 18:38:21 +0900408 if (DBG) {
409 Slog.w(TAG, "Remove " + removeList.get(i));
410 }
satok988323c2011-06-22 16:38:13 +0900411 mListeners.remove(removeList.get(i));
412 }
413 cleanLocked();
414 }
415 }
416
417 private void cleanLocked() {
satokda317ef2011-07-26 08:02:45 +0900418 if (DBG) {
419 Slog.d(TAG, "cleanLocked");
420 }
satok988323c2011-06-22 16:38:13 +0900421 if (mListeners.isEmpty()) {
satok6be6d752011-07-28 20:40:38 +0900422 if (mSpellCheckerBindGroups.containsKey(this)) {
423 mSpellCheckerBindGroups.remove(this);
424 }
satok988323c2011-06-22 16:38:13 +0900425 // Unbind service when there is no active clients.
426 mContext.unbindService(mInternalConnection);
427 }
428 }
satok6be6d752011-07-28 20:40:38 +0900429
430 public void removeAll() {
431 Slog.e(TAG, "Remove the spell checker bind unexpectedly.");
satokdf5659d2011-07-29 18:38:21 +0900432 synchronized(mSpellCheckerMap) {
433 mListeners.clear();
434 cleanLocked();
435 }
satok6be6d752011-07-28 20:40:38 +0900436 }
satok988323c2011-06-22 16:38:13 +0900437 }
438
439 private class InternalServiceConnection implements ServiceConnection {
440 private final ISpellCheckerSessionListener mListener;
441 private final String mSciId;
442 private final String mLocale;
443 public InternalServiceConnection(
444 String id, String locale, ISpellCheckerSessionListener listener) {
445 mSciId = id;
446 mLocale = locale;
447 mListener = listener;
448 }
449
450 @Override
451 public void onServiceConnected(ComponentName name, IBinder service) {
452 synchronized(mSpellCheckerMap) {
satok6be6d752011-07-28 20:40:38 +0900453 if (DBG) {
454 Slog.w(TAG, "onServiceConnected: " + name);
455 }
satok988323c2011-06-22 16:38:13 +0900456 ISpellCheckerService spellChecker = ISpellCheckerService.Stub.asInterface(service);
457 final SpellCheckerBindGroup group = mSpellCheckerBindGroups.get(mSciId);
458 if (group != null) {
459 group.onServiceConnected(spellChecker);
460 }
461 }
462 }
463
464 @Override
465 public void onServiceDisconnected(ComponentName name) {
466 mSpellCheckerBindGroups.remove(mSciId);
467 }
468 }
469
470 private class InternalDeathRecipient implements IBinder.DeathRecipient {
471 public final ITextServicesSessionListener mTsListener;
472 public final ISpellCheckerSessionListener mScListener;
473 public final String mScLocale;
474 private final SpellCheckerBindGroup mGroup;
satokdf5659d2011-07-29 18:38:21 +0900475 public final int mUid;
satok988323c2011-06-22 16:38:13 +0900476 public InternalDeathRecipient(SpellCheckerBindGroup group,
477 ITextServicesSessionListener tsListener, String scLocale,
satokdf5659d2011-07-29 18:38:21 +0900478 ISpellCheckerSessionListener scListener, int uid) {
satok988323c2011-06-22 16:38:13 +0900479 mTsListener = tsListener;
480 mScListener = scListener;
481 mScLocale = scLocale;
482 mGroup = group;
satokdf5659d2011-07-29 18:38:21 +0900483 mUid = uid;
satok988323c2011-06-22 16:38:13 +0900484 }
485
486 public boolean hasSpellCheckerListener(ISpellCheckerSessionListener listener) {
satokdf5659d2011-07-29 18:38:21 +0900487 return listener.asBinder().equals(mScListener.asBinder());
satok988323c2011-06-22 16:38:13 +0900488 }
489
490 @Override
491 public void binderDied() {
492 mGroup.removeListener(mScListener);
493 }
494 }
495}