Permalink
Browse files

Fix music with sms popup

  • Loading branch information...
1 parent 3a5698a commit 3cf17d7c842695a26ffa9fd75f3a12e91e9bf2c5 @drod2169 committed May 9, 2012
View
10 core/java/android/provider/Settings.java
@@ -1988,6 +1988,16 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
public static final String LOCKSCREEN_SMS_COLOR = "lockscreen_sms_color";
/**
+ * Is music playing & transportview visible?
+ * 1 = visible transport view
+ * 0 = hidden transport view
+ * wont allow SMS popup to work with transportview visible
+ * as they dont play nice together
+ * @hide
+ */
+ public static final String LOCKSCREEN_SMS_MUSIC = "lockscreen_sms_music";
+
+ /**
* Whether to show the battery bar
* @hide
*/
View
37 core/java/com/android/internal/widget/TransportControlView.java
@@ -38,6 +38,7 @@
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.provider.Settings;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
@@ -197,6 +198,7 @@ public TransportControlView(Context context, AttributeSet attrs) {
mAudioManager = new AudioManager(mContext);
mCurrentPlayState = RemoteControlClient.PLAYSTATE_NONE; // until we get a callback
mIRCD = new IRemoteControlDisplayWeak(mHandler);
+ isMusicPlaying(false);
}
private void updateTransportControls(int transportControlFlags) {
@@ -332,6 +334,7 @@ private static void setVisibilityBasedOnFlag(View view, int flags, int flag) {
}
private void updatePlayPauseState(int state) {
+ isMusicPlaying(state);
if (DEBUG) Log.v(TAG,
"updatePlayPauseState(), old=" + mCurrentPlayState + ", state=" + state);
if (state == mCurrentPlayState) {
@@ -512,4 +515,38 @@ private boolean wasPlayingRecently(int state, long stateChangeTimeMs) {
return false;
}
}
+
+ //thanks google for letting me copy paste this from above LOL
+ private void isMusicPlaying(int state) {
+ switch (state) {
+ case RemoteControlClient.PLAYSTATE_PLAYING:
+ case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
+ case RemoteControlClient.PLAYSTATE_REWINDING:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
+ case RemoteControlClient.PLAYSTATE_BUFFERING:
+ // actively playing or about to play
+ isMusicPlaying(true);
+ break;
+ case RemoteControlClient.PLAYSTATE_NONE:
+ // music is no longer playing or about to
+ isMusicPlaying(false);
+ break;
+ case RemoteControlClient.PLAYSTATE_STOPPED:
+ case RemoteControlClient.PLAYSTATE_PAUSED:
+ case RemoteControlClient.PLAYSTATE_ERROR:
+ default:
+ // defaulted music is not playing so make sure the crossover is that way
+ isMusicPlaying(false);
+ break;
+ }
+ }
+
+ private void isMusicPlaying(boolean musicPlaying) {
+ if (musicPlaying) {
+ Settings.System.putInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SMS_MUSIC, 1);
+ } else {
+ Settings.System.putInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SMS_MUSIC, 0);
+ }
+ }
}
View
9 policy/src/com/android/internal/policy/impl/LockTextSMS.java
@@ -119,14 +119,15 @@ public void onReceive(Context context, Intent intent) {
private void keepMyBoxUp() {
boolean showTexts = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SMS_CROSS, 1) == 0);
+ boolean musicPlaying = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SMS_MUSIC, 0) == 1);
Uri uri = Uri.parse("content://sms/inbox");
Cursor c = mContext.getContentResolver().query(uri, null, "read = 0", null, null);
int unreadSMSCount = c.getCount();
c.deactivate();
- if (unreadSMSCount > 0 && showTexts) {
+ if (unreadSMSCount > 0 && showTexts && !musicPlaying) {
String name = null;
String msg = null;
Cursor cursor1 = mContext.getContentResolver().query(uri,new String[] { "_id", "thread_id", "address", "person", "date","body", "type" }, null, null, null);
@@ -169,7 +170,9 @@ private void updateCurrentText(String textBody, String callerID) {
private void getYourText(Bundle bundle) {
boolean showTexts = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SHOW_TEXTS, 0) == 1);
- if (showTexts) {
+ boolean musicPlaying = (Settings.System.getInt(mContext.getContentResolver(), Settings.System.LOCKSCREEN_SMS_MUSIC, 0) == 1);
+
+ if (showTexts && !musicPlaying) {
try {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
@@ -232,4 +235,4 @@ private void updateSettings() {
setVisibility(View.GONE);
}
}
-}
+}

0 comments on commit 3cf17d7

Please sign in to comment.