From 05e2b6be6652e874bcd7248aeddd2c7d2fe226c5 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Mon, 10 Jun 2013 15:06:28 -0700 Subject: [PATCH 1/3] Unhide MediaExtractor.getPsshInfo() b/9373882 Change-Id: I2af42656d6a7eb19e8e9ec798b615dab0d9d33cb --- api/current.txt | 1 + media/java/android/media/MediaExtractor.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 092fe168ad0dc..ed19834812628 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11883,6 +11883,7 @@ package android.media { ctor public MediaExtractor(); method public boolean advance(); method public long getCachedDuration(); + method public java.util.Map getPsshInfo(); method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo); method public int getSampleFlags(); method public long getSampleTime(); diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index cf159f0ed1dbc..e558c07d3c87d 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -199,9 +199,9 @@ final public class MediaExtractor { public native final int getTrackCount(); /** - * Get the PSSH info if present. This returns a map of uuid-to-bytes, with the uuid specifying + * Get the PSSH info if present. + * @return a map of uuid-to-bytes, with the uuid specifying * the crypto scheme, and the bytes being the data specific to that scheme. - * {@hide} */ public Map getPsshInfo() { Map psshMap = null; From d61650a0add958b27d6117eb1853b9fff47df524 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Fri, 7 Jun 2013 15:48:22 -0700 Subject: [PATCH 2/3] Let RemoteControlDisplay know more about playback position The BT stack needs to differentiate between applications that use the new RemoteControlClient APIs to pass a playback position but don't have one yet, and applications that use the legacy API and will never pass a position. Bug 9294855 Change-Id: I05cba82a073e6e0aaea1d8bbf9cc8c99da715f58 --- .../android/media/IRemoteControlDisplay.aidl | 27 +++++++++++++++++++ .../android/media/RemoteControlClient.java | 27 +++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/media/java/android/media/IRemoteControlDisplay.aidl b/media/java/android/media/IRemoteControlDisplay.aidl index c70889c9237cd..583f436690c6f 100644 --- a/media/java/android/media/IRemoteControlDisplay.aidl +++ b/media/java/android/media/IRemoteControlDisplay.aidl @@ -40,6 +40,33 @@ oneway interface IRemoteControlDisplay void setCurrentClientId(int clientGeneration, in PendingIntent clientMediaIntent, boolean clearing); + /** + * Sets the playback information (state, position and speed) of a client. + * @param generationId the current generation ID as known by this client + * @param state the current playback state, one of the following values: + * {@link RemoteControlClient#PLAYSTATE_STOPPED}, + * {@link RemoteControlClient#PLAYSTATE_PAUSED}, + * {@link RemoteControlClient#PLAYSTATE_PLAYING}, + * {@link RemoteControlClient#PLAYSTATE_FAST_FORWARDING}, + * {@link RemoteControlClient#PLAYSTATE_REWINDING}, + * {@link RemoteControlClient#PLAYSTATE_SKIPPING_FORWARDS}, + * {@link RemoteControlClient#PLAYSTATE_SKIPPING_BACKWARDS}, + * {@link RemoteControlClient#PLAYSTATE_BUFFERING}, + * {@link RemoteControlClient#PLAYSTATE_ERROR}. + * @param stateChangeTimeMs the time at which the client reported the playback information + * @param currentPosMs a 0 or positive value for the current media position expressed in ms + * Strictly negative values imply that position is not known: + * a value of {@link RemoteControlClient#PLAYBACK_POSITION_INVALID} is intended to express + * that an application doesn't know the position (e.g. listening to a live stream of a radio) + * or that the position information is not applicable (e.g. when state + * is {@link RemoteControlClient#PLAYSTATE_BUFFERING} and nothing had played yet); + * a value of {@link RemoteControlClient#PLAYBACK_POSITION_ALWAYS_UNKNOWN} implies that the + * application uses {@link RemoteControlClient#setPlaybackState(int)} (legacy API) and will + * never pass a playback position. + * @param speed a value expressed as a ratio of 1x playback: 1.0f is normal playback, + * 2.0f is 2x, 0.5f is half-speed, -2.0f is rewind at 2x speed. 0.0f means nothing is + * playing (e.g. when state is {@link RemoteControlClient#PLAYSTATE_ERROR}). + */ void setPlaybackState(int generationId, int state, long stateChangeTimeMs, long currentPosMs, float speed); diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java index c6ae9aade2c01..7379438360ab1 100644 --- a/media/java/android/media/RemoteControlClient.java +++ b/media/java/android/media/RemoteControlClient.java @@ -178,6 +178,12 @@ public class RemoteControlClient * An unknown or invalid playback position value. */ public final static long PLAYBACK_POSITION_INVALID = -1; + /** + * @hide + * An invalid playback position value associated with the use of {@link #setPlaybackState(int)} + * used to indicate that playback position will remain unknown. + */ + public final static long PLAYBACK_POSITION_ALWAYS_UNKNOWN = 0x8019771980198300L; /** * @hide * The default playback speed, 1x. @@ -602,7 +608,8 @@ public class RemoteControlClient * {@link #PLAYSTATE_ERROR}. */ public void setPlaybackState(int state) { - setPlaybackState(state, PLAYBACK_POSITION_INVALID, PLAYBACK_SPEED_1X); + setPlaybackStateInt(state, PLAYBACK_POSITION_ALWAYS_UNKNOWN, PLAYBACK_SPEED_1X, + false /* legacy API, converting to method with position and speed */); } /** @@ -629,12 +636,28 @@ public class RemoteControlClient * playing (e.g. when state is {@link #PLAYSTATE_ERROR}). */ public void setPlaybackState(int state, long timeInMs, float playbackSpeed) { + setPlaybackStateInt(state, timeInMs, playbackSpeed, true); + } + + private void setPlaybackStateInt(int state, long timeInMs, float playbackSpeed, + boolean hasPosition) { synchronized(mCacheLock) { if ((mPlaybackState != state) || (mPlaybackPositionMs != timeInMs) || (mPlaybackSpeed != playbackSpeed)) { // store locally mPlaybackState = state; - mPlaybackPositionMs = timeInMs; + // distinguish between an application not knowing the current playback position + // at the moment and an application using the API where only the playback state + // is passed, not the playback position. + if (hasPosition) { + if (timeInMs < 0) { + mPlaybackPositionMs = PLAYBACK_POSITION_INVALID; + } else { + mPlaybackPositionMs = timeInMs; + } + } else { + mPlaybackPositionMs = PLAYBACK_POSITION_ALWAYS_UNKNOWN; + } mPlaybackSpeed = playbackSpeed; // keep track of when the state change occurred mPlaybackStateChangeTimeMs = SystemClock.elapsedRealtime(); From 00416842550ea5f2c6a5bc0e4c82a3b4fe27ad9a Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Mon, 10 Jun 2013 16:55:02 -0700 Subject: [PATCH 3/3] Need to explicitly disable scan-always when turning off wifi ... when you want wifi to be really most sincerely off, because settings restore is about to rewrite the conf file. Bug 9032154 Change-Id: I6a3a34ac3f14ec43aa9d9cc0159fca6168ccd0a2 --- .../providers/settings/SettingsBackupAgent.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 0b85e70201bed..3f044708d5a0d 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -20,6 +20,7 @@ import android.app.backup.BackupAgentHelper; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.FullBackupDataOutput; +import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -330,7 +331,16 @@ public class SettingsBackupAgent extends BackupAgentHelper { if (DEBUG_BACKUP) { Log.v(TAG, "Starting deferred restore of wifi data"); } + final ContentResolver cr = getContentResolver(); + final int scanAlways = Settings.Global.getInt(cr, + Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0); final int retainedWifiState = enableWifi(false); + if (scanAlways != 0) { + Settings.Global.putInt(cr, + Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0); + // !!! Give the wifi stack a moment to quiesce + try { Thread.sleep(1000); } catch (InterruptedException e) {} + } if (restoredSupplicantData != null) { restoreWifiSupplicant(FILE_WIFI_SUPPLICANT, restoredSupplicantData, restoredSupplicantData.length); @@ -344,6 +354,10 @@ public class SettingsBackupAgent extends BackupAgentHelper { restoredWifiConfigFile, restoredWifiConfigFile.length); } // restore the previous WIFI state. + if (scanAlways != 0) { + Settings.Global.putInt(cr, + Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, scanAlways); + } enableWifi(retainedWifiState == WifiManager.WIFI_STATE_ENABLED || retainedWifiState == WifiManager.WIFI_STATE_ENABLING); }