diff options
author | Ricardo Cerqueira <github@cerqueira.org> | 2012-05-01 00:42:32 +0100 |
---|---|---|
committer | Ricardo Cerqueira <github@cerqueira.org> | 2012-05-04 00:35:28 +0100 |
commit | 5b98f48ce8a98f7ecd74559088a755ca4df96bd2 (patch) | |
tree | aee5867ff4f0571f7e33197ddc97a4affe0daf40 /media | |
parent | 83f5fc03a67685e762f47a1b9b913b8bc04896d0 (diff) | |
parent | 44ffc93b4d3ab81bf4df569839e409bae0c8695a (diff) | |
download | frameworks_base-5b98f48ce8a98f7ecd74559088a755ca4df96bd2.zip frameworks_base-5b98f48ce8a98f7ecd74559088a755ca4df96bd2.tar.gz frameworks_base-5b98f48ce8a98f7ecd74559088a755ca4df96bd2.tar.bz2 |
Merge remote-tracking branch 'tmo/themes-2.3.1_r1' into themes-4.0
* Adapt to ICS API changes
* Remove part of idmap due to conflicts
* Restructure statusbar code
* Fix issues with PowerWidget on phones to avoid the CM7 hackish
restart of SystemUI
* Add reinflation to properly redo status icons on tablets
Conflicts:
core/java/android/app/ActivityManager.java
core/java/android/app/ActivityThread.java
core/java/android/app/ContextImpl.java
core/java/android/content/pm/ApplicationInfo.java
core/java/android/content/pm/IPackageManager.aidl
core/java/android/content/pm/PackageParser.java
core/java/android/content/res/AssetManager.java
core/java/android/content/res/CompatibilityInfo.java
core/java/android/content/res/Configuration.java
core/java/android/content/res/Resources.java
core/java/com/android/internal/os/ZygoteInit.java
core/jni/AndroidRuntime.cpp
core/jni/android_util_AssetManager.cpp
core/res/AndroidManifest.xml
data/etc/platform.xml
include/utils/AssetManager.h
include/utils/ResourceTypes.h
libs/utils/Android.mk
libs/utils/AssetManager.cpp
libs/utils/ResourceTypes.cpp
media/java/android/media/RingtoneManager.java
packages/SystemUI/res/layout/status_bar.xml
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarView.java
packages/SystemUI/src/com/android/systemui/statusbar/TrackingView.java
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
services/java/com/android/server/PackageManagerService.java
services/java/com/android/server/SystemServer.java
services/java/com/android/server/am/ActivityManagerService.java
test-runner/src/android/test/mock/MockPackageManager.java
Change-Id: Icabcd2c7b07dcbf174789b34f960360b87d7f27a
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/Ringtone.java | 25 | ||||
-rw-r--r-- | media/java/android/media/RingtoneManager.java | 76 |
2 files changed, 78 insertions, 23 deletions
diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java index f16ba36..8b6fd4a 100644 --- a/media/java/android/media/Ringtone.java +++ b/media/java/android/media/Ringtone.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2006 The Android Open Source Project + * This code has been modified. Portions copyright (C) 2010, T-Mobile USA, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,6 @@ import android.content.ContentResolver; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.database.Cursor; -import android.media.AudioManager; -import android.media.MediaPlayer; import android.net.Uri; import android.provider.DrmStore; import android.provider.MediaStore; @@ -113,6 +112,19 @@ public class Ringtone { return mTitle = getTitle(context, mUri, true); } + private static String stringForQuery(Cursor cursor) { + if (cursor != null) { + try { + if (cursor.moveToFirst()) { + return cursor.getString(0); + } + } finally { + cursor.close(); + } + } + return null; + } + private static String getTitle(Context context, Uri uri, boolean followSettingsUri) { Cursor cursor = null; ContentResolver res = context.getContentResolver(); @@ -131,8 +143,15 @@ public class Ringtone { .getString(com.android.internal.R.string.ringtone_default_with_actual, actualTitle); } + } else if (RingtoneManager.THEME_AUTHORITY.equals(authority)) { + Uri themes = Uri.parse("content://com.tmobile.thememanager.themes/themes"); + title = stringForQuery(res.query(themes, new String[] { "ringtone_name" }, + "ringtone_uri = ?", new String[] { uri.toString() }, null)); + if (title == null) { + title = stringForQuery(res.query(themes, new String[] { "notif_ringtone_name" }, + "notif_ringtone_uri = ?", new String[] { uri.toString() }, null)); + } } else { - if (DrmStore.AUTHORITY.equals(authority)) { cursor = res.query(uri, DRM_COLUMNS, null, null, null); } else if (MediaStore.AUTHORITY.equals(authority)) { diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 7aa4109..7d253f1 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 The Android Open Source Project + * This code has been modified. Portions copyright (C) 2010, T-Mobile USA, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,6 @@ import android.content.ContentUris; import android.app.ProfileGroup; import android.app.ProfileManager; import android.content.Context; -import android.content.res.AssetFileDescriptor; import android.database.Cursor; import android.net.Uri; import android.os.Environment; @@ -177,23 +177,28 @@ public class RingtoneManager { public static final String EXTRA_RINGTONE_PICKED_URI = "android.intent.extra.ringtone.PICKED_URI"; + /** + * @hide + */ + public static final String THEME_AUTHORITY = "com.tmobile.thememanager.packageresources"; + // Make sure the column ordering and then ..._COLUMN_INDEX are in sync private static final String[] INTERNAL_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "\"", + "\"" + MediaStore.Audio.Media.INTERNAL_CONTENT_URI + "/\" || " + MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE_KEY }; private static final String[] DRM_COLUMNS = new String[] { DrmStore.Audio._ID, DrmStore.Audio.TITLE, - "\"" + DrmStore.Audio.CONTENT_URI + "\"", + "\"" + DrmStore.Audio.CONTENT_URI + "/\" || " + DrmStore.Audio._ID, DrmStore.Audio.TITLE + " AS " + MediaStore.Audio.Media.TITLE_KEY }; private static final String[] MEDIA_COLUMNS = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, - "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"", + "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "/\" || " + MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE_KEY }; @@ -367,8 +372,11 @@ public class RingtoneManager { final Cursor internalCursor = getInternalRingtones(); final Cursor drmCursor = mIncludeDrm ? getDrmRingtones() : null; final Cursor mediaCursor = getMediaRingtones(); - - return mCursor = new SortCursor(new Cursor[] { internalCursor, drmCursor, mediaCursor }, + final Cursor themeRegularCursor = getThemeRegularRingtones(); + final Cursor themeNotifCursor = getThemeNotificationRingtones(); + + return mCursor = new SortCursor(new Cursor[] { internalCursor, drmCursor, mediaCursor, + themeRegularCursor, themeNotifCursor }, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); } @@ -405,8 +413,7 @@ public class RingtoneManager { } private static Uri getUriFromCursor(Cursor cursor) { - return ContentUris.withAppendedId(Uri.parse(cursor.getString(URI_COLUMN_INDEX)), cursor - .getLong(ID_COLUMN_INDEX)); + return Uri.parse(cursor.getString(URI_COLUMN_INDEX)); } /** @@ -426,23 +433,12 @@ public class RingtoneManager { return -1; } - // Only create Uri objects when the actual URI changes - Uri currentUri = null; - String previousUriString = null; for (int i = 0; i < cursorCount; i++) { - String uriString = cursor.getString(URI_COLUMN_INDEX); - if (currentUri == null || !uriString.equals(previousUriString)) { - currentUri = Uri.parse(uriString); - } - - if (ringtoneUri.equals(ContentUris.withAppendedId(currentUri, cursor - .getLong(ID_COLUMN_INDEX)))) { + if (ringtoneUri.equals(getUriFromCursor(cursor))) { return i; } cursor.move(1); - - previousUriString = uriString; } return -1; @@ -468,6 +464,14 @@ public class RingtoneManager { uri = getValidRingtoneUriFromCursorAndClose(context, rm.getDrmRingtones()); } + if (uri == null) { + uri = getValidRingtoneUriFromCursorAndClose(context, rm.getThemeRegularRingtones()); + } + + if (uri == null) { + uri = getValidRingtoneUriFromCursorAndClose(context, rm.getThemeNotificationRingtones()); + } + return uri; } @@ -513,6 +517,38 @@ public class RingtoneManager { : null; } + private String getThemeWhereClause(String uriColumn) { + /* Filter out themes with no ringtone and the default theme (which has no package). */ + String clause = uriColumn + " IS NOT NULL AND LENGTH(theme_package) > 0"; + if (mIncludeDrm) { + return clause; + } else { + return clause + " AND " + uriColumn + " NOT LIKE '%/assets/%locked%'"; + } + } + + private Cursor getThemeRegularRingtones() { + if ((mType & TYPE_RINGTONE) != 0) { + return query(Uri.parse("content://com.tmobile.thememanager.themes/themes"), + new String[] { "_id", "ringtone_name AS " + MEDIA_COLUMNS[1], "ringtone_uri", + "ringtone_name_key AS " + MEDIA_COLUMNS[3] }, + getThemeWhereClause("ringtone_uri"), null, MEDIA_COLUMNS[3]); + } else { + return null; + } + } + + private Cursor getThemeNotificationRingtones() { + if ((mType & TYPE_NOTIFICATION) != 0) { + return query(Uri.parse("content://com.tmobile.thememanager.themes/themes"), + new String[] { "_id", "notif_ringtone_name AS " + MEDIA_COLUMNS[1], "notif_ringtone_uri", + "notif_ringtone_name_key AS " + MEDIA_COLUMNS[3] }, + getThemeWhereClause("notif_ringtone_uri"), null, MEDIA_COLUMNS[3]); + } else { + return null; + } + } + private void setFilterColumnsList(int type) { List<String> columns = mFilterColumns; columns.clear(); |