blob: 837778e4d8d62b732a2da001ee26ba0a692ff2da [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.
83 setCurrentSpellCheckerLocked(sci);
84 }
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);
98 if (change == PACKAGE_PERMANENT_CHANGE || change == PACKAGE_TEMPORARY_CHANGE) {
99 // Package disappearing
satokdf5659d2011-07-29 18:38:21 +0900100 setCurrentSpellCheckerLocked(findAvailSpellCheckerLocked(null, packageName));
satok988323c2011-06-22 16:38:13 +0900101 } else if (isPackageModified(packageName)) {
102 // Package modified
satokdf5659d2011-07-29 18:38:21 +0900103 setCurrentSpellCheckerLocked(findAvailSpellCheckerLocked(null, packageName));
satok988323c2011-06-22 16:38:13 +0900104 }
105 }
106 }
107 }
108
109 private static void buildSpellCheckerMapLocked(Context context,
110 ArrayList<SpellCheckerInfo> list, HashMap<String, SpellCheckerInfo> map) {
111 list.clear();
112 map.clear();
113 final PackageManager pm = context.getPackageManager();
114 List<ResolveInfo> services = pm.queryIntentServices(
115 new Intent(SpellCheckerService.SERVICE_INTERFACE), PackageManager.GET_META_DATA);
116 final int N = services.size();
117 for (int i = 0; i < N; ++i) {
118 final ResolveInfo ri = services.get(i);
119 final ServiceInfo si = ri.serviceInfo;
120 final ComponentName compName = new ComponentName(si.packageName, si.name);
121 if (!android.Manifest.permission.BIND_TEXT_SERVICE.equals(si.permission)) {
122 Slog.w(TAG, "Skipping text service " + compName
123 + ": it does not require the permission "
124 + android.Manifest.permission.BIND_TEXT_SERVICE);
125 continue;
126 }
127 if (DBG) Slog.d(TAG, "Add: " + compName);
128 final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri);
129 list.add(sci);
130 map.put(sci.getId(), sci);
131 }
satokda317ef2011-07-26 08:02:45 +0900132 if (DBG) {
133 Slog.d(TAG, "buildSpellCheckerMapLocked: " + list.size() + "," + map.size());
134 }
satok988323c2011-06-22 16:38:13 +0900135 }
136
137 // TODO: find an appropriate spell checker for specified locale
138 private SpellCheckerInfo findAvailSpellCheckerLocked(String locale, String prefPackage) {
139 final int spellCheckersCount = mSpellCheckerList.size();
140 if (spellCheckersCount == 0) {
141 Slog.w(TAG, "no available spell checker services found");
142 return null;
143 }
144 if (prefPackage != null) {
145 for (int i = 0; i < spellCheckersCount; ++i) {
146 final SpellCheckerInfo sci = mSpellCheckerList.get(i);
147 if (prefPackage.equals(sci.getPackageName())) {
satokda317ef2011-07-26 08:02:45 +0900148 if (DBG) {
149 Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
150 }
satok988323c2011-06-22 16:38:13 +0900151 return sci;
152 }
153 }
154 }
155 if (spellCheckersCount > 1) {
156 Slog.w(TAG, "more than one spell checker service found, picking first");
157 }
158 return mSpellCheckerList.get(0);
159 }
160
161 // TODO: Save SpellCheckerService by supported languages. Currently only one spell
162 // checker is saved.
163 @Override
164 public SpellCheckerInfo getCurrentSpellChecker(String locale) {
165 synchronized (mSpellCheckerMap) {
satokda317ef2011-07-26 08:02:45 +0900166 String curSpellCheckerId =
satok988323c2011-06-22 16:38:13 +0900167 Settings.Secure.getString(mContext.getContentResolver(),
168 Settings.Secure.SPELL_CHECKER_SERVICE);
satok562ab582011-07-25 10:12:21 +0900169 if (DBG) {
170 Slog.w(TAG, "getCurrentSpellChecker: " + curSpellCheckerId);
171 }
satok988323c2011-06-22 16:38:13 +0900172 if (TextUtils.isEmpty(curSpellCheckerId)) {
satokdf5659d2011-07-29 18:38:21 +0900173 return null;
satok988323c2011-06-22 16:38:13 +0900174 }
175 return mSpellCheckerMap.get(curSpellCheckerId);
176 }
177 }
178
179 @Override
180 public void getSpellCheckerService(SpellCheckerInfo info, String locale,
181 ITextServicesSessionListener tsListener, ISpellCheckerSessionListener scListener) {
182 if (!mSystemReady) {
183 return;
184 }
satok6be6d752011-07-28 20:40:38 +0900185 if (info == null || tsListener == null || scListener == null) {
satok988323c2011-06-22 16:38:13 +0900186 Slog.e(TAG, "getSpellCheckerService: Invalid input.");
187 return;
188 }
189 final String sciId = info.getId();
190 synchronized(mSpellCheckerMap) {
191 if (!mSpellCheckerMap.containsKey(sciId)) {
192 return;
193 }
satokdf5659d2011-07-29 18:38:21 +0900194 final int uid = Binder.getCallingUid();
satok988323c2011-06-22 16:38:13 +0900195 if (mSpellCheckerBindGroups.containsKey(sciId)) {
satok6be6d752011-07-28 20:40:38 +0900196 final SpellCheckerBindGroup bindGroup = mSpellCheckerBindGroups.get(sciId);
197 if (bindGroup != null) {
198 final InternalDeathRecipient recipient =
199 mSpellCheckerBindGroups.get(sciId).addListener(
satokdf5659d2011-07-29 18:38:21 +0900200 tsListener, locale, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900201 if (recipient == null) {
202 if (DBG) {
203 Slog.w(TAG, "Didn't create a death recipient.");
204 }
205 return;
206 }
207 if (bindGroup.mSpellChecker == null & bindGroup.mConnected) {
208 Slog.e(TAG, "The state of the spell checker bind group is illegal.");
209 bindGroup.removeAll();
210 } else if (bindGroup.mSpellChecker != null) {
211 if (DBG) {
satokdf5659d2011-07-29 18:38:21 +0900212 Slog.w(TAG, "Existing bind found. Return a spell checker session now. "
213 + "Listeners count = " + bindGroup.mListeners.size());
satok6be6d752011-07-28 20:40:38 +0900214 }
215 try {
216 final ISpellCheckerSession session =
217 bindGroup.mSpellChecker.getISpellCheckerSession(
218 recipient.mScLocale, recipient.mScListener);
satokdf5659d2011-07-29 18:38:21 +0900219 if (session != null) {
220 tsListener.onServiceConnected(session);
221 return;
222 } else {
223 if (DBG) {
224 Slog.w(TAG, "Existing bind already expired. ");
225 }
226 bindGroup.removeAll();
227 }
satok6be6d752011-07-28 20:40:38 +0900228 } catch (RemoteException e) {
229 Slog.e(TAG, "Exception in getting spell checker session: " + e);
230 bindGroup.removeAll();
231 }
232 }
233 }
satok988323c2011-06-22 16:38:13 +0900234 }
satok6be6d752011-07-28 20:40:38 +0900235 final long ident = Binder.clearCallingIdentity();
236 try {
satokdf5659d2011-07-29 18:38:21 +0900237 startSpellCheckerServiceInnerLocked(info, locale, tsListener, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900238 } finally {
239 Binder.restoreCallingIdentity(ident);
satok988323c2011-06-22 16:38:13 +0900240 }
satok988323c2011-06-22 16:38:13 +0900241 }
242 return;
243 }
244
satok6be6d752011-07-28 20:40:38 +0900245 private void startSpellCheckerServiceInnerLocked(SpellCheckerInfo info, String locale,
satokdf5659d2011-07-29 18:38:21 +0900246 ITextServicesSessionListener tsListener, ISpellCheckerSessionListener scListener,
247 int uid) {
248 if (DBG) {
249 Slog.w(TAG, "Start spell checker session inner locked.");
250 }
satok6be6d752011-07-28 20:40:38 +0900251 final String sciId = info.getId();
252 final InternalServiceConnection connection = new InternalServiceConnection(
253 sciId, locale, scListener);
254 final Intent serviceIntent = new Intent(SpellCheckerService.SERVICE_INTERFACE);
255 serviceIntent.setComponent(info.getComponent());
256 if (DBG) {
257 Slog.w(TAG, "bind service: " + info.getId());
258 }
259 if (!mContext.bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE)) {
260 Slog.e(TAG, "Failed to get a spell checker service.");
261 return;
262 }
263 final SpellCheckerBindGroup group = new SpellCheckerBindGroup(
satokdf5659d2011-07-29 18:38:21 +0900264 connection, tsListener, locale, scListener, uid);
satok6be6d752011-07-28 20:40:38 +0900265 mSpellCheckerBindGroups.put(sciId, group);
266 }
267
satok988323c2011-06-22 16:38:13 +0900268 @Override
satok562ab582011-07-25 10:12:21 +0900269 public SpellCheckerInfo[] getEnabledSpellCheckers() {
satokda317ef2011-07-26 08:02:45 +0900270 if (DBG) {
271 Slog.d(TAG, "getEnabledSpellCheckers: " + mSpellCheckerList.size());
272 for (int i = 0; i < mSpellCheckerList.size(); ++i) {
273 Slog.d(TAG, "EnabledSpellCheckers: " + mSpellCheckerList.get(i).getPackageName());
274 }
275 }
satok562ab582011-07-25 10:12:21 +0900276 return mSpellCheckerList.toArray(new SpellCheckerInfo[mSpellCheckerList.size()]);
277 }
278
279 @Override
satok988323c2011-06-22 16:38:13 +0900280 public void finishSpellCheckerService(ISpellCheckerSessionListener listener) {
satokda317ef2011-07-26 08:02:45 +0900281 if (DBG) {
282 Slog.d(TAG, "FinishSpellCheckerService");
283 }
satok988323c2011-06-22 16:38:13 +0900284 synchronized(mSpellCheckerMap) {
285 for (SpellCheckerBindGroup group : mSpellCheckerBindGroups.values()) {
286 if (group == null) continue;
287 group.removeListener(listener);
288 }
289 }
290 }
291
satokdf5659d2011-07-29 18:38:21 +0900292 @Override
293 public void setCurrentSpellChecker(SpellCheckerInfo sci) {
294 synchronized(mSpellCheckerMap) {
295 if (mContext.checkCallingOrSelfPermission(
296 android.Manifest.permission.WRITE_SECURE_SETTINGS)
297 != PackageManager.PERMISSION_GRANTED) {
298 throw new SecurityException(
299 "Requires permission "
300 + android.Manifest.permission.WRITE_SECURE_SETTINGS);
301 }
302 setCurrentSpellCheckerLocked(sci);
303 }
304 }
305
306 private void setCurrentSpellCheckerLocked(SpellCheckerInfo sci) {
satok562ab582011-07-25 10:12:21 +0900307 if (DBG) {
308 Slog.w(TAG, "setCurrentSpellChecker: " + sci.getId());
309 }
satokdf5659d2011-07-29 18:38:21 +0900310 if (sci == null || !mSpellCheckerMap.containsKey(sci.getId())) return;
311 final long ident = Binder.clearCallingIdentity();
312 try {
313 Settings.Secure.putString(mContext.getContentResolver(),
314 Settings.Secure.SPELL_CHECKER_SERVICE, sci == null ? "" : sci.getId());
315 } finally {
316 Binder.restoreCallingIdentity(ident);
317 }
satok988323c2011-06-22 16:38:13 +0900318 }
319
320 // SpellCheckerBindGroup contains active text service session listeners.
321 // If there are no listeners anymore, the SpellCheckerBindGroup instance will be removed from
322 // mSpellCheckerBindGroups
323 private class SpellCheckerBindGroup {
satokdf5659d2011-07-29 18:38:21 +0900324 private final String TAG = SpellCheckerBindGroup.class.getSimpleName();
satok6be6d752011-07-28 20:40:38 +0900325 private final InternalServiceConnection mInternalConnection;
326 private final ArrayList<InternalDeathRecipient> mListeners =
satok988323c2011-06-22 16:38:13 +0900327 new ArrayList<InternalDeathRecipient>();
satok6be6d752011-07-28 20:40:38 +0900328 public ISpellCheckerService mSpellChecker;
329 public boolean mConnected;
satok988323c2011-06-22 16:38:13 +0900330
331 public SpellCheckerBindGroup(InternalServiceConnection connection,
332 ITextServicesSessionListener listener, String locale,
satokdf5659d2011-07-29 18:38:21 +0900333 ISpellCheckerSessionListener scListener, int uid) {
satok988323c2011-06-22 16:38:13 +0900334 mInternalConnection = connection;
satok6be6d752011-07-28 20:40:38 +0900335 mConnected = false;
satokdf5659d2011-07-29 18:38:21 +0900336 addListener(listener, locale, scListener, uid);
satok988323c2011-06-22 16:38:13 +0900337 }
338
339 public void onServiceConnected(ISpellCheckerService spellChecker) {
satokda317ef2011-07-26 08:02:45 +0900340 if (DBG) {
341 Slog.d(TAG, "onServiceConnected");
342 }
satok988323c2011-06-22 16:38:13 +0900343 synchronized(mSpellCheckerMap) {
344 for (InternalDeathRecipient listener : mListeners) {
345 try {
346 final ISpellCheckerSession session = spellChecker.getISpellCheckerSession(
347 listener.mScLocale, listener.mScListener);
348 listener.mTsListener.onServiceConnected(session);
349 } catch (RemoteException e) {
satokdf5659d2011-07-29 18:38:21 +0900350 Slog.e(TAG, "Exception in getting the spell checker session: " + e);
satok6be6d752011-07-28 20:40:38 +0900351 removeAll();
352 return;
satok988323c2011-06-22 16:38:13 +0900353 }
354 }
satok6be6d752011-07-28 20:40:38 +0900355 mSpellChecker = spellChecker;
356 mConnected = true;
satok988323c2011-06-22 16:38:13 +0900357 }
358 }
359
satok6be6d752011-07-28 20:40:38 +0900360 public InternalDeathRecipient addListener(ITextServicesSessionListener tsListener,
satokdf5659d2011-07-29 18:38:21 +0900361 String locale, ISpellCheckerSessionListener scListener, int uid) {
satokda317ef2011-07-26 08:02:45 +0900362 if (DBG) {
363 Slog.d(TAG, "addListener: " + locale);
364 }
satok6be6d752011-07-28 20:40:38 +0900365 InternalDeathRecipient recipient = null;
satok988323c2011-06-22 16:38:13 +0900366 synchronized(mSpellCheckerMap) {
367 try {
368 final int size = mListeners.size();
369 for (int i = 0; i < size; ++i) {
370 if (mListeners.get(i).hasSpellCheckerListener(scListener)) {
371 // do not add the lister if the group already contains this.
satok6be6d752011-07-28 20:40:38 +0900372 return null;
satok988323c2011-06-22 16:38:13 +0900373 }
374 }
satok6be6d752011-07-28 20:40:38 +0900375 recipient = new InternalDeathRecipient(
satokdf5659d2011-07-29 18:38:21 +0900376 this, tsListener, locale, scListener, uid);
satok988323c2011-06-22 16:38:13 +0900377 scListener.asBinder().linkToDeath(recipient, 0);
satokdf5659d2011-07-29 18:38:21 +0900378 mListeners.add(recipient);
satok988323c2011-06-22 16:38:13 +0900379 } catch(RemoteException e) {
380 // do nothing
381 }
382 cleanLocked();
383 }
satok6be6d752011-07-28 20:40:38 +0900384 return recipient;
satok988323c2011-06-22 16:38:13 +0900385 }
386
387 public void removeListener(ISpellCheckerSessionListener listener) {
satokda317ef2011-07-26 08:02:45 +0900388 if (DBG) {
satokdf5659d2011-07-29 18:38:21 +0900389 Slog.w(TAG, "remove listener: " + listener.hashCode());
satokda317ef2011-07-26 08:02:45 +0900390 }
satok988323c2011-06-22 16:38:13 +0900391 synchronized(mSpellCheckerMap) {
392 final int size = mListeners.size();
393 final ArrayList<InternalDeathRecipient> removeList =
394 new ArrayList<InternalDeathRecipient>();
395 for (int i = 0; i < size; ++i) {
396 final InternalDeathRecipient tempRecipient = mListeners.get(i);
397 if(tempRecipient.hasSpellCheckerListener(listener)) {
satokdf5659d2011-07-29 18:38:21 +0900398 if (DBG) {
399 Slog.w(TAG, "found existing listener.");
400 }
satok988323c2011-06-22 16:38:13 +0900401 removeList.add(tempRecipient);
402 }
403 }
404 final int removeSize = removeList.size();
405 for (int i = 0; i < removeSize; ++i) {
satokdf5659d2011-07-29 18:38:21 +0900406 if (DBG) {
407 Slog.w(TAG, "Remove " + removeList.get(i));
408 }
satok988323c2011-06-22 16:38:13 +0900409 mListeners.remove(removeList.get(i));
410 }
411 cleanLocked();
412 }
413 }
414
415 private void cleanLocked() {
satokda317ef2011-07-26 08:02:45 +0900416 if (DBG) {
417 Slog.d(TAG, "cleanLocked");
418 }
satok988323c2011-06-22 16:38:13 +0900419 if (mListeners.isEmpty()) {
satok6be6d752011-07-28 20:40:38 +0900420 if (mSpellCheckerBindGroups.containsKey(this)) {
421 mSpellCheckerBindGroups.remove(this);
422 }
satok988323c2011-06-22 16:38:13 +0900423 // Unbind service when there is no active clients.
424 mContext.unbindService(mInternalConnection);
425 }
426 }
satok6be6d752011-07-28 20:40:38 +0900427
428 public void removeAll() {
429 Slog.e(TAG, "Remove the spell checker bind unexpectedly.");
satokdf5659d2011-07-29 18:38:21 +0900430 synchronized(mSpellCheckerMap) {
431 mListeners.clear();
432 cleanLocked();
433 }
satok6be6d752011-07-28 20:40:38 +0900434 }
satok988323c2011-06-22 16:38:13 +0900435 }
436
437 private class InternalServiceConnection implements ServiceConnection {
438 private final ISpellCheckerSessionListener mListener;
439 private final String mSciId;
440 private final String mLocale;
441 public InternalServiceConnection(
442 String id, String locale, ISpellCheckerSessionListener listener) {
443 mSciId = id;
444 mLocale = locale;
445 mListener = listener;
446 }
447
448 @Override
449 public void onServiceConnected(ComponentName name, IBinder service) {
450 synchronized(mSpellCheckerMap) {
satok6be6d752011-07-28 20:40:38 +0900451 if (DBG) {
452 Slog.w(TAG, "onServiceConnected: " + name);
453 }
satok988323c2011-06-22 16:38:13 +0900454 ISpellCheckerService spellChecker = ISpellCheckerService.Stub.asInterface(service);
455 final SpellCheckerBindGroup group = mSpellCheckerBindGroups.get(mSciId);
456 if (group != null) {
457 group.onServiceConnected(spellChecker);
458 }
459 }
460 }
461
462 @Override
463 public void onServiceDisconnected(ComponentName name) {
464 mSpellCheckerBindGroups.remove(mSciId);
465 }
466 }
467
468 private class InternalDeathRecipient implements IBinder.DeathRecipient {
469 public final ITextServicesSessionListener mTsListener;
470 public final ISpellCheckerSessionListener mScListener;
471 public final String mScLocale;
472 private final SpellCheckerBindGroup mGroup;
satokdf5659d2011-07-29 18:38:21 +0900473 public final int mUid;
satok988323c2011-06-22 16:38:13 +0900474 public InternalDeathRecipient(SpellCheckerBindGroup group,
475 ITextServicesSessionListener tsListener, String scLocale,
satokdf5659d2011-07-29 18:38:21 +0900476 ISpellCheckerSessionListener scListener, int uid) {
satok988323c2011-06-22 16:38:13 +0900477 mTsListener = tsListener;
478 mScListener = scListener;
479 mScLocale = scLocale;
480 mGroup = group;
satokdf5659d2011-07-29 18:38:21 +0900481 mUid = uid;
satok988323c2011-06-22 16:38:13 +0900482 }
483
484 public boolean hasSpellCheckerListener(ISpellCheckerSessionListener listener) {
satokdf5659d2011-07-29 18:38:21 +0900485 return listener.asBinder().equals(mScListener.asBinder());
satok988323c2011-06-22 16:38:13 +0900486 }
487
488 @Override
489 public void binderDied() {
490 mGroup.removeListener(mScListener);
491 }
492 }
493}