Merge "Fix NPE in Recent Apps"
diff --git a/api/current.txt b/api/current.txt
index 9285a15..fa2a475 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -24890,9 +24890,11 @@
public final class SpellCheckerSubtype implements android.os.Parcelable {
ctor public SpellCheckerSubtype(int, java.lang.String, java.lang.String);
+ method public boolean containsExtraValueKey(java.lang.String);
method public int describeContents();
method public java.lang.CharSequence getDisplayName(android.content.Context, java.lang.String, android.content.pm.ApplicationInfo);
method public java.lang.String getExtraValue();
+ method public java.lang.String getExtraValueOf(java.lang.String);
method public java.lang.String getLocale();
method public int getNameResId();
method public void writeToParcel(android.os.Parcel, int);
diff --git a/core/java/android/view/textservice/SpellCheckerSubtype.java b/core/java/android/view/textservice/SpellCheckerSubtype.java
index 1bbaf6c..f235295 100644
--- a/core/java/android/view/textservice/SpellCheckerSubtype.java
+++ b/core/java/android/view/textservice/SpellCheckerSubtype.java
@@ -110,7 +110,6 @@
}
/**
- * @hide
* The string of ExtraValue in subtype should be defined as follows:
* example: key0,key1=value1,key2,key3,key4=value4
* @param key the key of extra value
@@ -121,7 +120,6 @@
}
/**
- * @hide
* The string of ExtraValue in subtype should be defined as follows:
* example: key0,key1=value1,key2,key3,key4=value4
* @param key the key of extra value
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index e1eff58..21364c1a 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -116,13 +116,12 @@
return mVideoSurfaceView;
}
- HTML5VideoFullScreen(Context context, int videoLayerId, int position,
- boolean autoStart) {
+ HTML5VideoFullScreen(Context context, int videoLayerId, int position) {
mVideoSurfaceView = new VideoSurfaceView(context);
mFullScreenMode = FULLSCREEN_OFF;
mVideoWidth = 0;
mVideoHeight = 0;
- init(videoLayerId, position, autoStart);
+ init(videoLayerId, position);
}
private void setMediaController(MediaController m) {
@@ -186,11 +185,6 @@
// after reading the MetaData
if (mMediaController != null) {
mMediaController.setEnabled(true);
- // If paused , should show the controller for ever!
- if (getAutostart())
- mMediaController.show();
- else
- mMediaController.show(0);
}
if (mProgressView != null) {
@@ -201,6 +195,9 @@
mVideoHeight = mp.getVideoHeight();
// This will trigger the onMeasure to get the display size right.
mVideoSurfaceView.getHolder().setFixedSize(mVideoWidth, mVideoHeight);
+ // Call into the native to ask for the state, if still in play mode,
+ // this will trigger the video to play.
+ mProxy.dispatchOnRestoreState();
}
public boolean fullScreenExited() {
diff --git a/core/java/android/webkit/HTML5VideoInline.java b/core/java/android/webkit/HTML5VideoInline.java
index fe5908e..2d5b263 100644
--- a/core/java/android/webkit/HTML5VideoInline.java
+++ b/core/java/android/webkit/HTML5VideoInline.java
@@ -34,9 +34,8 @@
}
}
- HTML5VideoInline(int videoLayerId, int position,
- boolean autoStart) {
- init(videoLayerId, position, autoStart);
+ HTML5VideoInline(int videoLayerId, int position) {
+ init(videoLayerId, position);
mTextureNames = null;
}
diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java
index 67660b8..1d8bda7 100644
--- a/core/java/android/webkit/HTML5VideoView.java
+++ b/core/java/android/webkit/HTML5VideoView.java
@@ -52,10 +52,6 @@
// Switching between inline and full screen will also create a new instance.
protected MediaPlayer mPlayer;
- // This will be set up every time we create the Video View object.
- // Set to true only when switching into full screen while playing
- protected boolean mAutostart;
-
// We need to save such info.
protected Uri mUri;
protected Map<String, String> mHeaders;
@@ -141,22 +137,17 @@
}
}
- public boolean getAutostart() {
- return mAutostart;
- }
-
public boolean getPauseDuringPreparing() {
return mPauseDuringPreparing;
}
// Every time we start a new Video, we create a VideoView and a MediaPlayer
- public void init(int videoLayerId, int position, boolean autoStart) {
+ public void init(int videoLayerId, int position) {
mPlayer = new MediaPlayer();
mCurrentState = STATE_INITIALIZED;
mProxy = null;
mVideoLayerId = videoLayerId;
mSaveSeekTime = position;
- mAutostart = autoStart;
mTimer = null;
mPauseDuringPreparing = false;
}
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java
index d0237b5..7c2dc38 100644
--- a/core/java/android/webkit/HTML5VideoViewProxy.java
+++ b/core/java/android/webkit/HTML5VideoViewProxy.java
@@ -66,6 +66,7 @@
private static final int POSTER_FETCHED = 202;
private static final int PAUSED = 203;
private static final int STOPFULLSCREEN = 204;
+ private static final int RESTORESTATE = 205;
// Timer thread -> UI thread
private static final int TIMEUPDATE = 300;
@@ -144,19 +145,16 @@
HTML5VideoViewProxy proxy, WebView webView) {
// Save the inline video info and inherit it in the full screen
int savePosition = 0;
- boolean savedIsPlaying = false;
if (mHTML5VideoView != null) {
// If we are playing the same video, then it is better to
// save the current position.
if (layerId == mHTML5VideoView.getVideoLayerId()) {
savePosition = mHTML5VideoView.getCurrentPosition();
- savedIsPlaying = mHTML5VideoView.isPlaying();
}
- mHTML5VideoView.pauseAndDispatch(mCurrentProxy);
mHTML5VideoView.release();
}
mHTML5VideoView = new HTML5VideoFullScreen(proxy.getContext(),
- layerId, savePosition, savedIsPlaying);
+ layerId, savePosition);
mCurrentProxy = proxy;
mHTML5VideoView.setVideoURI(url, mCurrentProxy);
@@ -192,7 +190,7 @@
mHTML5VideoView.release();
}
mCurrentProxy = proxy;
- mHTML5VideoView = new HTML5VideoInline(videoLayerId, time, false);
+ mHTML5VideoView = new HTML5VideoInline(videoLayerId, time);
mHTML5VideoView.setVideoURI(url, mCurrentProxy);
mHTML5VideoView.prepareDataAndDisplayMode(proxy);
@@ -235,7 +233,7 @@
}
public static void onPrepared() {
- if (!mHTML5VideoView.isFullScreenMode() || mHTML5VideoView.getAutostart()) {
+ if (!mHTML5VideoView.isFullScreenMode()) {
mHTML5VideoView.start();
}
if (mBaseLayer != 0) {
@@ -297,6 +295,11 @@
mWebCoreHandler.sendMessage(msg);
}
+ public void dispatchOnRestoreState() {
+ Message msg = Message.obtain(mWebCoreHandler, RESTORESTATE);
+ mWebCoreHandler.sendMessage(msg);
+ }
+
public void onTimeupdate() {
sendMessage(obtainMessage(TIMEUPDATE));
}
@@ -569,6 +572,9 @@
case STOPFULLSCREEN:
nativeOnStopFullscreen(mNativePointer);
break;
+ case RESTORESTATE:
+ nativeOnRestoreState(mNativePointer);
+ break;
}
}
};
@@ -696,6 +702,7 @@
private native void nativeOnPosterFetched(Bitmap poster, int nativePointer);
private native void nativeOnTimeupdate(int position, int nativePointer);
private native void nativeOnStopFullscreen(int nativePointer);
+ private native void nativeOnRestoreState(int nativePointer);
private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture,
int baseLayer, int videoLayerId, int textureName,
int playerState);
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 08d94e2..b4c38db 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -535,21 +535,6 @@
}
/**
- * If WebView only supports touch, a different navigation model will be
- * applied. Otherwise, the navigation to support both touch and keyboard
- * will be used.
- * @hide
- public void setSupportTouchOnly(boolean touchOnly) {
- mSupportTounchOnly = touchOnly;
- }
- */
-
- boolean supportTouchOnly() {
- // for debug only, use mLightTouchEnabled for mSupportTounchOnly
- return mLightTouchEnabled;
- }
-
- /**
* Set whether the WebView supports zoom
*/
public void setSupportZoom(boolean support) {
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 15b47e3..168baad 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -92,6 +92,7 @@
import android.webkit.WebViewCore.EventHub;
import android.webkit.WebViewCore.TouchEventData;
import android.webkit.WebViewCore.TouchHighlightData;
+import android.webkit.WebViewCore.WebKitHitTest;
import android.widget.AbsoluteLayout;
import android.widget.Adapter;
import android.widget.AdapterView;
@@ -699,7 +700,7 @@
private Drawable mSelectHandleLeft;
private Drawable mSelectHandleRight;
- static final boolean USE_WEBKIT_RINGS = false;
+ static boolean sDisableNavcache = false;
// the color used to highlight the touch rectangles
private static final int HIGHLIGHT_COLOR = 0x6633b5e5;
// the round corner for the highlight path
@@ -775,7 +776,7 @@
static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128;
static final int SET_SCROLLBAR_MODES = 129;
static final int SELECTION_STRING_CHANGED = 130;
- static final int SET_TOUCH_HIGHLIGHT_RECTS = 131;
+ static final int HIT_TEST_RESULT = 131;
static final int SAVE_WEBARCHIVE_FINISHED = 132;
static final int SET_AUTOFILLABLE = 133;
@@ -788,7 +789,7 @@
static final int UPDATE_ZOOM_DENSITY = 139;
private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
- private static final int LAST_PACKAGE_MSG_ID = SET_TOUCH_HIGHLIGHT_RECTS;
+ private static final int LAST_PACKAGE_MSG_ID = HIT_TEST_RESULT;
static final String[] HandlerPrivateDebugString = {
"REMEMBER_PASSWORD", // = 1;
@@ -1311,6 +1312,7 @@
private void init() {
OnTrimMemoryListener.init(getContext());
+ sDisableNavcache = nativeDisableNavcache();
setWillNotDraw(false);
setFocusable(true);
@@ -2618,8 +2620,8 @@
}
private HitTestResult hitTestResult(HitTestResult fallback) {
- if (mNativeClass == 0) {
- return null;
+ if (mNativeClass == 0 || sDisableNavcache) {
+ return fallback;
}
HitTestResult result = new HitTestResult();
@@ -4376,7 +4378,7 @@
|| mTouchMode == TOUCH_SHORTPRESS_MODE
|| mTouchMode == TOUCH_DONE_MODE);
boolean drawNativeRings = !drawJavaRings;
- if (USE_WEBKIT_RINGS) {
+ if (sDisableNavcache) {
drawNativeRings = !drawJavaRings && !isInTouchMode();
}
drawContent(canvas, drawNativeRings);
@@ -4431,8 +4433,8 @@
}
private void removeTouchHighlight() {
- mWebViewCore.removeMessages(EventHub.GET_TOUCH_HIGHLIGHT_RECTS);
- mPrivateHandler.removeMessages(SET_TOUCH_HIGHLIGHT_RECTS);
+ mWebViewCore.removeMessages(EventHub.HIT_TEST);
+ mPrivateHandler.removeMessages(HIT_TEST_RESULT);
setTouchHighlightRects(null);
}
@@ -6198,7 +6200,7 @@
nativeSetIsScrolling(false);
} else if (mPrivateHandler.hasMessages(RELEASE_SINGLE_TAP)) {
mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
- if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (sDisableNavcache) {
removeTouchHighlight();
}
if (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare) {
@@ -6222,7 +6224,7 @@
mWebViewCore.sendMessage(
EventHub.UPDATE_FRAME_CACHE_IF_LOADING);
}
- if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (sDisableNavcache) {
TouchHighlightData data = new TouchHighlightData();
data.mX = contentX;
data.mY = contentY;
@@ -6234,7 +6236,7 @@
if (!mBlockWebkitViewMessages) {
mTouchHighlightRequested = System.currentTimeMillis();
mWebViewCore.sendMessageAtFrontOfQueue(
- EventHub.GET_TOUCH_HIGHLIGHT_RECTS, data);
+ EventHub.HIT_TEST, data);
}
if (DEBUG_TOUCH_HIGHLIGHT) {
if (getSettings().getNavDump()) {
@@ -6322,7 +6324,7 @@
if (mTouchMode == TOUCH_DOUBLE_TAP_MODE) {
mTouchMode = TOUCH_INIT_MODE;
}
- if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (sDisableNavcache) {
removeTouchHighlight();
}
}
@@ -6924,7 +6926,7 @@
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
- if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (sDisableNavcache) {
removeTouchHighlight();
}
mHeldMotionless = MOTIONLESS_TRUE;
@@ -7481,7 +7483,7 @@
* and calls showCursorTimed on the native side
*/
private void updateSelection() {
- if (mNativeClass == 0) {
+ if (mNativeClass == 0 || sDisableNavcache) {
return;
}
mPrivateHandler.removeMessages(UPDATE_SELECTION);
@@ -7589,7 +7591,7 @@
int contentX = viewToContentX(mLastTouchX + mScrollX);
int contentY = viewToContentY(mLastTouchY + mScrollY);
int slop = viewToContentDimension(mNavSlop);
- if (USE_WEBKIT_RINGS && !mTouchHighlightRegion.isEmpty()) {
+ if (sDisableNavcache && !mTouchHighlightRegion.isEmpty()) {
// set mTouchHighlightRequested to 0 to cause an immediate
// drawing of the touch rings
mTouchHighlightRequested = 0;
@@ -7601,8 +7603,7 @@
}
}, ViewConfiguration.getPressedStateDuration());
}
- if (getSettings().supportTouchOnly()) {
- removeTouchHighlight();
+ if (sDisableNavcache) {
WebViewCore.TouchUpData touchUpData = new WebViewCore.TouchUpData();
// use "0" as generation id to inform WebKit to use the same x/y as
// it used when processing GET_TOUCH_HIGHLIGHT_RECTS
@@ -8487,9 +8488,8 @@
break;
}
case SWITCH_TO_SHORTPRESS: {
- mInitialHitTestResult = null; // set by updateSelection()
if (mTouchMode == TOUCH_INIT_MODE) {
- if (!getSettings().supportTouchOnly()
+ if (!sDisableNavcache
&& mPreventDefault != PREVENT_DEFAULT_YES) {
mTouchMode = TOUCH_SHORTPRESS_START_MODE;
updateSelection();
@@ -8504,7 +8504,7 @@
break;
}
case SWITCH_TO_LONGPRESS: {
- if (USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (sDisableNavcache) {
removeTouchHighlight();
}
if (inFullScreenMode() || mDeferTouchProcess) {
@@ -8835,10 +8835,16 @@
}
break;
- case SET_TOUCH_HIGHLIGHT_RECTS:
- @SuppressWarnings("unchecked")
- ArrayList<Rect> rects = (ArrayList<Rect>) msg.obj;
- setTouchHighlightRects(rects);
+ case HIT_TEST_RESULT:
+ WebKitHitTest hit = (WebKitHitTest) msg.obj;
+ setTouchHighlightRects(hit != null ? hit.mTouchRects : null);
+ if (hit == null) {
+ mInitialHitTestResult = null;
+ } else {
+ mInitialHitTestResult = new HitTestResult();
+ mInitialHitTestResult.mType = hit.mType;
+ mInitialHitTestResult.mExtra = hit.mExtra;
+ }
break;
case SAVE_WEBARCHIVE_FINISHED:
@@ -8875,7 +8881,7 @@
}
}
- private void setTouchHighlightRects(ArrayList<Rect> rects) {
+ private void setTouchHighlightRects(Rect[] rects) {
invalidate(mTouchHighlightRegion.getBounds());
mTouchHighlightRegion.setEmpty();
if (rects != null) {
@@ -9793,4 +9799,5 @@
*/
private static native void nativeOnTrimMemory(int level);
private static native void nativeSetPauseDrawing(int instance, boolean pause);
+ private static native boolean nativeDisableNavcache();
}
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 95533c6..824f556 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -860,6 +860,12 @@
Rect mNativeLayerRect;
}
+ static class WebKitHitTest {
+ int mType;
+ String mExtra;
+ Rect[] mTouchRects;
+ }
+
static class AutoFillData {
public AutoFillData() {
mQueryId = WebTextView.FORM_NOT_AUTOFILLABLE;
@@ -1072,7 +1078,7 @@
static final int ADD_PACKAGE_NAME = 185;
static final int REMOVE_PACKAGE_NAME = 186;
- static final int GET_TOUCH_HIGHLIGHT_RECTS = 187;
+ static final int HIT_TEST = 187;
// accessibility support
static final int MODIFY_SELECTION = 190;
@@ -1550,7 +1556,7 @@
break;
case MODIFY_SELECTION:
- String modifiedSelectionString =
+ String modifiedSelectionString =
nativeModifySelection(mNativeClass, msg.arg1,
msg.arg2);
mWebView.mPrivateHandler.obtainMessage(WebView.SELECTION_STRING_CHANGED,
@@ -1671,16 +1677,16 @@
(Set<String>) msg.obj);
break;
- case GET_TOUCH_HIGHLIGHT_RECTS:
+ case HIT_TEST:
TouchHighlightData d = (TouchHighlightData) msg.obj;
if (d.mNativeLayer != 0) {
nativeScrollLayer(mNativeClass,
d.mNativeLayer, d.mNativeLayerRect);
}
- ArrayList<Rect> rects = nativeGetTouchHighlightRects
- (mNativeClass, d.mX, d.mY, d.mSlop);
+ WebKitHitTest hit = nativeHitTest(mNativeClass,
+ d.mX, d.mY, d.mSlop);
mWebView.mPrivateHandler.obtainMessage(
- WebView.SET_TOUCH_HIGHLIGHT_RECTS, rects)
+ WebView.HIT_TEST_RESULT, hit)
.sendToTarget();
break;
@@ -2335,9 +2341,9 @@
}
// remove the touch highlight when moving to a new page
- if (WebView.USE_WEBKIT_RINGS || getSettings().supportTouchOnly()) {
+ if (WebView.sDisableNavcache) {
mWebView.mPrivateHandler.sendEmptyMessage(
- WebView.SET_TOUCH_HIGHLIGHT_RECTS);
+ WebView.HIT_TEST_RESULT);
}
// reset the scroll position, the restored offset and scales
@@ -2927,8 +2933,7 @@
private native boolean nativeValidNodeAndBounds(int nativeClass, int frame,
int node, Rect bounds);
- private native ArrayList<Rect> nativeGetTouchHighlightRects(int nativeClass,
- int x, int y, int slop);
+ private native WebKitHitTest nativeHitTest(int nativeClass, int x, int y, int slop);
private native void nativeAutoFillForm(int nativeClass, int queryId);
private native void nativeScrollLayer(int nativeClass, int layer, Rect rect);
diff --git a/core/jni/android_bluetooth_HeadsetBase.cpp b/core/jni/android_bluetooth_HeadsetBase.cpp
index a982182..0df211a 100644
--- a/core/jni/android_bluetooth_HeadsetBase.cpp
+++ b/core/jni/android_bluetooth_HeadsetBase.cpp
@@ -163,7 +163,7 @@
bufit++;
}
- *bufit = NULL;
+ *bufit = 0;
// According to ITU V.250 section 5.1, IA5 7 bit chars are used,
// the eighth bit or higher bits are ignored if they exists
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 4067324..d921685 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -240,7 +240,7 @@
// compute the frame count
int bytesPerSample = audioFormat == javaAudioTrackFields.PCM16 ? 2 : 1;
- int format = audioFormat == javaAudioTrackFields.PCM16 ?
+ audio_format_t format = audioFormat == javaAudioTrackFields.PCM16 ?
AUDIO_FORMAT_PCM_16_BIT : AUDIO_FORMAT_PCM_8_BIT;
int frameCount = buffSizeInBytes / (nbChannels * bytesPerSample);
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp
index c475261..6c11121 100644
--- a/core/jni/android_server_BluetoothService.cpp
+++ b/core/jni/android_server_BluetoothService.cpp
@@ -1035,7 +1035,7 @@
DBUS_ADAPTER_IFACE, "RemoveReservedServiceRecords",
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
&values, len, DBUS_TYPE_INVALID);
- env->ReleaseIntArrayElements(handles, values, NULL);
+ env->ReleaseIntArrayElements(handles, values, 0);
return reply ? JNI_TRUE : JNI_FALSE;
#endif
return JNI_FALSE;
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 6ecee35..17130af 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -434,12 +434,12 @@
{
ScopedUtfChars path8(env, path);
if (path8.c_str() == NULL) {
- return NULL;
+ return 0;
}
AssetManager* am = assetManagerForJavaObject(env, clazz);
if (am == NULL) {
- return JNI_FALSE;
+ return 0;
}
void* cookie;
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 2c494ac..8234f1b 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -389,7 +389,7 @@
jlong mem = 0;
static const char* const sums[] = { "MemFree:", "Cached:", NULL };
- static const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), NULL };
+ static const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 };
char* p = buffer;
while (*p && numFound < 2) {
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index 0580ebc..d375d4c 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -249,8 +249,6 @@
sleep(SHORT_TIMEOUT);
removeConfiguredNetworksAndDisableWifi();
mWifiRegexs = mCM.getTetherableWifiRegexs();
- // after wifi is shutdown, wait for 2 minute to enable wifi
- sleep(WIFI_STOP_START_INTERVAL);
}
public List<WifiConfiguration> loadNetworkConfigurations() throws Exception {
diff --git a/docs/html/guide/topics/wireless/bluetooth.jd b/docs/html/guide/topics/wireless/bluetooth.jd
index e4c6e1b..76da08e 100644
--- a/docs/html/guide/topics/wireless/bluetooth.jd
+++ b/docs/html/guide/topics/wireless/bluetooth.jd
@@ -29,6 +29,7 @@
<li><a href="#Profiles">Working with Profiles</a>
<ol>
<li><a href="#AT-Commands">Vendor-specific AT commands</a>
+ <li><a href="#HDP">Health Device Profile</a>
</ol></li>
</ol>
@@ -43,6 +44,7 @@
<h2>Related samples</h2>
<ol>
<li><a href="{@docRoot}resources/samples/BluetoothChat/index.html">Bluetooth Chat</a></li>
+ <li><a href="{@docRoot}resources/samples/BluetoothHDP/index.html">Bluetooth HDP (Health Device Profile)</a></li>
</ol>
</div>
@@ -132,11 +134,27 @@
audio can be streamed from one device to another over a Bluetooth connection.
"A2DP" stands for Advanced Audio Distribution Profile.</dd>
-<dt>{@link android.bluetooth.BluetoothProfile.ServiceListener}</dt>
+<dt>{@link android.bluetooth.BluetoothHealth}</dt>
+<dd> Represents a Health Device Profile proxy that controls the Bluetooth service.</dd>
+
+<dt>{@link android.bluetooth.BluetoothHealthCallback}</dt>
+
+<dd>An abstract class that you use to implement {@link
+android.bluetooth.BluetoothHealth} callbacks. You must extend this class and
+implement the callback methods to receive updates about changes in the
+application’s registration state and Bluetooth channel state.</dd>
+
+<dt>{@link android.bluetooth.BluetoothHealthAppConfiguration}</dt>
+
+<dd>Represents an application configuration that the Bluetooth Health third-party
+application registers to communicate with a remote Bluetooth health
+device.</dd>
+
+<dt>{@link android.bluetooth.BluetoothProfile.ServiceListener}</dt>
<dd>An interface that notifies {@link android.bluetooth.BluetoothProfile} IPC
clients when they have been connected to or disconnected from the service (that
-is, the internal service that runs a particular profile). </dd>
+is, the internal service that runs a particular profile). </dd>
</dl>
@@ -889,7 +907,7 @@
href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#IPC">IPC</a
>). This includes both Bluetooth Headset and Hands-Free (v1.5) profiles. The
{@link android.bluetooth.BluetoothHeadset} class includes support for AT commands.
-For more discussion of this topic, see <a href="#AT-Commands">Vendor-specific AT commands</a></li>
+For more discussion of this topic, see <a href="#AT-Commands">Vendor-specific AT commands</a></li>
<li><strong>A2DP</strong>. The Advanced Audio Distribution Profile (A2DP)
profile defines how high quality audio can be streamed from one device to
@@ -897,6 +915,17 @@
android.bluetooth.BluetoothA2dp} class, which is a proxy for controlling
the Bluetooth A2DP Service via IPC.</li>
+ <li><strong>Health Device</strong>. Android 4.0 (API level 14) introduces
+support for the Bluetooth Health Device Profile (HDP). This lets you create
+applications that use Bluetooth to communicate with health devices that support
+Bluetooth, such as heart-rate monitors, blood meters, thermometers, scales, and
+so on. For a list of supported devices and their corresponding device data
+specialization codes, refer to <strong>Bluetooth Assigned Numbers</strong> at <a
+href="http://www.bluetooth.org">www.bluetooth.org</a>. Note that these values
+are also referenced in the ISO/IEEE 11073-20601 [7] specification as
+MDC_DEV_SPEC_PROFILE_* in the Nomenclature Codes Annex. For more discussion of
+HDP, see <a href="#HDP">Health Device Profile</a>.</li>
+
</ul>
<p>Here are the basic steps for working with a profile:</p>
@@ -926,7 +955,9 @@
state of the connection and perform other operations that are relevant to that
profile.</li>
</ol>
-<p> For example, this code snippet shows how to connect to a {@link android.bluetooth.BluetoothHeadset} proxy object so that you can control the
+
+<p> For example, this code snippet shows how to connect to a {@link
+android.bluetooth.BluetoothHeadset} proxy object so that you can control the
Headset profile:</p>
<pre>BluetoothHeadset mBluetoothHeadset;
@@ -956,6 +987,8 @@
mBluetoothAdapter.closeProfileProxy(mBluetoothHeadset);
</pre>
+
+
<h3 id="AT-Commands">Vendor-specific AT commands</h3>
<p>Starting in Android 3.0, applications can register to receive system
@@ -965,3 +998,81 @@
user or take other action as needed. Create a broadcast receiver for the {@link
android.bluetooth.BluetoothHeadset#ACTION_VENDOR_SPECIFIC_HEADSET_EVENT} intent
to handle vendor-specific AT commands for the headset.</p>
+
+<h3 id="HDP">Health Device Profile</h3>
+
+<p>Android 4.0 (API level 14) introduces support for the Bluetooth Health Device
+Profile (HDP). This lets you create applications that use Bluetooth to
+communicate with health devices that support Bluetooth, such as heart-rate
+monitors, blood meters, thermometers, and scales. The Bluetooth Health API
+includes the classes {@link android.bluetooth.BluetoothHealth}, {@link
+android.bluetooth.BluetoothHealthCallback}, and {@link
+android.bluetooth.BluetoothHealthAppConfiguration}, which are described in <a
+href="#TheBasics">The Basics</a>. </p>
+
+<p>In using the Bluetooth Health API, it's helpful to understand these key HDP concepts:</p>
+<table>
+ <tr>
+ <th>Concept</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td><strong>Source</strong></td>
+
+ <td>A role defined in HDP. A <em>source</em> is a health device that
+transmits medical data (weight scale, glucose meter, thermometer, etc.) to a
+smart device such as an Android phone or tablet. </td>
+ </tr>
+ <tr>
+ <td><strong>Sink</strong></td>
+
+ <td>A role defined in HDP. In HDP, a <em>sink</em> is the smart device that
+receives the medical data. In an Android HDP application, the sink is
+represented by a {@link android.bluetooth.BluetoothHealthAppConfiguration}
+object.</td>
+ </tr>
+ <tr>
+ <td><strong>Registration</strong></td>
+ <td>Refers to registering a sink for a particular health device.</td>
+ </tr>
+ <tr>
+ <td><strong>Connection</strong></td>
+
+ <td>Refers to opening a channel between a health device and a smart device
+such as an Android phone or tablet.</td>
+ </tr>
+</table>
+
+<h4>Creating an HDP Application</h4>
+
+<p>Here are the basic steps involved in creating an Android HDP application:</p>
+<ol>
+
+ <li>Get a reference to the {@link android.bluetooth.BluetoothHealth} proxy
+object. <p>Similar to regular headset and A2DP profile devices, you must call
+{@link android.bluetooth.BluetoothAdapter#getProfileProxy getProfileProxy()}
+with a {@link android.bluetooth.BluetoothProfile.ServiceListener} and the {@link
+android.bluetooth.BluetoothProfile.ServiceListener#HEALTH} profile type to
+establish a connection with the profile proxy object.</p> </li>
+
+ <li>Create a {@link android.bluetooth.BluetoothHealthCallback} and register an
+application configuration
+({@link android.bluetooth.BluetoothHealthAppConfiguration})
+that acts as a health
+sink.</li>
+
+ <li>Establish a connection to a health device. Some devices will initiate the
+connection. It is unnecessary to carry out this step for those devices.</li>
+
+ <li>When connected successfully to a health device, read/write to the health
+device using the file descriptor. <p>The received data needs to be interpreted
+using a health manager which implements the IEEE 11073-xxxxx
+specifications.</p></li>
+
+ <li>When done, close the health channel and unregister the application. The
+channel also closes when there is extended inactivity.</li>
+</ol>
+
+<p>For a complete code sample that illustrates these steps, see <a
+href="{@docRoot}resources/samples/BluetoothHDP/index.html">Bluetooth HDP (Health
+Device Profile)</a>. </p>
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 98b2c70..60b052bd9 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -69,7 +69,8 @@
MUTE = 0x00000001
};
uint32_t flags;
- int format;
+ audio_format_t format; // but AUDIO_FORMAT_PCM_8_BIT -> AUDIO_FORMAT_PCM_16_BIT
+ // accessed directly by WebKit ANP callback
int channelCount; // will be removed in the future, do not use
size_t frameCount;
size_t size;
@@ -143,7 +144,7 @@
AudioTrack( int streamType,
uint32_t sampleRate = 0,
- int format = 0,
+ audio_format_t format = AUDIO_FORMAT_DEFAULT,
int channelMask = 0,
int frameCount = 0,
uint32_t flags = 0,
@@ -163,7 +164,7 @@
AudioTrack( int streamType,
uint32_t sampleRate = 0,
- int format = 0,
+ audio_format_t format = AUDIO_FORMAT_DEFAULT,
int channelMask = 0,
const sp<IMemory>& sharedBuffer = 0,
uint32_t flags = 0,
@@ -187,7 +188,7 @@
* */
status_t set(int streamType =-1,
uint32_t sampleRate = 0,
- int format = 0,
+ audio_format_t format = AUDIO_FORMAT_DEFAULT,
int channelMask = 0,
int frameCount = 0,
uint32_t flags = 0,
@@ -215,7 +216,7 @@
/* getters, see constructor */
int streamType() const;
- int format() const;
+ audio_format_t format() const;
int channelCount() const;
uint32_t frameCount() const;
int frameSize() const;
@@ -434,7 +435,7 @@
bool processAudioBuffer(const sp<AudioTrackThread>& thread);
status_t createTrack_l(int streamType,
uint32_t sampleRate,
- uint32_t format,
+ audio_format_t format,
uint32_t channelMask,
int frameCount,
uint32_t flags,
@@ -456,7 +457,7 @@
uint32_t mFrameCount;
audio_track_cblk_t* mCblk;
- uint32_t mFormat;
+ audio_format_t mFormat;
uint8_t mStreamType;
uint8_t mChannelCount;
uint8_t mMuted;
diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h
index 3fa2bf8..b83e552 100644
--- a/include/media/IAudioTrack.h
+++ b/include/media/IAudioTrack.h
@@ -35,6 +35,9 @@
public:
DECLARE_META_INTERFACE(AudioTrack);
+ /* Get this track's control block */
+ virtual sp<IMemory> getCblk() const = 0;
+
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
@@ -67,8 +70,6 @@
*/
virtual status_t attachAuxEffect(int effectId) = 0;
- /* get this track's control block */
- virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
index 93bbe13..4f46fcd 100644
--- a/include/media/IMediaPlayerService.h
+++ b/include/media/IMediaPlayerService.h
@@ -23,6 +23,7 @@
#include <utils/String8.h>
#include <binder/IInterface.h>
#include <binder/Parcel.h>
+#include <system/audio.h>
#include <media/IMediaPlayerClient.h>
#include <media/IMediaPlayer.h>
@@ -43,8 +44,8 @@
virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid) = 0;
virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId = 0) = 0;
- virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
- virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
+ virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
virtual sp<IOMX> getOMX() = 0;
// codecs and audio devices usage tracking for the battery app
diff --git a/include/media/JetPlayer.h b/include/media/JetPlayer.h
index 6d53989..491a950 100644
--- a/include/media/JetPlayer.h
+++ b/include/media/JetPlayer.h
@@ -94,7 +94,7 @@
S_JET_STATUS mJetStatus;
S_JET_STATUS mPreviousJetStatus;
- char mJetFilePath[256];
+ char mJetFilePath[PATH_MAX];
class JetPlayerThread : public Thread {
public:
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 80f43a3..1f6bdda 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -85,7 +85,7 @@
// audio data.
virtual status_t open(
uint32_t sampleRate, int channelCount,
- int format=AUDIO_FORMAT_PCM_16_BIT,
+ audio_format_t format=AUDIO_FORMAT_PCM_16_BIT,
int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
AudioCallback cb = NULL,
void *cookie = NULL) = 0;
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index e6a0cc5..2dc055e 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -190,8 +190,8 @@
bool isLooping();
status_t setVolume(float leftVolume, float rightVolume);
void notify(int msg, int ext1, int ext2, const Parcel *obj = NULL);
- static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
- static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
+ static sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
+ static sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
status_t invoke(const Parcel& request, Parcel *reply);
status_t setMetadataFilter(const Parcel& filter);
status_t getMetadata(bool update_only, bool apply_filter, Parcel *metadata);
diff --git a/include/ui/GraphicLog.h b/include/ui/GraphicLog.h
deleted file mode 100644
index ee1b09a..0000000
--- a/include/ui/GraphicLog.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _UI_GRAPHIC_LOG_H
-#define _UI_GRAPHIC_LOG_H
-
-#include <utils/Singleton.h>
-#include <cutils/compiler.h>
-
-namespace android {
-
-class GraphicLog : public Singleton<GraphicLog>
-{
- int32_t mEnabled;
- static void logImpl(int32_t tag, int32_t buffer);
- static void logImpl(int32_t tag, int32_t identity, int32_t buffer);
-
-public:
- enum {
- SF_APP_DEQUEUE_BEFORE = 60100,
- SF_APP_DEQUEUE_AFTER = 60101,
- SF_APP_LOCK_BEFORE = 60102,
- SF_APP_LOCK_AFTER = 60103,
- SF_APP_QUEUE = 60104,
-
- SF_REPAINT = 60105,
- SF_COMPOSITION_COMPLETE = 60106,
- SF_UNLOCK_CLIENTS = 60107,
- SF_SWAP_BUFFERS = 60108,
- SF_REPAINT_DONE = 60109,
-
- SF_FB_POST_BEFORE = 60110,
- SF_FB_POST_AFTER = 60111,
- SF_FB_DEQUEUE_BEFORE = 60112,
- SF_FB_DEQUEUE_AFTER = 60113,
- SF_FB_LOCK_BEFORE = 60114,
- SF_FB_LOCK_AFTER = 60115,
- };
-
- inline void log(int32_t tag, int32_t buffer) {
- if (CC_UNLIKELY(mEnabled))
- logImpl(tag, buffer);
- }
- inline void log(int32_t tag, int32_t identity, int32_t buffer) {
- if (CC_UNLIKELY(mEnabled))
- logImpl(tag, identity, buffer);
- }
-
- GraphicLog();
-
- void setEnabled(bool enable);
-};
-
-}
-
-#endif // _UI_GRAPHIC_LOG_H
-
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
index fbabfc4..f8b4452 100644
--- a/libs/ui/Android.mk
+++ b/libs/ui/Android.mk
@@ -47,7 +47,6 @@
GraphicBuffer.cpp \
GraphicBufferAllocator.cpp \
GraphicBufferMapper.cpp \
- GraphicLog.cpp \
InputTransport.cpp \
PixelFormat.cpp \
Rect.cpp \
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index f5ed981..d1dca0c 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -29,7 +29,6 @@
#include <ui/Rect.h>
#include <ui/FramebufferNativeWindow.h>
-#include <ui/GraphicLog.h>
#include <EGL/egl.h>
@@ -211,9 +210,6 @@
if (self->mBufferHead >= self->mNumBuffers)
self->mBufferHead = 0;
- GraphicLog& logger(GraphicLog::getInstance());
- logger.log(GraphicLog::SF_FB_DEQUEUE_BEFORE, index);
-
// wait for a free buffer
while (!self->mNumFreeBuffers) {
self->mCondition.wait(self->mutex);
@@ -224,7 +220,6 @@
*buffer = self->buffers[index].get();
- logger.log(GraphicLog::SF_FB_DEQUEUE_AFTER, index);
return 0;
}
@@ -235,16 +230,12 @@
Mutex::Autolock _l(self->mutex);
const int index = self->mCurrentBufferIndex;
- GraphicLog& logger(GraphicLog::getInstance());
- logger.log(GraphicLog::SF_FB_LOCK_BEFORE, index);
// wait that the buffer we're locking is not front anymore
while (self->front == buffer) {
self->mCondition.wait(self->mutex);
}
- logger.log(GraphicLog::SF_FB_LOCK_AFTER, index);
-
return NO_ERROR;
}
@@ -257,13 +248,7 @@
buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle;
const int index = self->mCurrentBufferIndex;
- GraphicLog& logger(GraphicLog::getInstance());
- logger.log(GraphicLog::SF_FB_POST_BEFORE, index);
-
int res = fb->post(fb, handle);
-
- logger.log(GraphicLog::SF_FB_POST_AFTER, index);
-
self->front = static_cast<NativeBuffer*>(buffer);
self->mNumFreeBuffers++;
self->mCondition.broadcast();
diff --git a/libs/ui/GraphicLog.cpp b/libs/ui/GraphicLog.cpp
deleted file mode 100644
index 7ba2779..0000000
--- a/libs/ui/GraphicLog.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <cutils/log.h>
-#include <cutils/properties.h>
-#include <utils/Endian.h>
-#include <utils/Timers.h>
-
-#include <ui/GraphicLog.h>
-
-namespace android {
-
-ANDROID_SINGLETON_STATIC_INSTANCE(GraphicLog)
-
-static inline
-void writeInt32(uint8_t* base, size_t& pos, int32_t value) {
-#ifdef HAVE_LITTLE_ENDIAN
- int32_t v = value;
-#else
- int32_t v = htole32(value);
-#endif
- base[pos] = EVENT_TYPE_INT;
- memcpy(&base[pos+1], &v, sizeof(int32_t));
- pos += 1+sizeof(int32_t);
-}
-
-static inline
-void writeInt64(uint8_t* base, size_t& pos, int64_t value) {
-#ifdef HAVE_LITTLE_ENDIAN
- int64_t v = value;
-#else
- int64_t v = htole64(value);
-#endif
- base[pos] = EVENT_TYPE_LONG;
- memcpy(&base[pos+1], &v, sizeof(int64_t));
- pos += 1+sizeof(int64_t);
-}
-
-void GraphicLog::logImpl(int32_t tag, int32_t buffer)
-{
- uint8_t scratch[2 + 2 + sizeof(int32_t) + sizeof(int64_t)];
- size_t pos = 0;
- scratch[pos++] = EVENT_TYPE_LIST;
- scratch[pos++] = 2;
- writeInt32(scratch, pos, buffer);
- writeInt64(scratch, pos, ns2ms( systemTime( SYSTEM_TIME_MONOTONIC ) ));
- android_bWriteLog(tag, scratch, sizeof(scratch));
-}
-
-void GraphicLog::logImpl(int32_t tag, int32_t identity, int32_t buffer)
-{
- uint8_t scratch[2 + 3 + sizeof(int32_t) + sizeof(int32_t) + sizeof(int64_t)];
- size_t pos = 0;
- scratch[pos++] = EVENT_TYPE_LIST;
- scratch[pos++] = 3;
- writeInt32(scratch, pos, buffer);
- writeInt32(scratch, pos, identity);
- writeInt64(scratch, pos, ns2ms( systemTime( SYSTEM_TIME_MONOTONIC ) ));
- android_bWriteLog(tag, scratch, sizeof(scratch));
-}
-
-GraphicLog::GraphicLog()
- : mEnabled(0)
-{
- char property[PROPERTY_VALUE_MAX];
- if (property_get("debug.graphic_log", property, NULL) > 0) {
- mEnabled = atoi(property);
- }
-}
-
-void GraphicLog::setEnabled(bool enable)
-{
- mEnabled = enable;
-}
-
-}
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 55074aa..b06ef95 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -313,15 +313,8 @@
private final String mExternalStoragePath;
// WARNING: Bulk inserts sounded like a great idea and gave us a good performance improvement,
- // but unfortunately it also introduced a number of bugs. Many of those bugs were fixed,
- // but (at least) one problem is still outstanding:
- //
- // - Bulk inserts broke the code that sets the default ringtones, notifications, and alarms
- // on first boot
- //
- // This problem might be solvable by moving the logic to the media provider or disabling bulk
- // inserts only for those cases. For now, we are disabling bulk inserts until we have a solid
- // fix for this problem.
+ // but unfortunately it also introduced a number of bugs. All the known bugs were fixed,
+ // but we need more testing before enabling.
private static final boolean ENABLE_BULK_INSERTS = false;
// used when scanning the image database so we know whether we have to prune
@@ -895,6 +888,7 @@
}
}
Uri result = null;
+ boolean needToSetSettings = false;
if (rowId == 0) {
if (mMtpObjectHandle != 0) {
values.put(MediaStore.MediaColumns.MEDIA_SCANNER_NEW_OBJECT_ID, mMtpObjectHandle);
@@ -906,12 +900,37 @@
}
values.put(Files.FileColumns.FORMAT, format);
}
+ // Setting a flag in order not to use bulk insert for the file related with
+ // notifications, ringtones, and alarms, because the rowId of the inserted file is
+ // needed.
+ if (mWasEmptyPriorToScan) {
+ if (notifications && !mDefaultNotificationSet) {
+ if (TextUtils.isEmpty(mDefaultNotificationFilename) ||
+ doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename)) {
+ needToSetSettings = true;
+ }
+ } else if (ringtones && !mDefaultRingtoneSet) {
+ if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
+ doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
+ needToSetSettings = true;
+ }
+ } else if (alarms && !mDefaultAlarmSet) {
+ if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) ||
+ doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) {
+ needToSetSettings = true;
+ }
+ }
+ }
+
// new file, insert it
// We insert directories immediately to ensure they are in the database
// before the files they contain.
// Otherwise we can get duplicate directory entries in the database
// if one of the media FileInserters is flushed before the files table FileInserter
- if (inserter == null || entry.mFormat == MtpConstants.FORMAT_ASSOCIATION) {
+ // Also, we immediately insert the file if the rowId of the inserted file is
+ // needed.
+ if (inserter == null || needToSetSettings ||
+ entry.mFormat == MtpConstants.FORMAT_ASSOCIATION) {
result = mMediaProvider.insert(tableUri, values);
} else {
inserter.insert(tableUri, values);
@@ -930,21 +949,14 @@
mMediaProvider.update(result, values, null, null);
}
- if (notifications && mWasEmptyPriorToScan && !mDefaultNotificationSet) {
- if (TextUtils.isEmpty(mDefaultNotificationFilename) ||
- doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename)) {
+ if(needToSetSettings) {
+ if (notifications) {
setSettingIfNotSet(Settings.System.NOTIFICATION_SOUND, tableUri, rowId);
mDefaultNotificationSet = true;
- }
- } else if (ringtones && mWasEmptyPriorToScan && !mDefaultRingtoneSet) {
- if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
- doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
+ } else if (ringtones) {
setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
mDefaultRingtoneSet = true;
- }
- } else if (alarms && mWasEmptyPriorToScan && !mDefaultAlarmSet) {
- if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) ||
- doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) {
+ } else if (alarms) {
setSettingIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId);
mDefaultAlarmSet = true;
}
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index 14a5309..b5303ef 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -496,7 +496,7 @@
{
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> p;
ALOGV("Start decode");
if (mUrl) {
diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h
index 6010aac..1b91b3b 100644
--- a/media/jni/soundpool/SoundPool.h
+++ b/media/jni/soundpool/SoundPool.h
@@ -56,7 +56,7 @@
int sampleID() { return mSampleID; }
int numChannels() { return mNumChannels; }
int sampleRate() { return mSampleRate; }
- int format() { return mFormat; }
+ audio_format_t format() { return mFormat; }
size_t size() { return mSize; }
int state() { return mState; }
uint8_t* data() { return static_cast<uint8_t*>(mData->pointer()); }
@@ -65,7 +65,7 @@
sp<IMemory> getIMemory() { return mData; }
// hack
- void init(int numChannels, int sampleRate, int format, size_t size, sp<IMemory> data ) {
+ void init(int numChannels, int sampleRate, audio_format_t format, size_t size, sp<IMemory> data ) {
mNumChannels = numChannels; mSampleRate = sampleRate; mFormat = format; mSize = size; mData = data; }
private:
@@ -77,7 +77,7 @@
uint16_t mSampleRate;
uint8_t mState : 3;
uint8_t mNumChannels : 2;
- uint8_t mFormat : 2;
+ audio_format_t mFormat;
int mFd;
int64_t mOffset;
int64_t mLength;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 2674070..8e4a9d6 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -208,9 +208,6 @@
if (cbf != 0) {
mClientRecordThread = new ClientRecordThread(*this, threadCanCallJava);
- if (mClientRecordThread == 0) {
- return NO_INIT;
- }
}
mStatus = NO_ERROR;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index f7f129c..9d4137e 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -38,7 +38,7 @@
DefaultKeyedVector<int, audio_io_handle_t> AudioSystem::gStreamOutputMap(0);
DefaultKeyedVector<audio_io_handle_t, AudioSystem::OutputDescriptor *> AudioSystem::gOutputs(0);
-// Cached values for recording queries
+// Cached values for recording queries, all protected by gLock
uint32_t AudioSystem::gPrevInSamplingRate = 16000;
int AudioSystem::gPrevInFormat = AUDIO_FORMAT_PCM_16_BIT;
int AudioSystem::gPrevInChannelCount = 1;
@@ -158,7 +158,7 @@
status_t AudioSystem::setMode(int mode)
{
- if (mode >= AUDIO_MODE_CNT) return BAD_VALUE;
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
return af->setMode(mode);
@@ -301,22 +301,27 @@
status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, int format, int channelCount,
size_t* buffSize)
{
+ gLock.lock();
// Do we have a stale gInBufferSize or are we requesting the input buffer size for new values
- if ((gInBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
+ size_t inBuffSize = gInBuffSize;
+ if ((inBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
|| (channelCount != gPrevInChannelCount)) {
+ gLock.unlock();
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) {
+ return PERMISSION_DENIED;
+ }
+ inBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+ gLock.lock();
// save the request params
gPrevInSamplingRate = sampleRate;
gPrevInFormat = format;
gPrevInChannelCount = channelCount;
- gInBuffSize = 0;
- const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
- if (af == 0) {
- return PERMISSION_DENIED;
- }
- gInBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+ gInBuffSize = inBuffSize;
}
- *buffSize = gInBuffSize;
+ gLock.unlock();
+ *buffSize = inBuffSize;
return NO_ERROR;
}
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 191fbaf..9c650ad 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -85,7 +85,7 @@
AudioTrack::AudioTrack(
int streamType,
uint32_t sampleRate,
- int format,
+ audio_format_t format,
int channelMask,
int frameCount,
uint32_t flags,
@@ -104,7 +104,7 @@
AudioTrack::AudioTrack(
int streamType,
uint32_t sampleRate,
- int format,
+ audio_format_t format,
int channelMask,
const sp<IMemory>& sharedBuffer,
uint32_t flags,
@@ -142,7 +142,7 @@
status_t AudioTrack::set(
int streamType,
uint32_t sampleRate,
- int format,
+ audio_format_t format,
int channelMask,
int frameCount,
uint32_t flags,
@@ -179,7 +179,7 @@
sampleRate = afSampleRate;
}
// these below should probably come from the audioFlinger too...
- if (format == 0) {
+ if (format == AUDIO_FORMAT_DEFAULT) {
format = AUDIO_FORMAT_PCM_16_BIT;
}
if (channelMask == 0) {
@@ -205,7 +205,7 @@
audio_io_handle_t output = AudioSystem::getOutput(
(audio_stream_type_t)streamType,
- sampleRate,format, channelMask,
+ sampleRate, format, channelMask,
(audio_policy_output_flags_t)flags);
if (output == 0) {
@@ -224,7 +224,7 @@
// create the IAudioTrack
status_t status = createTrack_l(streamType,
sampleRate,
- (uint32_t)format,
+ format,
(uint32_t)channelMask,
frameCount,
flags,
@@ -238,16 +238,12 @@
if (cbf != 0) {
mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
- if (mAudioTrackThread == 0) {
- ALOGE("Could not create callback thread");
- return NO_INIT;
- }
}
mStatus = NO_ERROR;
mStreamType = streamType;
- mFormat = (uint32_t)format;
+ mFormat = format;
mChannelMask = (uint32_t)channelMask;
mChannelCount = channelCount;
mSharedBuffer = sharedBuffer;
@@ -284,7 +280,7 @@
return mStreamType;
}
-int AudioTrack::format() const
+audio_format_t AudioTrack::format() const
{
return mFormat;
}
@@ -717,7 +713,7 @@
status_t AudioTrack::createTrack_l(
int streamType,
uint32_t sampleRate,
- uint32_t format,
+ audio_format_t format,
uint32_t channelMask,
int frameCount,
uint32_t flags,
diff --git a/media/libmedia/IAudioTrack.cpp b/media/libmedia/IAudioTrack.cpp
index 0b372f3..e618619 100644
--- a/media/libmedia/IAudioTrack.cpp
+++ b/media/libmedia/IAudioTrack.cpp
@@ -46,6 +46,18 @@
{
}
+ virtual sp<IMemory> getCblk() const
+ {
+ Parcel data, reply;
+ sp<IMemory> cblk;
+ data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
+ status_t status = remote()->transact(GET_CBLK, data, &reply);
+ if (status == NO_ERROR) {
+ cblk = interface_cast<IMemory>(reply.readStrongBinder());
+ }
+ return cblk;
+ }
+
virtual status_t start()
{
Parcel data, reply;
@@ -88,18 +100,6 @@
remote()->transact(PAUSE, data, &reply);
}
- virtual sp<IMemory> getCblk() const
- {
- Parcel data, reply;
- sp<IMemory> cblk;
- data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
- status_t status = remote()->transact(GET_CBLK, data, &reply);
- if (status == NO_ERROR) {
- cblk = interface_cast<IMemory>(reply.readStrongBinder());
- }
- return cblk;
- }
-
virtual status_t attachAuxEffect(int effectId)
{
Parcel data, reply;
diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp
index 8e4dd04..f5b5cbd 100644
--- a/media/libmedia/IMediaPlayerService.cpp
+++ b/media/libmedia/IMediaPlayerService.cpp
@@ -78,7 +78,7 @@
return interface_cast<IMediaRecorder>(reply.readStrongBinder());
}
- virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -86,11 +86,11 @@
remote()->transact(DECODE_URL, data, &reply);
*pSampleRate = uint32_t(reply.readInt32());
*pNumChannels = reply.readInt32();
- *pFormat = reply.readInt32();
+ *pFormat = (audio_format_t) reply.readInt32();
return interface_cast<IMemory>(reply.readStrongBinder());
}
- virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+ virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -100,7 +100,7 @@
remote()->transact(DECODE_FD, data, &reply);
*pSampleRate = uint32_t(reply.readInt32());
*pNumChannels = reply.readInt32();
- *pFormat = reply.readInt32();
+ *pFormat = (audio_format_t) reply.readInt32();
return interface_cast<IMemory>(reply.readStrongBinder());
}
@@ -148,11 +148,11 @@
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
- reply->writeInt32(format);
+ reply->writeInt32((int32_t) format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
@@ -163,11 +163,11 @@
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
- int format;
+ audio_format_t format;
sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
- reply->writeInt32(format);
+ reply->writeInt32((int32_t) format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index 188e582..8456db5 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -91,7 +91,7 @@
mAudioTrack = new AudioTrack();
mAudioTrack->set(AUDIO_STREAM_MUSIC, //TODO parametrize this
pLibConfig->sampleRate,
- 1, // format = PCM 16bits per sample,
+ AUDIO_FORMAT_PCM_16_BIT,
(pLibConfig->numChannels == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
mTrackBufferSize,
0);
@@ -168,10 +168,6 @@
// allocate render buffer
mAudioBuffer =
new EAS_PCM[pLibConfig->mixBufferSize * pLibConfig->numChannels * MIX_NUM_BUFFERS];
- if (!mAudioBuffer) {
- ALOGE("JetPlayer::render(): mAudioBuffer allocate failed");
- goto threadExit;
- }
// signal main thread that we started
{
@@ -338,8 +334,8 @@
Mutex::Autolock lock(mMutex);
mEasJetFileLoc = (EAS_FILE_LOCATOR) malloc(sizeof(EAS_FILE));
- memset(mJetFilePath, 0, 256);
- strncpy(mJetFilePath, path, strlen(path));
+ strncpy(mJetFilePath, path, sizeof(mJetFilePath));
+ mJetFilePath[sizeof(mJetFilePath) - 1] = '\0';
mEasJetFileLoc->path = mJetFilePath;
mEasJetFileLoc->fd = 0;
diff --git a/media/libmedia/MediaScannerClient.cpp b/media/libmedia/MediaScannerClient.cpp
index 40b8188..9fe1820 100644
--- a/media/libmedia/MediaScannerClient.cpp
+++ b/media/libmedia/MediaScannerClient.cpp
@@ -173,6 +173,7 @@
const char* source = mValues->getEntry(i);
int targetLength = len * 3 + 1;
char* buffer = new char[targetLength];
+ // don't normally check for NULL, but in this case targetLength may be large
if (!buffer)
break;
char* target = buffer;
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 35dfbb8..9d32460 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -1017,10 +1017,6 @@
// Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
mpAudioTrack = new AudioTrack();
- if (mpAudioTrack == 0) {
- ALOGE("AudioTrack allocation failed");
- goto initAudioTrack_exit;
- }
ALOGV("Create Track: %p\n", mpAudioTrack);
mpAudioTrack->set(mStreamType,
@@ -1353,9 +1349,6 @@
new ToneGenerator::WaveGenerator((unsigned short)mSamplingRate,
frequency,
TONEGEN_GAIN/lNumWaves);
- if (lpWaveGen == 0) {
- goto prepareWave_exit;
- }
mWaveGens.add(frequency, lpWaveGen);
}
frequency = mpNewToneDesc->segments[segmentIdx].waveFreq[++freqIdx];
@@ -1375,12 +1368,6 @@
}
return true;
-
-prepareWave_exit:
-
- clearWaveGens();
-
- return false;
}
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index d08ffa5..66758d2 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -115,10 +115,6 @@
if (cbk != NULL) {
mCaptureThread = new CaptureThread(*this, rate, ((flags & CAPTURE_CALL_JAVA) != 0));
- if (mCaptureThread == 0) {
- ALOGE("Could not create callback thread");
- return NO_INIT;
- }
}
ALOGV("setCaptureCallBack() rate: %d thread %p flags 0x%08x",
rate, mCaptureThread.get(), mCaptureFlags);
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 2284927..4be960c 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -709,7 +709,7 @@
}
}
-/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> MediaPlayer::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%s)", url);
sp<IMemory> p;
@@ -729,7 +729,7 @@
notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0);
}
-/*static*/ sp<IMemory> MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+/*static*/ sp<IMemory> MediaPlayer::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%d, %lld, %lld)", fd, offset, length);
sp<IMemory> p;
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index f5cb019..af58cac 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -1149,7 +1149,7 @@
static size_t kDefaultHeapSize = 1024 * 1024; // 1MB
-sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%s)", url);
sp<MemoryBase> mem;
@@ -1197,7 +1197,7 @@
mem = new MemoryBase(cache->getHeap(), 0, cache->size());
*pSampleRate = cache->sampleRate();
*pNumChannels = cache->channelCount();
- *pFormat = (int)cache->format();
+ *pFormat = cache->format();
ALOGV("return memory @ %p, sampleRate=%u, channelCount = %d, format = %d", mem->pointer(), *pSampleRate, *pNumChannels, *pFormat);
Exit:
@@ -1205,7 +1205,7 @@
return mem;
}
-sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat)
+sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat)
{
ALOGV("decode(%d, %lld, %lld)", fd, offset, length);
sp<MemoryBase> mem;
@@ -1339,7 +1339,7 @@
}
status_t MediaPlayerService::AudioOutput::open(
- uint32_t sampleRate, int channelCount, int format, int bufferCount,
+ uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
AudioCallback cb, void *cookie)
{
mCallback = cb;
@@ -1611,7 +1611,7 @@
////////////////////////////////////////////////////////////////////////////////
status_t MediaPlayerService::AudioCache::open(
- uint32_t sampleRate, int channelCount, int format, int bufferCount,
+ uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
AudioCallback cb, void *cookie)
{
ALOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
@@ -1621,7 +1621,7 @@
mSampleRate = sampleRate;
mChannelCount = (uint16_t)channelCount;
- mFormat = (uint16_t)format;
+ mFormat = format;
mMsecsPerFrame = 1.e3 / (float) sampleRate;
if (cb != NULL) {
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 04d9e28..66f245d 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -83,7 +83,7 @@
virtual status_t open(
uint32_t sampleRate, int channelCount,
- int format, int bufferCount,
+ audio_format_t format, int bufferCount,
AudioCallback cb, void *cookie);
virtual void start();
@@ -139,7 +139,7 @@
virtual int getSessionId();
virtual status_t open(
- uint32_t sampleRate, int channelCount, int format,
+ uint32_t sampleRate, int channelCount, audio_format_t format,
int bufferCount = 1,
AudioCallback cb = NULL, void *cookie = NULL);
@@ -152,7 +152,7 @@
void setAudioStreamType(int streamType) {}
void setVolume(float left, float right) {}
uint32_t sampleRate() const { return mSampleRate; }
- uint32_t format() const { return (uint32_t)mFormat; }
+ audio_format_t format() const { return mFormat; }
size_t size() const { return mSize; }
status_t wait();
@@ -170,7 +170,7 @@
sp<MemoryHeapBase> mHeap;
float mMsecsPerFrame;
uint16_t mChannelCount;
- uint16_t mFormat;
+ audio_format_t mFormat;
ssize_t mFrameCount;
uint32_t mSampleRate;
uint32_t mSize;
@@ -190,8 +190,8 @@
virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId);
- virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
- virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
+ virtual sp<IMemory> decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
+ virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
virtual sp<IOMX> getOMX();
virtual status_t dump(int fd, const Vector<String16>& args);
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 7a2d7b3..d0cb7ff 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1841,6 +1841,10 @@
return;
}
mAudioStatusEventPending = true;
+ // Do not honor delay when looping in order to limit audio gap
+ if (mFlags & (LOOPING | AUTO_LOOPING)) {
+ delayUs = 0;
+ }
mQueue.postEventWithDelay(mCheckAudioStatusEvent, delayUs);
}
diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp
index 21496a9..1520c01 100644
--- a/media/mediaserver/main_mediaserver.cpp
+++ b/media/mediaserver/main_mediaserver.cpp
@@ -15,6 +15,8 @@
** limitations under the License.
*/
+#define LOG_TAG "mediaserver"
+
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index 5e5bc1a..975c372 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -87,7 +87,7 @@
mGlowBG = a.getDrawable(R.styleable.KeyButtonView_glowBackground);
if (mGlowBG != null) {
- mDrawingAlpha = BUTTON_QUIESCENT_ALPHA;
+ setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
}
a.recycle();
@@ -107,17 +107,13 @@
final int h = getHeight();
canvas.scale(mGlowScale, mGlowScale, w*0.5f, h*0.5f);
mGlowBG.setBounds(0, 0, w, h);
- mGlowBG.setAlpha((int)(mGlowAlpha * 255));
+ mGlowBG.setAlpha((int)(mDrawingAlpha * mGlowAlpha * 255));
mGlowBG.draw(canvas);
canvas.restore();
mRect.right = w;
mRect.bottom = h;
- canvas.saveLayerAlpha(mRect, (int)(mDrawingAlpha * 255), Canvas.ALL_SAVE_FLAG);
}
super.onDraw(canvas);
- if (mGlowBG != null) {
- canvas.restore();
- }
}
public float getDrawingAlpha() {
@@ -127,8 +123,11 @@
public void setDrawingAlpha(float x) {
if (mGlowBG == null) return;
+ // Calling setAlpha(int), which is an ImageView-specific
+ // method that's different from setAlpha(float). This sets
+ // the alpha on this ImageView's drawable directly
+ setAlpha((int) (x * 255));
mDrawingAlpha = x;
- invalidate();
}
public float getGlowAlpha() {
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ddefdb..9fb666e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -294,7 +294,7 @@
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
- int hardwareStatus = mHardwareStatus;
+ hardware_call_state hardwareStatus = mHardwareStatus;
snprintf(buffer, SIZE, "Hardware status: %d\n", hardwareStatus);
result.append(buffer);
@@ -574,7 +574,7 @@
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
- if ((mode < 0) || (mode >= AUDIO_MODE_CNT)) {
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) {
ALOGW("Illegal value: setMode(%d)", mode);
return BAD_VALUE;
}
@@ -1011,7 +1011,7 @@
ALOGV("ThreadBase::exit");
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
mExiting = true;
requestExit();
mWaitWorkCV.signal();
@@ -3243,7 +3243,7 @@
}
} else {
mCblk = (audio_track_cblk_t *)(new uint8_t[size]);
- if (mCblk) { // construct the shared structure in-place.
+ // construct the shared structure in-place.
new(mCblk) audio_track_cblk_t();
// clear all buffers
mCblk->frameCount = frameCount;
@@ -3256,7 +3256,6 @@
// written to buffer (other flags are cleared)
mCblk->flags = CBLK_UNDERRUN_ON;
mBufferEnd = (uint8_t *)mBuffer + bufferSize;
- }
}
}
@@ -4506,7 +4505,7 @@
sp <ThreadBase> strongMe = this;
status_t status = NO_ERROR;
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
if (mActiveTrack != 0) {
if (recordTrack != mActiveTrack.get()) {
status = -EBUSY;
@@ -4558,7 +4557,7 @@
ALOGV("RecordThread::stop");
sp <ThreadBase> strongMe = this;
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
if (mActiveTrack != 0 && recordTrack == mActiveTrack.get()) {
mActiveTrack->mState = TrackBase::PAUSING;
// do not wait for mStartStopCond if exiting
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index ff8dedb..f99e764 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1383,7 +1383,7 @@
mutable Mutex mHardwareLock;
audio_hw_device_t* mPrimaryHardwareDev;
Vector<audio_hw_device_t*> mAudioHwDevs;
- mutable int mHardwareStatus;
+ mutable hardware_call_state mHardwareStatus; // for dump only
DefaultKeyedVector< int, sp<PlaybackThread> > mPlaybackThreads;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 8df4605..a8102e5 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -309,7 +309,7 @@
inline
void AudioMixer::track_t::adjustVolumeRamp(bool aux)
{
- for (int i=0 ; i<MAX_NUM_CHANNELS ; i++) {
+ for (uint32_t i=0 ; i<MAX_NUM_CHANNELS ; i++) {
if (((volumeInc[i]>0) && (((prevVolume[i]+volumeInc[i])>>16) >= volume[i])) ||
((volumeInc[i]<0) && (((prevVolume[i]+volumeInc[i])>>16) <= volume[i]))) {
volumeInc[i] = 0;
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index f572fce..3f86d58 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -193,7 +193,7 @@
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (state < 0 || state >= AUDIO_MODE_CNT) {
+ if (uint32_t(state) >= AUDIO_MODE_CNT) {
return BAD_VALUE;
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 6e4aca7..97fb0b0 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1431,6 +1431,12 @@
}
mNetTrackers[ConnectivityManager.TYPE_MOBILE].setUserDataEnable(enabled);
}
+ if (mNetTrackers[ConnectivityManager.TYPE_WIMAX] != null) {
+ if (VDBG) {
+ log(mNetTrackers[ConnectivityManager.TYPE_WIMAX].toString() + enabled);
+ }
+ mNetTrackers[ConnectivityManager.TYPE_WIMAX].setUserDataEnable(enabled);
+ }
}
@Override
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index cf131b1..438a6da 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -384,10 +384,6 @@
return mNativeWindow->compositionComplete();
}
-int DisplayHardware::getCurrentBufferIndex() const {
- return mNativeWindow->getCurrentBufferIndex();
-}
-
void DisplayHardware::flip(const Region& dirty) const
{
checkGLErrors();
diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
index 45d4b45..77da272 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h
+++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h
@@ -93,9 +93,6 @@
}
inline Rect bounds() const { return getBounds(); }
- // only for debugging
- int getCurrentBufferIndex() const;
-
private:
void init(uint32_t displayIndex) __attribute__((noinline));
void fini() __attribute__((noinline));
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index 9245781..035836e 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -107,27 +107,17 @@
{ // scope for the lock
Mutex::Autolock _l(mLock);
do {
- // wait for listeners
+ // see if we need to wait for the VSYNC at all
do {
bool waitForNextVsync = false;
size_t count = mDisplayEventConnections.size();
for (size_t i=0 ; i<count ; i++) {
const ConnectionInfo& info(
mDisplayEventConnections.valueAt(i));
- if (info.count >= 1) {
- // continuous mode
+ if (info.count >= 0) {
+ // at least one continuous mode or active one-shot event
waitForNextVsync = true;
- } else {
- // one-shot event
- if (info.count >= -1) {
- ConnectionInfo& info(
- mDisplayEventConnections.editValueAt(i));
- info.count--;
- if (info.count == -1) {
- // fired this time around
- waitForNextVsync = true;
- }
- }
+ break;
}
}
@@ -137,14 +127,38 @@
mCondition.wait(mLock);
} while(true);
- // wait for vsync
+ // at least one listener requested VSYNC
mLock.unlock();
timestamp = mHw.waitForVSync();
mLock.lock();
mDeliveredEvents++;
- // make sure we still have some listeners
- } while (!mDisplayEventConnections.size());
+ // now see if we still need to report this VSYNC event
+ bool reportVsync = false;
+ size_t count = mDisplayEventConnections.size();
+ for (size_t i=0 ; i<count ; i++) {
+ const ConnectionInfo& info(
+ mDisplayEventConnections.valueAt(i));
+ if (info.count >= 1) {
+ if (info.count==1 || (mDeliveredEvents % info.count) == 0) {
+ // continuous event, and time to report it
+ reportVsync = true;
+ }
+ } else if (info.count >= -1) {
+ ConnectionInfo& info(
+ mDisplayEventConnections.editValueAt(i));
+ if (info.count == 0) {
+ // fired this time around
+ reportVsync = true;
+ }
+ info.count--;
+ }
+ }
+
+ if (reportVsync) {
+ break;
+ }
+ } while (true);
// dispatch vsync events to listeners...
vsync.header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC;
@@ -161,27 +175,6 @@
sp<DisplayEventConnection> conn(displayEventConnections.keyAt(i).promote());
// make sure the connection didn't die
if (conn != NULL) {
-
- const ConnectionInfo& info(
- displayEventConnections.valueAt(i));
-
- if ((info.count > 1) && (mDeliveredEvents % info.count)) {
- // continuous event, but not time to send this event yet
- continue;
- } else if (info.count < -1) {
- // disabled event
- continue;
- } else if (info.count == 0) {
- // impossible by construction. but we prefer to be safe.
- continue;
- }
-
- // here, either:
- // count = -1 : one-shot scheduled this time around
- // count = 1 : continuous not rate-limited
- // count > 1 : continuous, rate-limited
- // Note: count == 0 is not possible by construction
-
status_t err = conn->postEvent(vsync);
if (err == -EAGAIN || err == -EWOULDBLOCK) {
// The destination doesn't accept events anymore, it's probably
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index bbb30b0..42ae408 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -41,7 +41,6 @@
#include <utils/StopWatch.h>
#include <ui/GraphicBufferAllocator.h>
-#include <ui/GraphicLog.h>
#include <ui/PixelFormat.h>
#include <pixelflinger/pixelflinger.h>
@@ -431,21 +430,10 @@
const DisplayHardware& hw(graphicPlane(0).displayHardware());
if (CC_LIKELY(hw.canDraw())) {
// repaint the framebuffer (if needed)
-
- const int index = hw.getCurrentBufferIndex();
- GraphicLog& logger(GraphicLog::getInstance());
-
- logger.log(GraphicLog::SF_REPAINT, index);
handleRepaint();
-
// inform the h/w that we're done compositing
- logger.log(GraphicLog::SF_COMPOSITION_COMPLETE, index);
hw.compositionComplete();
-
- logger.log(GraphicLog::SF_SWAP_BUFFERS, index);
postFramebuffer();
-
- logger.log(GraphicLog::SF_REPAINT_DONE, index);
} else {
// pretend we did the post
hw.compositionComplete();
@@ -1097,23 +1085,6 @@
}
}
-void SurfaceFlinger::debugShowFPS() const
-{
- static int mFrameCount;
- static int mLastFrameCount = 0;
- static nsecs_t mLastFpsTime = 0;
- static float mFps = 0;
- mFrameCount++;
- nsecs_t now = systemTime();
- nsecs_t diff = now - mLastFpsTime;
- if (diff > ms2ns(250)) {
- mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff;
- mLastFpsTime = now;
- mLastFrameCount = mFrameCount;
- }
- // XXX: mFPS has the value we want
- }
-
status_t SurfaceFlinger::addLayer(const sp<LayerBase>& layer)
{
Mutex::Autolock _l(mStateLock);
@@ -1707,11 +1678,6 @@
setTransactionFlags(eTransactionNeeded|eTraversalNeeded);
return NO_ERROR;
}
- case 1006:{ // enable/disable GraphicLog
- int enabled = data.readInt32();
- GraphicLog::getInstance().setEnabled(enabled);
- return NO_ERROR;
- }
case 1008: // toggle use of hw composer
n = data.readInt32();
mDebugDisableHWC = n ? 1 : 0;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index ffd3ac9..7f6c90c 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -335,7 +335,6 @@
status_t electronBeamOnAnimationImplLocked();
void debugFlashRegions();
- void debugShowFPS() const;
void drawWormhole() const;
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index a88825b..3128592 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -568,10 +568,10 @@
int levelLteRsrp = 0;
if (mLteRsrp == -1) levelLteRsrp = 0;
- else if (mLteRsrp >= -85) levelLteRsrp = SIGNAL_STRENGTH_GREAT;
- else if (mLteRsrp >= -95) levelLteRsrp = SIGNAL_STRENGTH_GOOD;
- else if (mLteRsrp >= -105) levelLteRsrp = SIGNAL_STRENGTH_MODERATE;
- else if (mLteRsrp >= -115) levelLteRsrp = SIGNAL_STRENGTH_POOR;
+ else if (mLteRsrp >= -90) levelLteRsrp = SIGNAL_STRENGTH_GREAT;
+ else if (mLteRsrp >= -100) levelLteRsrp = SIGNAL_STRENGTH_GOOD;
+ else if (mLteRsrp >= -110) levelLteRsrp = SIGNAL_STRENGTH_MODERATE;
+ else if (mLteRsrp >= -118) levelLteRsrp = SIGNAL_STRENGTH_POOR;
else levelLteRsrp = 0;
if (DBG) log("Lte level: "+levelLteRsrp);
diff --git a/telephony/java/com/android/internal/telephony/ApnSetting.java b/telephony/java/com/android/internal/telephony/ApnSetting.java
index 980bb49..ad69fdb 100755
--- a/telephony/java/com/android/internal/telephony/ApnSetting.java
+++ b/telephony/java/com/android/internal/telephony/ApnSetting.java
@@ -181,9 +181,10 @@
public boolean canHandleType(String type) {
for (String t : types) {
// DEFAULT handles all, and HIPRI is handled by DEFAULT
- if (t.equals(type) || t.equals(Phone.APN_TYPE_ALL) ||
- (t.equals(Phone.APN_TYPE_DEFAULT) &&
- type.equals(Phone.APN_TYPE_HIPRI))) {
+ if (t.equalsIgnoreCase(type) ||
+ t.equalsIgnoreCase(Phone.APN_TYPE_ALL) ||
+ (t.equalsIgnoreCase(Phone.APN_TYPE_DEFAULT) &&
+ type.equalsIgnoreCase(Phone.APN_TYPE_HIPRI))) {
return true;
}
}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java
index d2298da..f96e68b 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingTest.java
@@ -41,6 +41,7 @@
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
private final String TAG = "ImageProcessingTest";
private final String RESULT_FILE = "image_processing_result.txt";
+ private int ITERATION = 5;
private ImageProcessingActivity mAct;
public ImageProcessingTest() {
@@ -63,9 +64,8 @@
*/
@LargeTest
public void testImageProcessingBench() {
- long t = mAct.getBenchmark();
- Log.v(TAG, "t = " + t);
-
+ long t = 0;
+ long sum = 0;
// write result into a file
File externalStorage = Environment.getExternalStorageDirectory();
if (!externalStorage.canWrite()) {
@@ -75,10 +75,18 @@
File resultFile = new File(externalStorage, RESULT_FILE);
resultFile.setWritable(true, false);
try {
- BufferedWriter results = new BufferedWriter(new FileWriter(resultFile));
- results.write("Renderscript frame time core: " + t + " ms");
- results.close();
+ BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
+ for (int i = 0; i < ITERATION; i++ ) {
+ t = mAct.getBenchmark();
+ sum += t;
+ rsWriter.write("Renderscript frame time core: " + t + " ms\n");
+ Log.v(TAG, "RenderScript framew time core: " + t + " ms");
+ }
+ long avgValue = sum/ITERATION;
+ rsWriter.write("Averge frame time: " + avgValue + " ms\n");
+ Log.v(TAG, "Average frame time: " + avgValue + " ms");
+ rsWriter.close();
} catch (IOException e) {
Log.v(TAG, "Unable to write result file " + e.getMessage());
}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 1a85529..58e19cf 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -2541,6 +2541,10 @@
} else {
WifiNative.setScanResultHandling(CONNECT_MODE);
WifiNative.reconnect();
+ // Status pulls in the current supplicant state and network connection state
+ // events over the monitor connection. This helps framework sync up with
+ // current supplicant state
+ WifiNative.status();
transitionTo(mDisconnectedState);
}
}