summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-07-05 15:05:46 +0200
committerDanny Baumann <dannybaumann@web.de>2013-07-10 14:38:50 +0200
commit416f0d447c9d341170ea8d033642a02c478e9095 (patch)
tree384a0c4e1cc3da5a290f2cff00f9732accb7a0b7 /core/java
parenta48d4ed29fa904f065786f9b773b605ad9638e6f (diff)
downloadframeworks_base-416f0d447c9d341170ea8d033642a02c478e9095.zip
frameworks_base-416f0d447c9d341170ea8d033642a02c478e9095.tar.gz
frameworks_base-416f0d447c9d341170ea8d033642a02c478e9095.tar.bz2
Also backup profiles file via backup manager.
Change-Id: Id70cb1bce15b7de127e4291e9482ab3fd7270f9f
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/Profile.java7
-rw-r--r--core/java/android/app/ProfileGroup.java28
2 files changed, 35 insertions, 0 deletions
diff --git a/core/java/android/app/Profile.java b/core/java/android/app/Profile.java
index 1877dab..7dd62c2 100644
--- a/core/java/android/app/Profile.java
+++ b/core/java/android/app/Profile.java
@@ -614,6 +614,13 @@ public final class Profile implements Parcelable, Comparable {
}
/** @hide */
+ public void validateRingtones(Context context) {
+ for (ProfileGroup pg : profileGroups.values()) {
+ pg.validateOverrideUris(context);
+ }
+ }
+
+ /** @hide */
public static Profile fromXml(XmlPullParser xpp, Context context)
throws XmlPullParserException, IOException {
String value = xpp.getAttributeValue(null, "nameres");
diff --git a/core/java/android/app/ProfileGroup.java b/core/java/android/app/ProfileGroup.java
index b3b70d6..93857c4 100644
--- a/core/java/android/app/ProfileGroup.java
+++ b/core/java/android/app/ProfileGroup.java
@@ -20,6 +20,7 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.content.Context;
+import android.database.Cursor;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Parcel;
@@ -218,6 +219,33 @@ public final class ProfileGroup implements Parcelable {
return notification;
}
+ private boolean validateOverrideUri(Context context, Uri uri) {
+ if (RingtoneManager.isDefault(uri)) {
+ return true;
+ }
+ Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
+ boolean valid = false;
+
+ if (cursor != null) {
+ valid = cursor.moveToFirst();
+ cursor.close();
+ }
+ return valid;
+ }
+
+ void validateOverrideUris(Context context) {
+ if (!validateOverrideUri(context, mSoundOverride)) {
+ mSoundOverride = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+ mSoundMode = Mode.DEFAULT;
+ mDirty = true;
+ }
+ if (!validateOverrideUri(context, mRingerOverride)) {
+ mRingerOverride = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
+ mRingerMode = Mode.DEFAULT;
+ mDirty = true;
+ }
+ }
+
private void silenceNotification(Notification notification) {
notification.defaults &= (~Notification.DEFAULT_SOUND);
notification.sound = null;