blob: 1d4a6da5413a2b38e2bfbd8396ae448519fd9ea9 [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/**
2 * Copyright (C) 2007 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16
17package com.android.settings;
18
Amith Yamasaniae697552011-09-27 11:33:17 -070019import android.app.ActivityManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080020import android.content.Context;
21import android.content.Intent;
22import android.content.pm.ApplicationInfo;
23import android.content.pm.PackageManager;
Amith Yamasani02cf71a2010-09-21 15:48:52 -070024import android.content.pm.PackageManager.NameNotFoundException;
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -070025import android.content.pm.ResolveInfo;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070026import android.content.pm.UserInfo;
Anders Hammar1b2dd9032010-04-08 10:03:50 +020027import android.content.res.Resources;
28import android.content.res.Resources.NotFoundException;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070029import android.database.Cursor;
Anders Hammar1b2dd9032010-04-08 10:03:50 +020030import android.graphics.drawable.Drawable;
Amith Yamasanic06d4c42011-02-25 14:35:20 -080031import android.net.ConnectivityManager;
32import android.net.LinkProperties;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070033import android.net.Uri;
Amith Yamasania4379d62011-07-22 10:34:58 -070034import android.os.BatteryManager;
Anders Hammar1b2dd9032010-04-08 10:03:50 +020035import android.os.Bundle;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070036import android.os.ParcelFileDescriptor;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070037import android.os.UserHandle;
38import android.os.UserManager;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080039import android.preference.Preference;
Amith Yamasani02cf71a2010-09-21 15:48:52 -070040import android.preference.PreferenceActivity.Header;
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -070041import android.preference.PreferenceFrameLayout;
42import android.preference.PreferenceGroup;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070043import android.provider.ContactsContract.CommonDataKinds.Phone;
44import android.provider.ContactsContract.Contacts;
45import android.provider.ContactsContract.Profile;
Amith Yamasani60133dd2010-09-11 14:17:31 -070046import android.telephony.TelephonyManager;
Anders Hammar1b2dd9032010-04-08 10:03:50 +020047import android.text.TextUtils;
Amith Yamasaniae47ef42012-09-16 17:53:35 -070048import android.util.Log;
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -070049import android.view.View;
50import android.view.ViewGroup;
51import android.widget.ListView;
52import android.widget.TabWidget;
Daisuke Miyakawaa2633d02010-09-15 20:09:12 -070053
Amith Yamasaniae47ef42012-09-16 17:53:35 -070054import com.android.settings.users.ProfileUpdateReceiver;
55
56import java.io.FileOutputStream;
57import java.io.IOException;
58import java.io.InputStream;
Amith Yamasanic06d4c42011-02-25 14:35:20 -080059import java.net.InetAddress;
60import java.util.Iterator;
Daisuke Miyakawaa2633d02010-09-15 20:09:12 -070061import java.util.List;
Jean Chalard71ad1f42011-05-12 15:06:16 +090062import java.util.Locale;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080063
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080064public class Utils {
65
66 /**
67 * Set the preference's title to the matching activity's label.
68 */
69 public static final int UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY = 1;
70
71 /**
Anders Hammar1b2dd9032010-04-08 10:03:50 +020072 * Name of the meta-data item that should be set in the AndroidManifest.xml
73 * to specify the icon that should be displayed for the preference.
74 */
75 private static final String META_DATA_PREFERENCE_ICON = "com.android.settings.icon";
76
77 /**
78 * Name of the meta-data item that should be set in the AndroidManifest.xml
79 * to specify the title that should be displayed for the preference.
80 */
81 private static final String META_DATA_PREFERENCE_TITLE = "com.android.settings.title";
82
83 /**
84 * Name of the meta-data item that should be set in the AndroidManifest.xml
85 * to specify the summary text that should be displayed for the preference.
86 */
87 private static final String META_DATA_PREFERENCE_SUMMARY = "com.android.settings.summary";
88
89 /**
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080090 * Finds a matching activity for a preference's intent. If a matching
91 * activity is not found, it will remove the preference.
Ying Wanga7188322010-01-04 18:45:10 -080092 *
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080093 * @param context The context.
94 * @param parentPreferenceGroup The preference group that contains the
95 * preference whose intent is being resolved.
96 * @param preferenceKey The key of the preference whose intent is being
97 * resolved.
98 * @param flags 0 or one or more of
99 * {@link #UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY}
100 * .
101 * @return Whether an activity was found. If false, the preference was
102 * removed.
103 */
104 public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
105 PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
Ying Wanga7188322010-01-04 18:45:10 -0800106
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800107 Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
108 if (preference == null) {
109 return false;
110 }
Ying Wanga7188322010-01-04 18:45:10 -0800111
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800112 Intent intent = preference.getIntent();
113 if (intent != null) {
114 // Find the activity that is in the system image
115 PackageManager pm = context.getPackageManager();
116 List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
117 int listSize = list.size();
118 for (int i = 0; i < listSize; i++) {
119 ResolveInfo resolveInfo = list.get(i);
120 if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
121 != 0) {
Ying Wanga7188322010-01-04 18:45:10 -0800122
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800123 // Replace the intent with this specific activity
124 preference.setIntent(new Intent().setClassName(
125 resolveInfo.activityInfo.packageName,
126 resolveInfo.activityInfo.name));
127
128 if ((flags & UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY) != 0) {
129 // Set the preference title to the activity's label
130 preference.setTitle(resolveInfo.loadLabel(pm));
131 }
Ying Wanga7188322010-01-04 18:45:10 -0800132
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800133 return true;
134 }
135 }
136 }
137
138 // Did not find a matching activity, so remove the preference
139 parentPreferenceGroup.removePreference(preference);
Ying Wanga7188322010-01-04 18:45:10 -0800140
Shuhrat Dehkanov7dc567a2012-04-23 01:59:56 +0900141 return false;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800142 }
Ying Wanga7188322010-01-04 18:45:10 -0800143
144 /**
Anders Hammar1b2dd9032010-04-08 10:03:50 +0200145 * Finds a matching activity for a preference's intent. If a matching
146 * activity is not found, it will remove the preference. The icon, title and
147 * summary of the preference will also be updated with the values retrieved
148 * from the activity's meta-data elements. If no meta-data elements are
149 * specified then the preference title will be set to match the label of the
150 * activity, an icon and summary text will not be displayed.
151 *
152 * @param context The context.
153 * @param parentPreferenceGroup The preference group that contains the
154 * preference whose intent is being resolved.
155 * @param preferenceKey The key of the preference whose intent is being
156 * resolved.
157 *
158 * @return Whether an activity was found. If false, the preference was
159 * removed.
160 *
161 * @see {@link #META_DATA_PREFERENCE_ICON}
162 * {@link #META_DATA_PREFERENCE_TITLE}
163 * {@link #META_DATA_PREFERENCE_SUMMARY}
164 */
165 public static boolean updatePreferenceToSpecificActivityFromMetaDataOrRemove(Context context,
166 PreferenceGroup parentPreferenceGroup, String preferenceKey) {
167
168 IconPreferenceScreen preference = (IconPreferenceScreen)parentPreferenceGroup
169 .findPreference(preferenceKey);
170 if (preference == null) {
171 return false;
172 }
173
174 Intent intent = preference.getIntent();
175 if (intent != null) {
176 // Find the activity that is in the system image
177 PackageManager pm = context.getPackageManager();
178 List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
179 int listSize = list.size();
180 for (int i = 0; i < listSize; i++) {
181 ResolveInfo resolveInfo = list.get(i);
182 if ((resolveInfo.activityInfo.applicationInfo.flags
183 & ApplicationInfo.FLAG_SYSTEM) != 0) {
184 Drawable icon = null;
185 String title = null;
186 String summary = null;
187
188 // Get the activity's meta-data
189 try {
190 Resources res = pm
191 .getResourcesForApplication(resolveInfo.activityInfo.packageName);
192 Bundle metaData = resolveInfo.activityInfo.metaData;
193
194 if (res != null && metaData != null) {
195 icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
196 title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
197 summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
198 }
199 } catch (NameNotFoundException e) {
200 // Ignore
201 } catch (NotFoundException e) {
202 // Ignore
203 }
204
205 // Set the preference title to the activity's label if no
206 // meta-data is found
207 if (TextUtils.isEmpty(title)) {
208 title = resolveInfo.loadLabel(pm).toString();
209 }
210
211 // Set icon, title and summary for the preference
212 preference.setIcon(icon);
213 preference.setTitle(title);
214 preference.setSummary(summary);
215
216 // Replace the intent with this specific activity
217 preference.setIntent(new Intent().setClassName(
218 resolveInfo.activityInfo.packageName,
219 resolveInfo.activityInfo.name));
220
221 return true;
222 }
223 }
224 }
225
226 // Did not find a matching activity, so remove the preference
227 parentPreferenceGroup.removePreference(preference);
228
229 return false;
230 }
231
Amith Yamasani02cf71a2010-09-21 15:48:52 -0700232 public static boolean updateHeaderToSpecificActivityFromMetaDataOrRemove(Context context,
233 List<Header> target, Header header) {
234
235 Intent intent = header.intent;
236 if (intent != null) {
237 // Find the activity that is in the system image
238 PackageManager pm = context.getPackageManager();
239 List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
240 int listSize = list.size();
241 for (int i = 0; i < listSize; i++) {
242 ResolveInfo resolveInfo = list.get(i);
243 if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
244 != 0) {
245 Drawable icon = null;
246 String title = null;
247 String summary = null;
248
249 // Get the activity's meta-data
250 try {
251 Resources res = pm.getResourcesForApplication(
252 resolveInfo.activityInfo.packageName);
253 Bundle metaData = resolveInfo.activityInfo.metaData;
254
255 if (res != null && metaData != null) {
256 icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
257 title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
258 summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
259 }
260 } catch (NameNotFoundException e) {
261 // Ignore
262 } catch (NotFoundException e) {
263 // Ignore
264 }
265
266 // Set the preference title to the activity's label if no
267 // meta-data is found
268 if (TextUtils.isEmpty(title)) {
269 title = resolveInfo.loadLabel(pm).toString();
270 }
271
272 // Set icon, title and summary for the preference
273 // TODO:
274 //header.icon = icon;
275 header.title = title;
276 header.summary = summary;
277 // Replace the intent with this specific activity
278 header.intent = new Intent().setClassName(resolveInfo.activityInfo.packageName,
279 resolveInfo.activityInfo.name);
280
281 return true;
282 }
283 }
284 }
285
286 // Did not find a matching activity, so remove the preference
287 if (target.remove(header)) System.err.println("Removed " + header.id);
288
289 return false;
290 }
291
Anders Hammar1b2dd9032010-04-08 10:03:50 +0200292 /**
Ying Wanga7188322010-01-04 18:45:10 -0800293 * Returns true if Monkey is running.
294 */
295 public static boolean isMonkeyRunning() {
Amith Yamasaniae697552011-09-27 11:33:17 -0700296 return ActivityManager.isUserAMonkey();
Ying Wanga7188322010-01-04 18:45:10 -0800297 }
Amith Yamasani60133dd2010-09-11 14:17:31 -0700298
299 /**
300 * Returns whether the device is voice-capable (meaning, it is also a phone).
301 */
302 public static boolean isVoiceCapable(Context context) {
303 TelephonyManager telephony =
304 (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
305 return telephony != null && telephony.isVoiceCapable();
306 }
Amith Yamasani0f85c482011-02-23 17:19:11 -0800307
Robert Greenwalt8af88fb2011-08-31 11:17:47 -0700308 public static boolean isWifiOnly(Context context) {
309 ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
310 Context.CONNECTIVITY_SERVICE);
311 return (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800312 }
Amith Yamasanic06d4c42011-02-25 14:35:20 -0800313
314 /**
315 * Returns the WIFI IP Addresses, if any, taking into account IPv4 and IPv6 style addresses.
316 * @param context the application context
317 * @return the formatted and comma-separated IP addresses, or null if none.
318 */
319 public static String getWifiIpAddresses(Context context) {
320 ConnectivityManager cm = (ConnectivityManager)
321 context.getSystemService(Context.CONNECTIVITY_SERVICE);
322 LinkProperties prop = cm.getLinkProperties(ConnectivityManager.TYPE_WIFI);
Amith Yamasani6822b742011-10-17 16:41:00 -0700323 return formatIpAddresses(prop);
324 }
325
326 /**
327 * Returns the default link's IP addresses, if any, taking into account IPv4 and IPv6 style
328 * addresses.
329 * @param context the application context
330 * @return the formatted and comma-separated IP addresses, or null if none.
331 */
332 public static String getDefaultIpAddresses(Context context) {
333 ConnectivityManager cm = (ConnectivityManager)
334 context.getSystemService(Context.CONNECTIVITY_SERVICE);
335 LinkProperties prop = cm.getActiveLinkProperties();
336 return formatIpAddresses(prop);
337 }
338
339 private static String formatIpAddresses(LinkProperties prop) {
Amith Yamasanic06d4c42011-02-25 14:35:20 -0800340 if (prop == null) return null;
341 Iterator<InetAddress> iter = prop.getAddresses().iterator();
342 // If there are no entries, return null
343 if (!iter.hasNext()) return null;
344 // Concatenate all available addresses, comma separated
345 String addresses = "";
346 while (iter.hasNext()) {
347 addresses += iter.next().getHostAddress();
348 if (iter.hasNext()) addresses += ", ";
349 }
350 return addresses;
351 }
Jean Chalard71ad1f42011-05-12 15:06:16 +0900352
353 public static Locale createLocaleFromString(String localeStr) {
354 // TODO: is there a better way to actually construct a locale that will match?
355 // The main problem is, on top of Java specs, locale.toString() and
356 // new Locale(locale.toString()).toString() do not return equal() strings in
357 // many cases, because the constructor takes the only string as the language
358 // code. So : new Locale("en", "US").toString() => "en_US"
359 // And : new Locale("en_US").toString() => "en_us"
360 if (null == localeStr)
361 return Locale.getDefault();
362 String[] brokenDownLocale = localeStr.split("_", 3);
363 // split may not return a 0-length array.
364 if (1 == brokenDownLocale.length) {
365 return new Locale(brokenDownLocale[0]);
366 } else if (2 == brokenDownLocale.length) {
367 return new Locale(brokenDownLocale[0], brokenDownLocale[1]);
368 } else {
369 return new Locale(brokenDownLocale[0], brokenDownLocale[1], brokenDownLocale[2]);
370 }
371 }
Amith Yamasania4379d62011-07-22 10:34:58 -0700372
373 public static String getBatteryPercentage(Intent batteryChangedIntent) {
374 int level = batteryChangedIntent.getIntExtra("level", 0);
375 int scale = batteryChangedIntent.getIntExtra("scale", 100);
376 return String.valueOf(level * 100 / scale) + "%";
377 }
378
379 public static String getBatteryStatus(Resources res, Intent batteryChangedIntent) {
380 final Intent intent = batteryChangedIntent;
381
382 int plugType = intent.getIntExtra("plugged", 0);
383 int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
384 String statusString;
385 if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
386 statusString = res.getString(R.string.battery_info_status_charging);
387 if (plugType > 0) {
Brian Muramatsu0bd54a62012-08-14 15:13:16 -0700388 int resId;
389 if (plugType == BatteryManager.BATTERY_PLUGGED_AC) {
390 resId = R.string.battery_info_status_charging_ac;
391 } else if (plugType == BatteryManager.BATTERY_PLUGGED_USB) {
392 resId = R.string.battery_info_status_charging_usb;
393 } else {
394 resId = R.string.battery_info_status_charging_wireless;
395 }
396 statusString = statusString + " " + res.getString(resId);
Amith Yamasania4379d62011-07-22 10:34:58 -0700397 }
398 } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
399 statusString = res.getString(R.string.battery_info_status_discharging);
400 } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
401 statusString = res.getString(R.string.battery_info_status_not_charging);
402 } else if (status == BatteryManager.BATTERY_STATUS_FULL) {
403 statusString = res.getString(R.string.battery_info_status_full);
404 } else {
405 statusString = res.getString(R.string.battery_info_status_unknown);
406 }
407
408 return statusString;
409 }
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -0700410
411 /**
412 * Prepare a custom preferences layout, moving padding to {@link ListView}
413 * when outside scrollbars are requested. Usually used to display
414 * {@link ListView} and {@link TabWidget} with correct padding.
415 */
Jeff Sharkey5d706792011-09-08 18:57:17 -0700416 public static void prepareCustomPreferencesList(
417 ViewGroup parent, View child, ListView list, boolean ignoreSidePadding) {
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -0700418 final boolean movePadding = list.getScrollBarStyle() == View.SCROLLBARS_OUTSIDE_OVERLAY;
419 if (movePadding && parent instanceof PreferenceFrameLayout) {
420 ((PreferenceFrameLayout.LayoutParams) child.getLayoutParams()).removeBorders = true;
421
422 final Resources res = list.getResources();
423 final int paddingSide = res.getDimensionPixelSize(
424 com.android.internal.R.dimen.preference_fragment_padding_side);
425 final int paddingBottom = res.getDimensionPixelSize(
426 com.android.internal.R.dimen.preference_fragment_padding_bottom);
Jeff Sharkey5d706792011-09-08 18:57:17 -0700427
Amith Yamasanif0b05de2012-05-09 09:43:33 -0700428 final int effectivePaddingSide = ignoreSidePadding ? 0 : paddingSide;
Jeff Sharkey5d706792011-09-08 18:57:17 -0700429 list.setPadding(effectivePaddingSide, 0, effectivePaddingSide, paddingBottom);
Jeff Sharkeyb654cbb2011-08-18 11:59:19 -0700430 }
431 }
Jeff Sharkeya83a24f2011-09-16 01:52:39 -0700432
433 /**
434 * Return string resource that best describes combination of tethering
435 * options available on this device.
436 */
437 public static int getTetheringLabel(ConnectivityManager cm) {
438 String[] usbRegexs = cm.getTetherableUsbRegexs();
439 String[] wifiRegexs = cm.getTetherableWifiRegexs();
440 String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs();
441
442 boolean usbAvailable = usbRegexs.length != 0;
443 boolean wifiAvailable = wifiRegexs.length != 0;
444 boolean bluetoothAvailable = bluetoothRegexs.length != 0;
445
446 if (wifiAvailable && usbAvailable && bluetoothAvailable) {
447 return R.string.tether_settings_title_all;
448 } else if (wifiAvailable && usbAvailable) {
449 return R.string.tether_settings_title_all;
450 } else if (wifiAvailable && bluetoothAvailable) {
451 return R.string.tether_settings_title_all;
452 } else if (wifiAvailable) {
453 return R.string.tether_settings_title_wifi;
454 } else if (usbAvailable && bluetoothAvailable) {
455 return R.string.tether_settings_title_usb_bluetooth;
456 } else if (usbAvailable) {
457 return R.string.tether_settings_title_usb;
458 } else {
459 return R.string.tether_settings_title_bluetooth;
460 }
461 }
Amith Yamasaniae47ef42012-09-16 17:53:35 -0700462
463 /* Used by UserSettings as well. Call this on a non-ui thread. */
464 public static boolean copyMeProfilePhoto(Context context, UserInfo user) {
465 Uri contactUri = Profile.CONTENT_URI;
466
467 InputStream avatarDataStream = Contacts.openContactPhotoInputStream(
468 context.getContentResolver(),
469 contactUri, true);
470 // If there's no profile photo, assign a default avatar
471 if (avatarDataStream == null) {
472 return false;
473 }
474 int userId = user != null ? user.id : UserHandle.myUserId();
475 UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
476 ParcelFileDescriptor fd = um.setUserIcon(userId);
477 FileOutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
478 byte[] buffer = new byte[4096];
479 int readSize;
480 try {
481 while ((readSize = avatarDataStream.read(buffer)) > 0) {
482 os.write(buffer, 0, readSize);
483 }
484 return true;
485 } catch (IOException ioe) {
486 Log.e("copyProfilePhoto", "Error copying profile photo " + ioe);
487 } finally {
488 try {
489 os.close();
490 avatarDataStream.close();
491 } catch (IOException ioe) { }
492 }
493 return false;
494 }
495
496 public static String getMeProfileName(Context context) {
497 Cursor cursor = context.getContentResolver().query(
498 Profile.CONTENT_URI, new String[] {Phone._ID, Phone.DISPLAY_NAME},
499 null, null, null);
500 if (cursor == null) {
501 return null;
502 }
503
504 try {
505 if (cursor.moveToFirst()) {
506 return cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME));
507 }
508 } finally {
509 cursor.close();
510 }
511 return null;
512 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800513}