diff options
| author | 2011-01-18 20:30:13 -0800 | |
|---|---|---|
| committer | 2011-01-18 20:30:13 -0800 | |
| commit | 2bc6971dd82d37273b0baafeeebf3ba90d15837f (patch) | |
| tree | fc4e83015e232ff7021d51ebece153d48e23bd73 | |
| parent | 3cd030a4fe229155b252cee003c78e2467ff4d82 (diff) | |
| parent | 242d0cdc1ad6c48faca403ea352bde73138443b5 (diff) | |
Merge changes I7df1ff78,Ibc2e8adf into honeycomb
* changes:
MediaScanner: Make sure name field is set for file based playlists
MTP: Fix problem with MTP starting up on the first try.
| -rw-r--r-- | media/java/android/media/MediaScanner.java | 25 | ||||
| -rw-r--r-- | media/jni/android_mtp_MtpServer.cpp | 26 |
2 files changed, 37 insertions, 14 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 10c9a9a99f5a..33c63856ce13 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -1462,22 +1462,29 @@ public class MediaScanner if (lastSlash < 0) throw new IllegalArgumentException("bad path " + path); Uri uri, membersUri; long rowId = entry.mRowId; - if (rowId == 0) { - // Create a new playlist - int lastDot = path.lastIndexOf('.'); - String name = (lastDot < 0 ? path.substring(lastSlash + 1) : path.substring(lastSlash + 1, lastDot)); - values.put(MediaStore.Audio.Playlists.NAME, name); + // make sure we have a name + String name = values.getAsString(MediaStore.Audio.Playlists.NAME); + if (name == null) { + name = values.getAsString(MediaStore.MediaColumns.TITLE); + if (name == null) { + // extract name from file name + int lastDot = path.lastIndexOf('.'); + name = (lastDot < 0 ? path.substring(lastSlash + 1) + : path.substring(lastSlash + 1, lastDot)); + } + } + + values.put(MediaStore.Audio.Playlists.NAME, name); + values.put(MediaStore.Audio.Playlists.DATE_MODIFIED, entry.mLastModified); + + if (rowId == 0) { values.put(MediaStore.Audio.Playlists.DATA, path); - values.put(MediaStore.Audio.Playlists.DATE_MODIFIED, entry.mLastModified); uri = mMediaProvider.insert(mPlaylistsUri, values); rowId = ContentUris.parseId(uri); membersUri = Uri.withAppendedPath(uri, Playlists.Members.CONTENT_DIRECTORY); } else { uri = ContentUris.withAppendedId(mPlaylistsUri, rowId); - - // update lastModified value of existing playlist - values.put(MediaStore.Audio.Playlists.DATE_MODIFIED, entry.mLastModified); mMediaProvider.update(uri, values, null, null); // delete members of existing playlist diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp index 241f18a0d2e8..4693ec5c768d 100644 --- a/media/jni/android_mtp_MtpServer.cpp +++ b/media/jni/android_mtp_MtpServer.cpp @@ -62,6 +62,7 @@ private: String8 mStoragePath; uint64_t mReserveSpace; jobject mJavaServer; + bool mDone; int mFd; public: @@ -72,6 +73,7 @@ public: mStoragePath(storagePath), mReserveSpace(reserveSpace), mJavaServer(javaServer), + mDone(false), mFd(-1) { } @@ -104,12 +106,17 @@ public: mServer = new MtpServer(mFd, mDatabase, AID_MEDIA_RW, 0664, 0775); mServer->addStorage(mStoragePath, mReserveSpace); - sMutex.unlock(); - LOGD("MtpThread mServer->run"); - mServer->run(); + while (!mDone) { + sMutex.unlock(); + + LOGD("MtpThread mServer->run"); + mServer->run(); + sleep(1); + + sMutex.lock(); + } - sMutex.lock(); close(mFd); mFd = -1; delete mServer; @@ -124,6 +131,12 @@ public: return false; } + void stop() { + sMutex.lock(); + mDone = true; + sMutex.unlock(); + } + void sendObjectAdded(MtpObjectHandle handle) { sMutex.lock(); if (mServer) @@ -181,6 +194,9 @@ android_mtp_MtpServer_stop(JNIEnv *env, jobject thiz) { #ifdef HAVE_ANDROID_OS LOGD("stop\n"); + MtpThread *thread = (MtpThread *)env->GetIntField(thiz, field_context); + if (thread) + thread->stop(); #endif } @@ -212,7 +228,7 @@ android_mtp_MtpServer_set_ptp_mode(JNIEnv *env, jobject thiz, jboolean usePtp) MtpThread *thread = (MtpThread *)env->GetIntField(thiz, field_context); if (thread) thread->setPtpMode(usePtp); - #endif +#endif } // ---------------------------------------------------------------------------- |