summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorDvTonder <david.vantonder@gmail.com>2012-07-15 10:28:15 -0400
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-11-21 00:25:18 +0000
commit0b636d08439c291322339e02be605be54f589b91 (patch)
tree1abb1921eab3532617ddda7e07939f99de093280 /media
parent8415ee214d09ed7f399d8ff68d4f78c76c68fe08 (diff)
downloadframeworks_base-0b636d08439c291322339e02be605be54f589b91.zip
frameworks_base-0b636d08439c291322339e02be605be54f589b91.tar.gz
frameworks_base-0b636d08439c291322339e02be605be54f589b91.tar.bz2
Framework: Port CM9 features to CM10
This commit includes: - Power menu Reboot - Power menu screenshot - Profiles - Lock screen Calendar - Lock screen Weather - Notification light customization - Battery light customization - IME Selector notification toggle - and a few more things to support Settings Change-Id: Ibd63116df90b06f6ce6adb8a0343059bbb999bfb
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioManager.java24
-rw-r--r--media/java/android/media/RingtoneManager.java69
2 files changed, 67 insertions, 26 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 035b282..f55a0bb 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -19,6 +19,8 @@ package android.media;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.PendingIntent;
+import android.app.ProfileGroup;
+import android.app.ProfileManager;
import android.bluetooth.BluetoothDevice;
import android.content.ComponentName;
import android.content.Context;
@@ -51,6 +53,7 @@ public class AudioManager {
private final boolean mUseMasterVolume;
private final boolean mUseVolumeKeySounds;
private static String TAG = "AudioManager";
+ private final ProfileManager mProfileManager;
/**
* Broadcast intent, a hint for applications that audio is about to become
@@ -422,6 +425,7 @@ public class AudioManager {
com.android.internal.R.bool.config_useMasterVolume);
mUseVolumeKeySounds = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_useVolumeKeySounds);
+ mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);
}
private static IAudioService getService()
@@ -1000,6 +1004,26 @@ public class AudioManager {
* current ringer mode that can be queried via {@link #getRingerMode()}.
*/
public boolean shouldVibrate(int vibrateType) {
+ String packageName = mContext.getPackageName();
+ // Don't apply profiles for "android" context, as these could
+ // come from the NotificationManager, and originate from a real package.
+ if (!packageName.equals("android")) {
+ ProfileGroup profileGroup = mProfileManager.getActiveProfileGroup(packageName);
+ if (profileGroup != null) {
+ Log.v(TAG, "shouldVibrate, group: " + profileGroup.getUuid()
+ + " mode: " + profileGroup.getVibrateMode());
+ switch (profileGroup.getVibrateMode()) {
+ case OVERRIDE :
+ return true;
+ case SUPPRESS :
+ return false;
+ case DEFAULT :
+ // Drop through
+ }
+ }
+ } else {
+ Log.v(TAG, "Not applying override for 'android' package");
+ }
IAudioService service = getService();
try {
return service.shouldVibrate(vibrateType);
diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java
index 5e18bfa..b5a672a 100644
--- a/media/java/android/media/RingtoneManager.java
+++ b/media/java/android/media/RingtoneManager.java
@@ -22,6 +22,8 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.Activity;
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;
@@ -55,29 +57,29 @@ public class RingtoneManager {
// Make sure these are in sync with attrs.xml:
// <attr name="ringtoneType">
-
+
/**
* Type that refers to sounds that are used for the phone ringer.
*/
public static final int TYPE_RINGTONE = 1;
-
+
/**
* Type that refers to sounds that are used for notifications.
*/
public static final int TYPE_NOTIFICATION = 2;
-
+
/**
* Type that refers to sounds that are used for the alarm.
*/
public static final int TYPE_ALARM = 4;
-
+
/**
* All types of sounds.
*/
public static final int TYPE_ALL = TYPE_RINGTONE | TYPE_NOTIFICATION | TYPE_ALARM;
// </attr>
-
+
/**
* Activity Action: Shows a ringtone picker.
* <p>
@@ -131,7 +133,7 @@ public class RingtoneManager {
*/
public static final String EXTRA_RINGTONE_EXISTING_URI =
"android.intent.extra.ringtone.EXISTING_URI";
-
+
/**
* Given to the ringtone picker as a {@link Uri}. The {@link Uri} of the
* ringtone to play when the user attempts to preview the "Default"
@@ -144,7 +146,7 @@ public class RingtoneManager {
*/
public static final String EXTRA_RINGTONE_DEFAULT_URI =
"android.intent.extra.ringtone.DEFAULT_URI";
-
+
/**
* Given to the ringtone picker as an int. Specifies which ringtone type(s) should be
* shown in the picker. One or more of {@link #TYPE_RINGTONE},
@@ -194,7 +196,7 @@ public class RingtoneManager {
"\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"",
MediaStore.Audio.Media.TITLE_KEY
};
-
+
/**
* The column index (in the cursor returned by {@link #getCursor()} for the
* row ID.
@@ -215,11 +217,11 @@ public class RingtoneManager {
private Activity mActivity;
private Context mContext;
-
+
private Cursor mCursor;
private int mType = TYPE_RINGTONE;
-
+
/**
* If a column (item from this list) exists in the Cursor, its value must
* be true (value of 1) for the row to be returned.
@@ -230,7 +232,7 @@ public class RingtoneManager {
private Ringtone mPreviousRingtone;
private boolean mIncludeDrm;
-
+
/**
* Constructs a RingtoneManager. This constructor is recommended as its
* constructed instance manages cursor(s).
@@ -322,7 +324,7 @@ public class RingtoneManager {
mPreviousRingtone.stop();
}
}
-
+
/**
* Returns whether DRM ringtones will be included.
*
@@ -365,7 +367,7 @@ 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 },
MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
}
@@ -401,12 +403,12 @@ public class RingtoneManager {
return getUriFromCursor(mCursor);
}
-
+
private static Uri getUriFromCursor(Cursor cursor) {
return ContentUris.withAppendedId(Uri.parse(cursor.getString(URI_COLUMN_INDEX)), cursor
.getLong(ID_COLUMN_INDEX));
}
-
+
/**
* Gets the position of a {@link Uri} within this {@link RingtoneManager}.
*
@@ -527,7 +529,7 @@ public class RingtoneManager {
columns.add(MediaStore.Audio.AudioColumns.IS_ALARM);
}
}
-
+
/**
* Constructs a where clause that consists of at least one column being 1
* (true). This is used to find all matching sounds for the given sound
@@ -539,7 +541,7 @@ public class RingtoneManager {
private static String constructBooleanTrueWhereClause(List<String> columns, boolean includeDrm) {
if (columns == null) return null;
-
+
StringBuilder sb = new StringBuilder();
sb.append("(");
@@ -565,7 +567,7 @@ public class RingtoneManager {
return sb.toString();
}
-
+
private Cursor query(Uri uri,
String[] projection,
String selection,
@@ -578,7 +580,7 @@ public class RingtoneManager {
sortOrder);
}
}
-
+
/**
* Returns a {@link Ringtone} for a given sound URI.
* <p>
@@ -606,11 +608,26 @@ public class RingtoneManager {
* @see #getRingtone(Context, Uri)
*/
private static Ringtone getRingtone(final Context context, Uri ringtoneUri, int streamType) {
+ ProfileManager pm = (ProfileManager)context.getSystemService(context.PROFILE_SERVICE);
+ ProfileGroup profileGroup = pm.getActiveProfileGroup(context.getPackageName());
+
try {
- final Ringtone r = new Ringtone(context, true);
+ Ringtone r = new Ringtone(context, true);
if (streamType >= 0) {
r.setStreamType(streamType);
}
+
+ if (profileGroup != null) {
+ switch (profileGroup.getRingerMode()) {
+ case OVERRIDE :
+ r.setUri(profileGroup.getRingerOverride());
+ return r;
+ case SUPPRESS :
+ r = null;
+ return r;
+ }
+ }
+
r.setUri(ringtoneUri);
return r;
} catch (Exception ex) {
@@ -619,7 +636,7 @@ public class RingtoneManager {
return null;
}
-
+
/**
* Gets the current default sound's {@link Uri}. This will give the actual
* sound {@link Uri}, instead of using this, most clients can use
@@ -638,7 +655,7 @@ public class RingtoneManager {
final String uriString = Settings.System.getString(context.getContentResolver(), setting);
return uriString != null ? Uri.parse(uriString) : null;
}
-
+
/**
* Sets the {@link Uri} of the default sound for a given sound type.
*
@@ -655,7 +672,7 @@ public class RingtoneManager {
Settings.System.putString(context.getContentResolver(), setting,
ringtoneUri != null ? ringtoneUri.toString() : null);
}
-
+
private static String getSettingForType(int type) {
if ((type & TYPE_RINGTONE) != 0) {
return Settings.System.RINGTONE;
@@ -667,7 +684,7 @@ public class RingtoneManager {
return null;
}
}
-
+
/**
* Returns whether the given {@link Uri} is one of the default ringtones.
*
@@ -677,7 +694,7 @@ public class RingtoneManager {
public static boolean isDefault(Uri ringtoneUri) {
return getDefaultType(ringtoneUri) != -1;
}
-
+
/**
* Returns the type of a default {@link Uri}.
*
@@ -700,7 +717,7 @@ public class RingtoneManager {
return -1;
}
}
-
+
/**
* Returns the {@link Uri} for the default ringtone of a particular type.
* Rather than returning the actual ringtone's sound {@link Uri}, this will