am 014085a8: am 4bc95d19: Merge change Iab089078 into eclair-mr2
Merge commit '014085a8727d7e10a4d39cba4a6d27826b66bc00'
* commit '014085a8727d7e10a4d39cba4a6d27826b66bc00':
Fix for a race condition that can occur if an utterance
diff --git a/camera/tests/CameraServiceTest/Android.mk b/camera/tests/CameraServiceTest/Android.mk
index c2a02bb..8da7c1f 100644
--- a/camera/tests/CameraServiceTest/Android.mk
+++ b/camera/tests/CameraServiceTest/Android.mk
@@ -14,6 +14,7 @@
LOCAL_CFLAGS :=
LOCAL_SHARED_LIBRARIES += \
+ libbinder \
libcutils \
libutils \
libui
diff --git a/cmds/keystore/keystore.c b/cmds/keystore/keystore.c
index ba74c78..37155e4 100644
--- a/cmds/keystore/keystore.c
+++ b/cmds/keystore/keystore.c
@@ -163,19 +163,23 @@
static int8_t encrypt_blob(char *name, AES_KEY *aes_key)
{
uint8_t vector[AES_BLOCK_SIZE];
- int length = blob.length;
+ int length;
int fd;
if (read(the_entropy, vector, AES_BLOCK_SIZE) != AES_BLOCK_SIZE) {
return SYSTEM_ERROR;
}
- length += blob.value - blob.digested;
+ length = (blob.length + blob.value - blob.encrypted) % AES_BLOCK_SIZE;
+ if (length) {
+ length = AES_BLOCK_SIZE - length;
+ }
+
+ length += blob.length + blob.value - blob.digested;
blob.length = htonl(blob.length);
MD5(blob.digested, length, blob.digest);
length += blob.digested - blob.encrypted;
- length = (length + AES_BLOCK_SIZE - 1) / AES_BLOCK_SIZE * AES_BLOCK_SIZE;
memcpy(vector, blob.vector, AES_BLOCK_SIZE);
AES_cbc_encrypt(blob.encrypted, blob.encrypted, length, aes_key, vector,
AES_ENCRYPT);
@@ -184,11 +188,9 @@
length += blob.encrypted - (uint8_t *)&blob;
fd = open(".tmp", O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd == -1 || write(fd, &blob, length) != length) {
- return SYSTEM_ERROR;
- }
+ length -= write(fd, &blob, length);
close(fd);
- return rename(".tmp", name) ? SYSTEM_ERROR : NO_ERROR;
+ return (length || rename(".tmp", name)) ? SYSTEM_ERROR : NO_ERROR;
}
static int8_t decrypt_blob(char *name, AES_KEY *aes_key)
@@ -210,14 +212,15 @@
AES_cbc_encrypt(blob.encrypted, blob.encrypted, length, aes_key,
blob.vector, AES_DECRYPT);
length -= blob.digested - blob.encrypted;
- if (!memcmp(blob.digest, MD5(blob.digested, length, NULL),
- MD5_DIGEST_LENGTH)) {
+ if (memcmp(blob.digest, MD5(blob.digested, length, NULL),
+ MD5_DIGEST_LENGTH)) {
return VALUE_CORRUPTED;
}
length -= blob.value - blob.digested;
blob.length = ntohl(blob.length);
- return (length < blob.length) ? VALUE_CORRUPTED : NO_ERROR;
+ return (blob.length < 0 || blob.length > length) ? VALUE_CORRUPTED :
+ NO_ERROR;
}
/* Here are the actions. Each of them is a function without arguments. All
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 2024cc0..ecfe1e0 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -932,6 +932,8 @@
result.append(buffer);
snprintf(buffer, SIZE, "blocked in write: %d\n", mInWrite);
result.append(buffer);
+ snprintf(buffer, SIZE, "suspend count: %d\n", mSuspended);
+ result.append(buffer);
write(fd, result.string(), result.size());
dumpBase(fd, args);
@@ -1344,7 +1346,7 @@
if (cblk->framesReady() && (track->isReady() || track->isStopped()) &&
!track->isPaused())
{
- //LOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
+ //LOGV("track %d u=%08x, s=%08x [OK] on thread %p", track->name(), cblk->user, cblk->server, this);
// compute volume for this track
int16_t left, right;
@@ -1400,7 +1402,7 @@
track->mRetryCount = kMaxTrackRetries;
mixerStatus = MIXER_TRACKS_READY;
} else {
- //LOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
+ //LOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", track->name(), cblk->user, cblk->server, this);
if (track->isStopped()) {
track->reset();
}
@@ -1914,7 +1916,7 @@
// ----------------------------------------------------------------------------
AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger, AudioFlinger::MixerThread* mainThread, int id)
- : MixerThread(audioFlinger, mainThread->getOutput(), id)
+ : MixerThread(audioFlinger, mainThread->getOutput(), id), mWaitTimeMs(UINT_MAX)
{
mType = PlaybackThread::DUPLICATING;
addOutputTrack(mainThread);
@@ -1952,6 +1954,7 @@
if (checkForNewParameters_l()) {
mixBufferSize = mFrameCount*mFrameSize;
+ updateWaitTime();
activeSleepTime = activeSleepTimeUs();
idleSleepTime = idleSleepTimeUs();
}
@@ -2003,7 +2006,11 @@
if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) {
// mix buffers...
- mAudioMixer->process(curBuf);
+ if (outputsReady(outputTracks)) {
+ mAudioMixer->process(curBuf);
+ } else {
+ memset(curBuf, 0, mixBufferSize);
+ }
sleepTime = 0;
writeFrames = mFrameCount;
} else {
@@ -2054,6 +2061,7 @@
{
int frameCount = (3 * mFrameCount * mSampleRate) / thread->sampleRate();
OutputTrack *outputTrack = new OutputTrack((ThreadBase *)thread,
+ this,
mSampleRate,
mFormat,
mChannelCount,
@@ -2062,6 +2070,7 @@
thread->setStreamVolume(AudioSystem::NUM_STREAM_TYPES, 1.0f);
mOutputTracks.add(outputTrack);
LOGV("addOutputTrack() track %p, on thread %p", outputTrack, thread);
+ updateWaitTime();
}
}
@@ -2072,12 +2081,50 @@
if (mOutputTracks[i]->thread() == (ThreadBase *)thread) {
mOutputTracks[i]->destroy();
mOutputTracks.removeAt(i);
+ updateWaitTime();
return;
}
}
LOGV("removeOutputTrack(): unkonwn thread: %p", thread);
}
+void AudioFlinger::DuplicatingThread::updateWaitTime()
+{
+ mWaitTimeMs = UINT_MAX;
+ for (size_t i = 0; i < mOutputTracks.size(); i++) {
+ sp<ThreadBase> strong = mOutputTracks[i]->thread().promote();
+ if (strong != NULL) {
+ uint32_t waitTimeMs = (strong->frameCount() * 2 * 1000) / strong->sampleRate();
+ if (waitTimeMs < mWaitTimeMs) {
+ mWaitTimeMs = waitTimeMs;
+ }
+ }
+ }
+}
+
+
+bool AudioFlinger::DuplicatingThread::outputsReady(SortedVector< sp<OutputTrack> > &outputTracks)
+{
+ for (size_t i = 0; i < outputTracks.size(); i++) {
+ sp <ThreadBase> thread = outputTracks[i]->thread().promote();
+ if (thread == 0) {
+ LOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
+ return false;
+ }
+ PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
+ if (playbackThread->standby() && !playbackThread->isSuspended()) {
+ LOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
+ return false;
+ }
+ }
+ return true;
+}
+
+uint32_t AudioFlinger::DuplicatingThread::activeSleepTimeUs()
+{
+ return (mWaitTimeMs * 1000) / 2;
+}
+
// ----------------------------------------------------------------------------
// TrackBase constructor must be called with AudioFlinger::mLock held
@@ -2616,12 +2663,13 @@
AudioFlinger::PlaybackThread::OutputTrack::OutputTrack(
const wp<ThreadBase>& thread,
+ DuplicatingThread *sourceThread,
uint32_t sampleRate,
int format,
int channelCount,
int frameCount)
: Track(thread, NULL, AudioSystem::NUM_STREAM_TYPES, sampleRate, format, channelCount, frameCount, NULL),
- mActive(false)
+ mActive(false), mSourceThread(sourceThread)
{
PlaybackThread *playbackThread = (PlaybackThread *)thread.unsafe_get();
@@ -2630,10 +2678,9 @@
mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
mCblk->volume[0] = mCblk->volume[1] = 0x1000;
mOutBuffer.frameCount = 0;
- mWaitTimeMs = (playbackThread->frameCount() * 2 * 1000) / playbackThread->sampleRate();
playbackThread->mTracks.add(this);
- LOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, mCblk->frameCount %d, mCblk->sampleRate %d, mCblk->channels %d mBufferEnd %p mWaitTimeMs %d",
- mCblk, mBuffer, mCblk->buffers, mCblk->frameCount, mCblk->sampleRate, mCblk->channels, mBufferEnd, mWaitTimeMs);
+ LOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, mCblk->frameCount %d, mCblk->sampleRate %d, mCblk->channels %d mBufferEnd %p",
+ mCblk, mBuffer, mCblk->buffers, mCblk->frameCount, mCblk->sampleRate, mCblk->channels, mBufferEnd);
} else {
LOGW("Error creating output track on thread %p", playbackThread);
}
@@ -2673,7 +2720,7 @@
inBuffer.frameCount = frames;
inBuffer.i16 = data;
- uint32_t waitTimeLeftMs = mWaitTimeMs;
+ uint32_t waitTimeLeftMs = mSourceThread->waitTimeMs();
if (!mActive && frames != 0) {
start();
@@ -2712,12 +2759,11 @@
mOutBuffer.frameCount = pInBuffer->frameCount;
nsecs_t startTime = systemTime();
if (obtainBuffer(&mOutBuffer, waitTimeLeftMs) == (status_t)AudioTrack::NO_MORE_BUFFERS) {
- LOGV ("OutputTrack::write() %p no more output buffers", this);
+ LOGV ("OutputTrack::write() %p thread %p no more output buffers", this, mThread.unsafe_get());
outputBufferFull = true;
break;
}
uint32_t waitTimeMs = (uint32_t)ns2ms(systemTime() - startTime);
- LOGV("OutputTrack::write() to thread %p waitTimeMs %d waitTimeLeftMs %d", mThread.unsafe_get(), waitTimeMs, waitTimeLeftMs);
if (waitTimeLeftMs >= waitTimeMs) {
waitTimeLeftMs -= waitTimeMs;
} else {
@@ -2738,7 +2784,7 @@
mBufferQueue.removeAt(0);
delete [] pInBuffer->mBuffer;
delete pInBuffer;
- LOGV("OutputTrack::write() %p released overflow buffer %d", this, mBufferQueue.size());
+ LOGV("OutputTrack::write() %p thread %p released overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
} else {
break;
}
@@ -2747,16 +2793,19 @@
// If we could not write all frames, allocate a buffer and queue it for next time.
if (inBuffer.frameCount) {
- if (mBufferQueue.size() < kMaxOverFlowBuffers) {
- pInBuffer = new Buffer;
- pInBuffer->mBuffer = new int16_t[inBuffer.frameCount * channels];
- pInBuffer->frameCount = inBuffer.frameCount;
- pInBuffer->i16 = pInBuffer->mBuffer;
- memcpy(pInBuffer->raw, inBuffer.raw, inBuffer.frameCount * channels * sizeof(int16_t));
- mBufferQueue.add(pInBuffer);
- LOGV("OutputTrack::write() %p adding overflow buffer %d", this, mBufferQueue.size());
- } else {
- LOGW("OutputTrack::write() %p no more overflow buffers", this);
+ sp<ThreadBase> thread = mThread.promote();
+ if (thread != 0 && !thread->standby()) {
+ if (mBufferQueue.size() < kMaxOverFlowBuffers) {
+ pInBuffer = new Buffer;
+ pInBuffer->mBuffer = new int16_t[inBuffer.frameCount * channels];
+ pInBuffer->frameCount = inBuffer.frameCount;
+ pInBuffer->i16 = pInBuffer->mBuffer;
+ memcpy(pInBuffer->raw, inBuffer.raw, inBuffer.frameCount * channels * sizeof(int16_t));
+ mBufferQueue.add(pInBuffer);
+ LOGV("OutputTrack::write() %p thread %p adding overflow buffer %d", this, mThread.unsafe_get(), mBufferQueue.size());
+ } else {
+ LOGW("OutputTrack::write() %p thread %p no more overflow buffers", mThread.unsafe_get(), this);
+ }
}
}
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 8c29da8..12c90eb 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
+#include <limits.h>
#include <media/IAudioFlinger.h>
#include <media/IAudioFlingerClient.h>
@@ -208,6 +209,7 @@
class PlaybackThread;
class MixerThread;
class DirectOutputThread;
+ class DuplicatingThread;
class Track;
class RecordTrack;
@@ -324,6 +326,7 @@
void sendConfigEvent_l(int event, int param = 0);
void processConfigEvents();
int id() const { return mId;}
+ bool standby() { return mStandby; }
mutable Mutex mLock;
@@ -452,6 +455,7 @@
};
OutputTrack( const wp<ThreadBase>& thread,
+ DuplicatingThread *sourceThread,
uint32_t sampleRate,
int format,
int channelCount,
@@ -471,13 +475,12 @@
void clearBufferQueue();
// Maximum number of pending buffers allocated by OutputTrack::write()
- static const uint8_t kMaxOverFlowBuffers = 3;
+ static const uint8_t kMaxOverFlowBuffers = 10;
Vector < Buffer* > mBufferQueue;
AudioBufferProvider::Buffer mOutBuffer;
- uint32_t mWaitTimeMs;
bool mActive;
-
+ DuplicatingThread* mSourceThread;
}; // end of OutputTrack
PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id);
@@ -520,6 +523,7 @@
virtual int type() const { return mType; }
void suspend() { mSuspended++; }
void restore() { if (mSuspended) mSuspended--; }
+ bool isSuspended() { return (mSuspended != 0); }
virtual String8 getParameters(const String8& keys);
virtual void audioConfigChanged(int event, int param = 0);
@@ -635,9 +639,16 @@
virtual bool threadLoop();
void addOutputTrack(MixerThread* thread);
void removeOutputTrack(MixerThread* thread);
+ uint32_t waitTimeMs() { return mWaitTimeMs; }
+ protected:
+ virtual uint32_t activeSleepTimeUs();
private:
+ bool outputsReady(SortedVector< sp<OutputTrack> > &outputTracks);
+ void updateWaitTime();
+
SortedVector < sp<OutputTrack> > mOutputTracks;
+ uint32_t mWaitTimeMs;
};
PlaybackThread *checkPlaybackThread_l(int output) const;
diff --git a/opengl/libagl/fixed_asm.S b/opengl/libagl/fixed_asm.S
index 6cbc56f..05044f2 100644
--- a/opengl/libagl/fixed_asm.S
+++ b/opengl/libagl/fixed_asm.S
@@ -20,7 +20,9 @@
.align
.global gglFloatToFixed
+ .type gglFloatToFixed, %function
.global gglFloatToFixedFast
+ .type gglFloatToFixedFast, %function
/*
diff --git a/opengl/libagl/iterators.S b/opengl/libagl/iterators.S
index daf2937..8c86482 100644
--- a/opengl/libagl/iterators.S
+++ b/opengl/libagl/iterators.S
@@ -21,6 +21,7 @@
.arm
.global iterators0032
+ .type iterators0032, %function
/*
* iterators0032
diff --git a/opengl/tests/fillrate/Android.mk b/opengl/tests/fillrate/Android.mk
index a7d30c2..191c59b 100644
--- a/opengl/tests/fillrate/Android.mk
+++ b/opengl/tests/fillrate/Android.mk
@@ -6,6 +6,7 @@
LOCAL_SHARED_LIBRARIES := \
libcutils \
+ libutils \
libEGL \
libGLESv1_CM \
libui
diff --git a/opengl/tests/finish/Android.mk b/opengl/tests/finish/Android.mk
index 5620814..aa607c6 100644
--- a/opengl/tests/finish/Android.mk
+++ b/opengl/tests/finish/Android.mk
@@ -6,6 +6,7 @@
LOCAL_SHARED_LIBRARIES := \
libcutils \
+ libutils \
libEGL \
libGLESv1_CM \
libui
diff --git a/opengl/tests/gl_basic/gl_basic.cpp b/opengl/tests/gl_basic/gl_basic.cpp
index 7dc2378..feb964a 100644
--- a/opengl/tests/gl_basic/gl_basic.cpp
+++ b/opengl/tests/gl_basic/gl_basic.cpp
@@ -1,32 +1,39 @@
// Simple OpenGL ES 1.x application showing how to initialize and draw something.
-#include <EGL/egl.h>
+#include <EGL/egl.h>
+
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/EGLUtils.h>
-#include <stdio.h>
+#include <stdio.h>
+
#include <stdlib.h>
#include <math.h>
using namespace android;
-
-EGLDisplay eglDisplay;
-EGLSurface eglSurface;
-EGLContext eglContext;
-GLuint texture;
-
+
+EGLDisplay eglDisplay;
+EGLSurface eglSurface;
+EGLContext eglContext;
+GLuint texture;
+
#define FIXED_ONE 0x10000
-#define ITERATIONS 50
-
-int init_gl_surface(void);
-void free_gl_surface(void);
-void init_scene(void);
-void render();
+#define ITERATIONS 50
+
+int init_gl_surface(void);
+void free_gl_surface(void);
+void init_scene(void);
+void render();
void create_texture(void);
-int readTimer(void);
+int readTimer(void);
+
+static void printGLString(const char *name, GLenum s) {
+ const char *v = (const char *) glGetString(s);
+ fprintf(stderr, "GL %s = %s\n", name, v);
+}
static void gluLookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ, float upX, float upY,
@@ -87,7 +94,6 @@
glTranslatef(-eyeX, -eyeY, -eyeZ);
}
-
void printEGLConfiguration(EGLDisplay dpy, EGLConfig config) {
#define X(VAL) {VAL, #VAL}
@@ -183,125 +189,129 @@
free(configs);
return true;
}
-
-int main(int argc, char **argv)
-{
+
+int main(int argc, char **argv)
+{
int q;
- int start, end;
-
+ int start, end;
printf("Initializing EGL...\n");
-
- if(!init_gl_surface())
- {
- printf("GL initialisation failed - exiting\n");
- return 0;
- }
-
- init_scene();
-
- create_texture();
-
+ if(!init_gl_surface())
+ {
+ printf("GL initialisation failed - exiting\n");
+ return 0;
+ }
+ init_scene();
+ create_texture();
printf("Running...\n");
-
while(true) {
render();
- }
-
- free_gl_surface();
-
- return 0;
-}
-
-int init_gl_surface(void)
-{
- EGLint numConfigs = 1;
- EGLConfig myConfig = {0};
- EGLint attrib[] =
- {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_NONE
- };
-
- if ( (eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY )
- {
- printf("eglGetDisplay failed\n");
- return 0;
}
-
- if ( eglInitialize(eglDisplay, NULL, NULL) != EGL_TRUE )
- {
- printf("eglInitialize failed\n");
- return 0;
+ free_gl_surface();
+ return 0;
+}
+
+int init_gl_surface(void)
+{
+ EGLint numConfigs = 1;
+ EGLConfig myConfig = {0};
+ EGLint attrib[] =
+ {
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_NONE
+ };
+
+ if ( (eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY )
+ {
+ printf("eglGetDisplay failed\n");
+ return 0;
+ }
+
+ if ( eglInitialize(eglDisplay, NULL, NULL) != EGL_TRUE )
+ {
+ printf("eglInitialize failed\n");
+ return 0;
}
if (! printEGLConfigurations(eglDisplay)) {
printf("printEGLConfigurations failed.\n");
return 0;
- }
- EGLNativeWindowType window = android_createDisplaySurface();
- EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig);
-
+ }
+
+ EGLNativeWindowType window = android_createDisplaySurface();
+ EGLUtils::selectConfigForNativeWindow(eglDisplay, attrib, window, &myConfig);
+
if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,
- window, 0)) == EGL_NO_SURFACE )
- {
- printf("eglCreateWindowSurface failed\n");
- return 0;
- }
-
- if ( (eglContext = eglCreateContext(eglDisplay, myConfig, 0, 0)) == EGL_NO_CONTEXT )
- {
- printf("eglCreateContext failed\n");
- return 0;
- }
-
- if ( eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) != EGL_TRUE )
- {
- printf("eglMakeCurrent failed\n");
- return 0;
- }
-
- return 1;
-}
-
-void free_gl_surface(void)
-{
- if (eglDisplay != EGL_NO_DISPLAY)
- {
- eglMakeCurrent( EGL_NO_DISPLAY, EGL_NO_SURFACE,
- EGL_NO_SURFACE, EGL_NO_CONTEXT );
- eglDestroyContext( eglDisplay, eglContext );
- eglDestroySurface( eglDisplay, eglSurface );
- eglTerminate( eglDisplay );
- eglDisplay = EGL_NO_DISPLAY;
- }
-}
-
-void init_scene(void)
-{
+ window, 0)) == EGL_NO_SURFACE )
+ {
+ printf("eglCreateWindowSurface failed\n");
+ return 0;
+ }
+
+ if ( (eglContext = eglCreateContext(eglDisplay, myConfig, 0, 0)) == EGL_NO_CONTEXT )
+ {
+ printf("eglCreateContext failed\n");
+ return 0;
+ }
+
+ if ( eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) != EGL_TRUE )
+ {
+ printf("eglMakeCurrent failed\n");
+ return 0;
+ }
+
+ int w, h;
+
+ eglQuerySurface(eglDisplay, eglSurface, EGL_WIDTH, &w);
+ checkEglError("eglQuerySurface");
+ eglQuerySurface(eglDisplay, eglSurface, EGL_HEIGHT, &h);
+ checkEglError("eglQuerySurface");
+ GLint dim = w < h ? w : h;
+
+ fprintf(stderr, "Window dimensions: %d x %d\n", w, h);
+
+ printGLString("Version", GL_VERSION);
+ printGLString("Vendor", GL_VENDOR);
+ printGLString("Renderer", GL_RENDERER);
+ printGLString("Extensions", GL_EXTENSIONS);
+
+ return 1;
+}
+
+void free_gl_surface(void)
+{
+ if (eglDisplay != EGL_NO_DISPLAY)
+ {
+ eglMakeCurrent( EGL_NO_DISPLAY, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT );
+ eglDestroyContext( eglDisplay, eglContext );
+ eglDestroySurface( eglDisplay, eglSurface );
+ eglTerminate( eglDisplay );
+ eglDisplay = EGL_NO_DISPLAY;
+ }
+}
+
+void init_scene(void)
+{
glDisable(GL_DITHER);
glEnable(GL_CULL_FACE);
-
float ratio = 320.0f / 480.0f;
glViewport(0, 0, 320, 480);
-
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustumf(-ratio, ratio, -1, 1, 1, 10);
-
- glMatrixMode(GL_MODELVIEW);
+ glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(
0, 0, 3, // eye
0, 0, 0, // center
0, 1, 0); // up
-
- glEnable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-}
-
-void create_texture(void)
-{
+}
+
+void create_texture(void)
+{
const unsigned int on = 0xff0000ff;
const unsigned int off = 0xffffffff;
const unsigned int pixels[] =
@@ -314,44 +324,42 @@
off, on, off, on, off, on, off, on,
on, off, on, off, on, off, on, off,
off, on, off, on, off, on, off, on,
- };
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-}
-
-void render()
-{
+ };
+
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+}
+
+void render()
+{
int i, j;
- int quads = 1;
-
- const GLfloat vertices[] = {
- -1, -1, 0,
- 1, -1, 0,
- 1, 1, 0,
- -1, 1, 0
- };
-
- const GLfixed texCoords[] = {
- 0, 0,
- FIXED_ONE, 0,
- FIXED_ONE, FIXED_ONE,
- 0, FIXED_ONE
- };
-
+ int quads = 1;
+
+ const GLfloat vertices[] = {
+ -1, -1, 0,
+ 1, -1, 0,
+ 1, 1, 0,
+ -1, 1, 0
+ };
+
+ const GLfixed texCoords[] = {
+ 0, 0,
+ FIXED_ONE, 0,
+ FIXED_ONE, FIXED_ONE,
+ 0, FIXED_ONE
+ };
+
const GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
-
- glVertexPointer(3, GL_FLOAT, 0, vertices);
+
+ glVertexPointer(3, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FIXED, 0, texCoords);
-
glClearColor(1.0, 1.0, 1.0, 1.0);
-
int nelem = sizeof(indices)/sizeof(indices[0]);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, nelem, GL_UNSIGNED_SHORT, indices);
- eglSwapBuffers(eglDisplay, eglSurface);
-}
-
+ eglSwapBuffers(eglDisplay, eglSurface);
+}
diff --git a/opengl/tests/swapinterval/Android.mk b/opengl/tests/swapinterval/Android.mk
index 619447c..9a4145e 100644
--- a/opengl/tests/swapinterval/Android.mk
+++ b/opengl/tests/swapinterval/Android.mk
@@ -6,6 +6,7 @@
LOCAL_SHARED_LIBRARIES := \
libcutils \
+ libutils \
libEGL \
libGLESv1_CM \
libui
diff --git a/vpn/java/android/net/vpn/VpnManager.java b/vpn/java/android/net/vpn/VpnManager.java
index 6df612e..ce40b5d 100644
--- a/vpn/java/android/net/vpn/VpnManager.java
+++ b/vpn/java/android/net/vpn/VpnManager.java
@@ -16,11 +16,15 @@
package android.net.vpn;
+import java.io.File;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
+import android.os.Environment;
+import android.os.SystemProperties;
import android.util.Log;
/**
@@ -65,7 +69,7 @@
/** Error code to indicate a successful connection. */
public static final int VPN_ERROR_NO_ERROR = 0;
- public static final String PROFILES_PATH = "/data/misc/vpn/profiles";
+ public static final String PROFILES_PATH = "/misc/vpn/profiles";
private static final String PACKAGE_PREFIX =
VpnManager.class.getPackage().getName() + ".";
@@ -77,7 +81,13 @@
private static final String ACTION_VPN_SETTINGS =
PACKAGE_PREFIX + "SETTINGS";
- private static final String TAG = VpnManager.class.getSimpleName();
+ public static final String TAG = VpnManager.class.getSimpleName();
+
+ // TODO(oam): Test VPN when EFS is enabled (will do later)...
+ public static String getProfilePath() {
+ // This call will return the correct path if Encrypted FS is enabled or not.
+ return Environment.getSecureDataDirectory().getPath() + PROFILES_PATH;
+ }
/**
* Returns all supported VPN types.