Merge "After failing to create an AudioTrack, only stop the source if we were the ones starting it." into kraken
diff --git a/api/current.xml b/api/current.xml
index 923a7b6..e6780be 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -87263,6 +87263,19 @@
<exception name="IOException" type="java.io.IOException">
</exception>
</constructor>
+<method name="getAltitude"
+ return="double"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="defaultValue" type="double">
+</parameter>
+</method>
<method name="getAttribute"
return="java.lang.String"
abstract="false"
@@ -87501,6 +87514,28 @@
visibility="public"
>
</field>
+<field name="TAG_GPS_ALTITUDE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""GPSAltitude""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TAG_GPS_ALTITUDE_REF"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""GPSAltitudeRef""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="TAG_GPS_DATESTAMP"
type="java.lang.String"
transient="false"
diff --git a/docs/html/guide/developing/tools/emulator.jd b/docs/html/guide/developing/tools/emulator.jd
index 6363ab2..f07cdd5 100644
--- a/docs/html/guide/developing/tools/emulator.jd
+++ b/docs/html/guide/developing/tools/emulator.jd
@@ -1142,7 +1142,7 @@
emulator checks the value of the <code>http_proxy</code> environment variable at
startup and uses its value automatically, if defined. </p>
-<p>You can use the <code>-verbose-proxy</code> option to diagnose proxy
+<p>You can use the <code>-debug-proxy</code> option to diagnose proxy
connection problems.</p>
<a name="connecting"></a>
diff --git a/docs/html/guide/practices/design/performance.jd b/docs/html/guide/practices/design/performance.jd
index b3f8830..f22d2d3 100644
--- a/docs/html/guide/practices/design/performance.jd
+++ b/docs/html/guide/practices/design/performance.jd
@@ -279,7 +279,7 @@
<p>On devices without a JIT, it is true that invoking methods via a
variable with an exact type rather than an interface is slightly more
efficient. (So, for example, it was cheaper to invoke methods on a
-<code>Map map</code> than a <code>HashMap map</code>, even though in both
+<code>HashMap map</code> than a <code>Map map</code>, even though in both
cases the map was a <code>HashMap</code>.) It was not the case that this
was 2x slower; the actual difference was more like 6% slower. Furthermore,
the JIT makes the two effectively indistinguishable.</p>
diff --git a/docs/html/guide/publishing/app-signing.jd b/docs/html/guide/publishing/app-signing.jd
index 39b230b..8c37d7a 100644
--- a/docs/html/guide/publishing/app-signing.jd
+++ b/docs/html/guide/publishing/app-signing.jd
@@ -337,17 +337,6 @@
<td><code>-v</code></td><td>Enable verbose output.</td>
</tr>
<tr>
-<td><code>-keystore <keystore-name>.keystore</code></td><td>A name
-for the keystore containing the private key.</td>
-</tr>
-<tr>
-<td><code>-storepass <password></code></td><td><p>A password for the
-keystore.</p><p>As a security precaution, do not include this option
-in your command line unless you are working at a secure computer.
-If not supplied, Keytool prompts you to enter the password. In this
-way, your password is not stored in your shell history.</p></td>
-</tr>
-<tr>
<td><code>-alias <alias_name></code></td><td>An alias for the key. Only
the first 8 characters of the alias are used.</td>
</tr>
@@ -356,6 +345,11 @@
when generating the key. Both DSA and RSA are supported.</td>
</tr>
<tr>
+<td><code>-keysize <size></code></td><td>The size of each generated key
+(bits). If not supplied, Keytool uses a default key size of 1024 bits. In
+general, we recommend using a key size of 2048 bits or higher. </td>
+</tr>
+<tr>
<td><code>-dname <name></code></td><td><p>A Distinguished Name that describes
who created the key. The value is used as the issuer and subject fields in the
self-signed certificate. </p><p>Note that you do not need to specify this option
@@ -363,22 +357,31 @@
of the Distinguished Name fields (CN, OU, and so on).</p></td>
</tr>
<tr>
+<td><code>-keypass <password></code></td><td><p>The password for the
+key.</p> <p>As a security precaution, do not include this option in your command
+line. If not supplied, Keytool prompts you to enter the password. In this way,
+your password is not stored in your shell history.</p></td>
+</tr>
+<tr>
<td><code>-validity <valdays></code></td><td><p>The validity period for the
key, in days. </p><p><strong>Note:</strong> A value of 10000 or greater is recommended.</p></td>
</tr>
<tr>
-<td><code>-keypass <password></code></td><td><p>The password for the key.</p>
-<p>As a security precaution, do not include this option
-in your command line unless you are working at a secure computer.
-If not supplied, Keytool prompts you to enter the password. In this
-way, your password is not stored in your shell history.</p></td>
+<td><code>-keystore <keystore-name>.keystore</code></td><td>A name
+for the keystore containing the private key.</td>
+</tr>
+<tr>
+<td><code>-storepass <password></code></td><td><p>A password for the
+keystore.</p><p>As a security precaution, do not include this option in your
+command line. If not supplied, Keytool prompts you to enter the password. In
+this way, your password is not stored in your shell history.</p></td>
</tr>
</table>
<p>Here's an example of a Keytool command that generates a private key:</p>
<pre>$ keytool -genkey -v -keystore my-release-key.keystore
--alias alias_name -keyalg RSA -validity 10000</pre>
+-alias alias_name -keyalg RSA -keysize 2048 -validity 10000</pre>
<p>Running the example command above, Keytool prompts you to provide
passwords for the keystore and key, and to provide the Distinguished
diff --git a/docs/html/guide/topics/providers/content-providers.jd b/docs/html/guide/topics/providers/content-providers.jd
index 5da760a..30f8d8c 100644
--- a/docs/html/guide/topics/providers/content-providers.jd
+++ b/docs/html/guide/topics/providers/content-providers.jd
@@ -176,17 +176,7 @@
<p>
<p style="margin-left: 2em">{@code android.provider.Contacts.Phones.CONTENT_URI}
<br/>{@code android.provider.Contacts.Photos.CONTENT_URI}
-</p>
-
-<p>
-Similarly, the URIs for the table of recent phone calls and the table
-of calendar entries are:
-</p>
-
-<p>
-<p style="margin-left: 2em">{@code android.provider.CallLog.Calls.CONTENT_URI}
-<br/>{@code android.provider.Calendar.CONTENT_URI}
-</p>
+</p>
<p>
The URI constant is used in all interactions with the content provider.
diff --git a/docs/html/sdk/adt_download.jd b/docs/html/sdk/adt_download.jd
index 96896c7..f98caf5 100644
--- a/docs/html/sdk/adt_download.jd
+++ b/docs/html/sdk/adt_download.jd
@@ -22,11 +22,18 @@
<th>Notes</th>
</tr>
<tr>
- <td>0.9.6</td>
- <td><a href="http://dl-ssl.google.com/android/ADT-0.9.6.zip">ADT-0.9.6.zip</a></td>
+ <td>0.9.7</td>
+ <td><a href="http://dl-ssl.google.com/android/ADT-0.9.7.zip">ADT-0.9.7.zip</a></td>
<td><nobr>{@adtZipBytes} bytes</nobr></td>
<td>{@adtZipChecksum}</td>
- <td>Requires SDK Tools, Revision 5 <em><nobr>March 2009</nobr></em></td>
+ <td>Requires SDK Tools, Revision 6 <em><nobr>May 2010</nobr></em></td>
+ </tr>
+ <tr>
+ <td>0.9.6</td>
+ <td><a href="http://dl-ssl.google.com/android/ADT-0.9.6.zip">ADT-0.9.6.zip</a></td>
+ <td><nobr>7456339 bytes</nobr></td>
+ <td>ea45d271be52b87b5dd1c9fb17536223</td>
+ <td>Requires SDK Tools, Revision 5 <em><nobr>March 2010</nobr></em></td>
</tr>
<tr>
<td>0.9.5</td>
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 42d6634..9d6b01d 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -19,6 +19,7 @@
#define CAMERA_SOURCE_H_
#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaSource.h>
#include <utils/List.h>
#include <utils/RefBase.h>
@@ -61,6 +62,7 @@
int32_t mNumFramesReceived;
int32_t mNumFramesEncoded;
int32_t mNumFramesDropped;
+ MediaBufferGroup *mBufferGroup;
bool mStarted;
CameraSource(const sp<Camera> &camera);
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 84584aa..3fbb4d3 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -209,6 +209,19 @@
drawWithOpenGL(clip, tex);
}
+bool Layer::needsFiltering() const
+{
+ if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
+ // NOTE: there is a race here, because mFixedSize is updated in a
+ // binder transaction. however, it doesn't really matter since it is
+ // evaluated each time we draw. To be perfectly correct, this flag
+ // would have to be associated with a buffer.
+ if (mFixedSize)
+ return true;
+ }
+ return LayerBase::needsFiltering();
+}
+
status_t Layer::setBufferCount(int bufferCount)
{
diff --git a/libs/surfaceflinger/Layer.h b/libs/surfaceflinger/Layer.h
index 10b5910..59603a5 100644
--- a/libs/surfaceflinger/Layer.h
+++ b/libs/surfaceflinger/Layer.h
@@ -67,6 +67,7 @@
virtual void finishPageFlip();
virtual bool needsBlending() const { return mNeedsBlending; }
virtual bool needsDithering() const { return mNeedsDithering; }
+ virtual bool needsFiltering() const;
virtual bool isSecure() const { return mSecure; }
virtual sp<Surface> createSurface() const;
virtual status_t ditch();
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 090404e..76733a9 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -42,8 +42,7 @@
LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
: dpy(display), contentDirty(false),
mFlinger(flinger),
- mTransformed(false),
- mUseLinearFiltering(false),
+ mNeedsFiltering(false),
mOrientation(0),
mLeft(0), mTop(0),
mTransactionFlags(0),
@@ -214,13 +213,12 @@
flags |= eVisibleRegion;
this->contentDirty = true;
- const bool linearFiltering = mUseLinearFiltering;
- mUseLinearFiltering = false;
+ mNeedsFiltering = false;
if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
// we may use linear filtering, if the matrix scales us
const uint8_t type = temp.transform.getType();
if (!temp.transform.preserveRects() || (type >= Transform::SCALE)) {
- mUseLinearFiltering = true;
+ mNeedsFiltering = true;
}
}
}
@@ -260,7 +258,6 @@
// cache a few things...
mOrientation = tr.getOrientation();
mTransformedBounds = tr.makeBounds(w, h);
- mTransformed = transformed;
mLeft = tr.tx();
mTop = tr.ty();
}
@@ -341,13 +338,13 @@
*/
}
-void LayerBase::clearWithOpenGL(const Region& clip, GLclampx red,
- GLclampx green, GLclampx blue,
- GLclampx alpha) const
+void LayerBase::clearWithOpenGL(const Region& clip, GLclampf red,
+ GLclampf green, GLclampf blue,
+ GLclampf alpha) const
{
const DisplayHardware& hw(graphicPlane(0).displayHardware());
const uint32_t fbHeight = hw.getHeight();
- glColor4x(red,green,blue,alpha);
+ glColor4f(red,green,blue,alpha);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDisable(GL_DITHER);
@@ -466,7 +463,7 @@
glBindTexture(GL_TEXTURE_2D, textureName);
// TODO: reload the texture if needed
// this is currently done in loadTexture() below
- if (mUseLinearFiltering) {
+ if (needsFiltering()) {
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 569b0ff..a78424e 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -177,9 +177,9 @@
virtual bool needsDithering() const { return false; }
/**
- * transformed -- true is this surface needs a to be transformed
+ * needsLinearFiltering - true if this surface needs filtering
*/
- virtual bool transformed() const { return mTransformed; }
+ virtual bool needsFiltering() const { return mNeedsFiltering; }
/**
* isSecure - true if this surface is secure, that is if it prevents
@@ -222,8 +222,8 @@
const GraphicPlane& graphicPlane(int dpy) const;
GraphicPlane& graphicPlane(int dpy);
- void clearWithOpenGL(const Region& clip, GLclampx r, GLclampx g,
- GLclampx b, GLclampx alpha) const;
+ void clearWithOpenGL(const Region& clip, GLclampf r, GLclampf g,
+ GLclampf b, GLclampf alpha) const;
void clearWithOpenGL(const Region& clip) const;
void drawWithOpenGL(const Region& clip, const Texture& texture) const;
@@ -231,8 +231,7 @@
uint32_t mFlags;
// cached during validateVisibility()
- bool mTransformed;
- bool mUseLinearFiltering;
+ bool mNeedsFiltering;
int32_t mOrientation;
GLfloat mVertices[4][2];
Rect mTransformedBounds;
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index dfcc80f..8a582da 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -118,7 +118,7 @@
source->onTransaction(flags);
uint32_t res = LayerBase::doTransaction(flags);
// we always want filtering for these surfaces
- mUseLinearFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
+ mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG);
return res;
}
@@ -143,14 +143,6 @@
}
}
-bool LayerBuffer::transformed() const
-{
- sp<Source> source(getSource());
- if (LIKELY(source != 0))
- return source->transformed();
- return false;
-}
-
void LayerBuffer::serverDestroy()
{
sp<Source> source(clearSource());
@@ -319,9 +311,6 @@
}
void LayerBuffer::Source::unregisterBuffers() {
}
-bool LayerBuffer::Source::transformed() const {
- return mLayer.mTransformed;
-}
// ---------------------------------------------------------------------------
@@ -442,11 +431,6 @@
mBuffer = buffer;
}
-bool LayerBuffer::BufferSource::transformed() const
-{
- return mBufferHeap.transform ? true : Source::transformed();
-}
-
void LayerBuffer::BufferSource::onDraw(const Region& clip) const
{
sp<Buffer> ourBuffer(getBuffer());
@@ -542,7 +526,7 @@
// figure out if we need linear filtering
if (buffers.w * h == buffers.h * w) {
// same pixel area, don't use filtering
- mLayer.mUseLinearFiltering = false;
+ mLayer.mNeedsFiltering = false;
}
// Allocate a temporary buffer and create the corresponding EGLImageKHR
@@ -638,9 +622,9 @@
void LayerBuffer::OverlaySource::onDraw(const Region& clip) const
{
// this would be where the color-key would be set, should we need it.
- GLclampx red = 0;
- GLclampx green = 0;
- GLclampx blue = 0;
+ GLclampf red = 0;
+ GLclampf green = 0;
+ GLclampf blue = 0;
mLayer.clearWithOpenGL(clip, red, green, blue, 0);
}
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 869c74f..d38dde2 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -46,7 +46,6 @@
virtual void onVisibilityResolved(const Transform& planeTransform);
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
- virtual bool transformed() const;
virtual void destroy() { }
protected:
LayerBuffer& mLayer;
@@ -66,7 +65,6 @@
virtual void onDraw(const Region& clip) const;
virtual uint32_t doTransaction(uint32_t flags);
virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
- virtual bool transformed() const;
status_t registerBuffers(const ISurface::BufferHeap& buffers);
void postBuffer(ssize_t offset);
@@ -130,7 +128,6 @@
virtual void onDraw(const Region& clip) const;
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
- virtual bool transformed() const;
virtual void destroy() { }
private:
status_t initTempBuffer() const;
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index 534a54e..a26733e 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -610,6 +610,9 @@
case NATIVE_WINDOW_SET_BUFFER_COUNT:
res = dispatch_set_buffer_count( args );
break;
+ case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY:
+ res = dispatch_set_buffers_geometry( args );
+ break;
default:
res = NAME_NOT_FOUND;
break;
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index b26906d..74488c5 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -51,6 +51,19 @@
public static final String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
/** Type is String. */
public static final String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+
+ /**
+ * The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF.
+ * Type is rational.
+ */
+ public static final String TAG_GPS_ALTITUDE = "GPSAltitude";
+
+ /**
+ * 0 if the altitude is above sea level. 1 if the altitude is below sea
+ * level. Type is int.
+ */
+ public static final String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef";
+
/** Type is String. */
public static final String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
/** Type is String. */
@@ -289,6 +302,23 @@
}
/**
+ * Return the altitude in meters. If the exif tag does not exist, return
+ * <var>defaultValue</var>.
+ *
+ * @param defaultValue the value to return if the tag is not available.
+ */
+ public double getAltitude(double defaultValue) {
+ double altitude = getAttributeDouble(TAG_GPS_ALTITUDE, -1);
+ int ref = getAttributeInt(TAG_GPS_ALTITUDE_REF, -1);
+
+ if (altitude >= 0 && ref >= 0) {
+ return (double) (altitude * ((ref == 1) ? -1 : 1));
+ } else {
+ return defaultValue;
+ }
+ }
+
+ /**
* Returns number of milliseconds since Jan. 1, 1970, midnight.
* Returns -1 if the date time information if not available.
* @hide
@@ -345,14 +375,14 @@
/ Float.parseFloat(pair[1].trim())));
pair = parts[2].split("/");
- float seconds = Float.parseFloat(pair[0].trim())
- / Float.parseFloat(pair[1].trim());
+ double seconds = Double.parseDouble(pair[0].trim())
+ / Double.parseDouble(pair[1].trim());
- float result = degrees + (minutes / 60F) + (seconds / (60F * 60F));
+ double result = degrees + (minutes / 60.0) + (seconds / 3600.0);
if ((ref.equals("S") || ref.equals("W"))) {
- return -result;
+ return (float) -result;
}
- return result;
+ return (float) result;
} catch (RuntimeException ex) {
// if for whatever reason we can't parse the lat long then return
// null
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index cd26e6b..476b36d 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -104,6 +104,7 @@
mNumFramesReceived(0),
mNumFramesEncoded(0),
mNumFramesDropped(0),
+ mBufferGroup(NULL),
mStarted(false) {
String8 s = mCamera->getParameters();
printf("params: \"%s\"\n", s.string());
@@ -126,7 +127,6 @@
CHECK_EQ(OK, mCamera->startRecording());
mStarted = true;
-
return OK;
}
@@ -139,6 +139,8 @@
mCamera->stopRecording();
releaseQueuedFrames();
+ delete mBufferGroup;
+ mBufferGroup = NULL;
LOGI("Frames received/encoded/dropped: %d/%d/%d, timestamp (us) last/first: %lld/%lld",
mNumFramesReceived, mNumFramesEncoded, mNumFramesDropped,
mLastFrameTimestampUs, mFirstFrameTimeUs);
@@ -196,8 +198,13 @@
mFrameTimes.erase(mFrameTimes.begin());
++mNumFramesEncoded;
}
+ if (mBufferGroup == NULL) {
+ mBufferGroup = new MediaBufferGroup();
+ CHECK(mBufferGroup != NULL);
+ mBufferGroup->add_buffer(new MediaBuffer(frame->size()));
+ }
- *buffer = new MediaBuffer(frame->size());
+ mBufferGroup->acquire_buffer(buffer);
memcpy((*buffer)->data(), frame->pointer(), frame->size());
(*buffer)->set_range(0, frame->size());
mCamera->releaseRecordingFrame(frame);
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index bd16db9..6013b6f 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -76,7 +76,7 @@
status_t seekToOffset(off_t offset);
status_t readNextPacket(MediaBuffer **buffer);
- void init();
+ status_t init();
sp<MetaData> getFileMetaData() { return mFileMeta; }
@@ -107,7 +107,7 @@
ssize_t readPage(off_t offset, Page *page);
status_t findNextPage(off_t startOffset, off_t *pageOffset);
- void verifyHeader(
+ status_t verifyHeader(
MediaBuffer *buffer, uint8_t type);
void parseFileMetaData();
@@ -308,6 +308,7 @@
totalSize += page->mLace[i];
}
+#if 0
String8 tmp;
for (size_t i = 0; i < page->mNumSegments; ++i) {
char x[32];
@@ -316,7 +317,8 @@
tmp.append(x);
}
- // LOGV("%c %s", page->mFlags & 1 ? '+' : ' ', tmp.string());
+ LOGV("%c %s", page->mFlags & 1 ? '+' : ' ', tmp.string());
+#endif
return sizeof(header) + page->mNumSegments + totalSize;
}
@@ -432,43 +434,60 @@
}
}
-void MyVorbisExtractor::init() {
+status_t MyVorbisExtractor::init() {
mMeta = new MetaData;
mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_VORBIS);
MediaBuffer *packet;
- CHECK_EQ(readNextPacket(&packet), OK);
+ status_t err;
+ if ((err = readNextPacket(&packet)) != OK) {
+ return err;
+ }
LOGV("read packet of size %d\n", packet->range_length());
- verifyHeader(packet, 1);
+ err = verifyHeader(packet, 1);
packet->release();
packet = NULL;
+ if (err != OK) {
+ return err;
+ }
- CHECK_EQ(readNextPacket(&packet), OK);
+ if ((err = readNextPacket(&packet)) != OK) {
+ return err;
+ }
LOGV("read packet of size %d\n", packet->range_length());
- verifyHeader(packet, 3);
+ err = verifyHeader(packet, 3);
packet->release();
packet = NULL;
+ if (err != OK) {
+ return err;
+ }
- CHECK_EQ(readNextPacket(&packet), OK);
+ if ((err = readNextPacket(&packet)) != OK) {
+ return err;
+ }
LOGV("read packet of size %d\n", packet->range_length());
- verifyHeader(packet, 5);
+ err = verifyHeader(packet, 5);
packet->release();
packet = NULL;
+ if (err != OK) {
+ return err;
+ }
mFirstDataOffset = mOffset + mCurrentPageSize;
+
+ return OK;
}
-void MyVorbisExtractor::verifyHeader(
+status_t MyVorbisExtractor::verifyHeader(
MediaBuffer *buffer, uint8_t type) {
const uint8_t *data =
(const uint8_t *)buffer->data() + buffer->range_offset();
size_t size = buffer->range_length();
- CHECK(size >= 7);
-
- CHECK_EQ(data[0], type);
- CHECK(!memcmp(&data[1], "vorbis", 6));
+ if (size < 7 || data[0] != type || memcmp(&data[1], "vorbis", 6)) {
+ return ERROR_MALFORMED;
+ }
ogg_buffer buf;
buf.data = (uint8_t *)data;
@@ -515,7 +534,9 @@
case 3:
{
- CHECK_EQ(0, _vorbis_unpack_comment(&mVc, &bits));
+ if (0 != _vorbis_unpack_comment(&mVc, &bits)) {
+ return ERROR_MALFORMED;
+ }
parseFileMetaData();
break;
@@ -523,12 +544,16 @@
case 5:
{
- CHECK_EQ(0, _vorbis_unpack_books(&mVi, &bits));
+ if (0 != _vorbis_unpack_books(&mVi, &bits)) {
+ return ERROR_MALFORMED;
+ }
mMeta->setData(kKeyVorbisBooks, 0, data, size);
break;
}
}
+
+ return OK;
}
uint64_t MyVorbisExtractor::approxBitrate() {
@@ -732,10 +757,11 @@
mInitCheck(NO_INIT),
mImpl(NULL) {
mImpl = new MyVorbisExtractor(mDataSource);
- CHECK_EQ(mImpl->seekToOffset(0), OK);
- mImpl->init();
+ mInitCheck = mImpl->seekToOffset(0);
- mInitCheck = OK;
+ if (mInitCheck == OK) {
+ mInitCheck = mImpl->init();
+ }
}
OggExtractor::~OggExtractor() {
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 552bed4..cbbc7be 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -494,15 +494,23 @@
* argv8 - Max SCB
*/
String str = String.format("softap set " + wlanIface + " " + softapIface +
- " \"%s\" %s %s", wifiConfig.SSID,
+ " %s %s %s", convertQuotedString(wifiConfig.SSID),
wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
"wpa2-psk" : "open",
- wifiConfig.preSharedKey);
+ convertQuotedString(wifiConfig.preSharedKey));
mConnector.doCommand(str);
}
mConnector.doCommand(String.format("softap startap"));
}
+ private String convertQuotedString(String s) {
+ if (s == null) {
+ return s;
+ }
+ /* Replace \ with \\, then " with \" and add quotes at end */
+ return '"' + s.replaceAll("\\\\","\\\\\\\\").replaceAll("\"","\\\\\"") + '"';
+ }
+
public void stopAccessPoint() throws IllegalStateException {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
@@ -521,10 +529,10 @@
mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
} else {
String str = String.format("softap set " + wlanIface + " " + softapIface +
- " \"%s\" %s %s", wifiConfig.SSID,
+ " %s %s %s", convertQuotedString(wifiConfig.SSID),
wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
"wpa2-psk" : "open",
- wifiConfig.preSharedKey);
+ convertQuotedString(wifiConfig.preSharedKey));
mConnector.doCommand(str);
}
}