diff options
56 files changed, 1038 insertions, 1787 deletions
diff --git a/api/current.xml b/api/current.xml index e72a88c..a29a1a9 100644 --- a/api/current.xml +++ b/api/current.xml @@ -8842,6 +8842,17 @@ visibility="public" > </field> +<field name="wallpaperAuthor" + type="int" + transient="false" + volatile="false" + value="16843444" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="wallpaperCloseEnterAnimation" type="int" transient="false" @@ -8864,6 +8875,17 @@ visibility="public" > </field> +<field name="wallpaperDescription" + type="int" + transient="false" + volatile="false" + value="16843445" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="wallpaperIntraCloseEnterAnimation" type="int" transient="false" diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp index f8bb3c8..4ffc8e4 100644 --- a/cmds/stagefright/stagefright.cpp +++ b/cmds/stagefright/stagefright.cpp @@ -283,7 +283,7 @@ int main(int argc, char **argv) { CHECK(service.get() != NULL); - sp<IOMX> omx = service->createOMX(); + sp<IOMX> omx = service->getOMX(); CHECK(omx.get() != NULL); const char *kMimeTypes[] = { @@ -329,11 +329,11 @@ int main(int argc, char **argv) { CHECK(service.get() != NULL); - sp<IOMX> omx = service->createOMX(); + sp<IOMX> omx = service->getOMX(); CHECK(omx.get() != NULL); List<String8> list; - omx->list_nodes(&list); + omx->listNodes(&list); for (List<String8>::iterator it = list.begin(); it != list.end(); ++it) { diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java index 587e8f9..59d58aa 100644 --- a/core/java/android/app/WallpaperInfo.java +++ b/core/java/android/app/WallpaperInfo.java @@ -9,6 +9,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.res.Resources.NotFoundException; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; @@ -45,6 +46,16 @@ public final class WallpaperInfo implements Parcelable { final int mThumbnailResource; /** + * Resource identifier for a string indicating the author of the wallpaper. + */ + final int mAuthorResource; + + /** + * Resource identifier for a string containing a short description of the wallpaper. + */ + final int mDescriptionResource; + + /** * Constructor. * * @param context The Context in which we are parsing the wallpaper. @@ -59,6 +70,8 @@ public final class WallpaperInfo implements Parcelable { PackageManager pm = context.getPackageManager(); String settingsActivityComponent = null; int thumbnailRes = -1; + int authorRes = -1; + int descriptionRes = -1; XmlResourceParser parser = null; try { @@ -89,6 +102,12 @@ public final class WallpaperInfo implements Parcelable { thumbnailRes = sa.getResourceId( com.android.internal.R.styleable.Wallpaper_thumbnail, -1); + authorRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_wallpaperAuthor, + -1); + descriptionRes = sa.getResourceId( + com.android.internal.R.styleable.Wallpaper_wallpaperDescription, + -1); sa.recycle(); } finally { @@ -97,11 +116,15 @@ public final class WallpaperInfo implements Parcelable { mSettingsActivityName = settingsActivityComponent; mThumbnailResource = thumbnailRes; + mAuthorResource = authorRes; + mDescriptionResource = descriptionRes; } WallpaperInfo(Parcel source) { mSettingsActivityName = source.readString(); mThumbnailResource = source.readInt(); + mAuthorResource = source.readInt(); + mDescriptionResource = source.readInt(); mService = ResolveInfo.CREATOR.createFromParcel(source); } @@ -169,6 +192,32 @@ public final class WallpaperInfo implements Parcelable { mThumbnailResource, null); } + + /** + * Return a string indicating the author(s) of this wallpaper. + */ + public CharSequence loadAuthor(PackageManager pm) throws NotFoundException { + if (mAuthorResource <= 0) throw new NotFoundException(); + return pm.getText( + (mService.resolvePackageName != null) + ? mService.resolvePackageName + : getPackageName(), + mAuthorResource, + null); + } + + /** + * Return a brief summary of this wallpaper's behavior. + */ + public CharSequence loadDescription(PackageManager pm) throws NotFoundException { + if (mDescriptionResource <= 0) throw new NotFoundException(); + return pm.getText( + (mService.resolvePackageName != null) + ? mService.resolvePackageName + : getPackageName(), + mDescriptionResource, + null); + } /** * Return the class name of an activity that provides a settings UI for @@ -206,6 +255,8 @@ public final class WallpaperInfo implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeString(mSettingsActivityName); dest.writeInt(mThumbnailResource); + dest.writeInt(mAuthorResource); + dest.writeInt(mDescriptionResource); mService.writeToParcel(dest, flags); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 8aab595..7e6258e 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3483,6 +3483,12 @@ <!-- Reference to a the wallpaper's thumbnail bitmap. --> <attr name="thumbnail" format="reference" /> + + <!-- Name of the author of a wallpaper, e.g. Google. --> + <attr name="wallpaperAuthor" format="reference" /> + + <!-- Short description of the wallpaper's purpose or behavior. --> + <attr name="wallpaperDescription" format="reference" /> </declare-styleable> <!-- =============================== --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a0b56101..5eb1c8e 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1201,5 +1201,8 @@ <public type="attr" name="quickContactBadgeStyleSmallWindowSmall" /> <public type="attr" name="quickContactBadgeStyleSmallWindowMedium" /> <public type="attr" name="quickContactBadgeStyleSmallWindowLarge" /> + + <public type="attr" name="wallpaperAuthor" /> + <public type="attr" name="wallpaperDescription" /> </resources> diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h index 303444c..d5c1594 100644 --- a/include/media/IMediaPlayerService.h +++ b/include/media/IMediaPlayerService.h @@ -42,7 +42,7 @@ public: virtual sp<IMediaPlayer> create(pid_t pid, const sp<IMediaPlayerClient>& client, int fd, int64_t offset, int64_t length) = 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<IOMX> createOMX() = 0; + virtual sp<IOMX> getOMX() = 0; // Take a peek at currently playing audio, for visualization purposes. // This returns a buffer of 16 bit mono PCM data, or NULL if no visualization buffer is currently available. diff --git a/include/media/IOMX.h b/include/media/IOMX.h index 10e0197..6f3ba1c 100644 --- a/include/media/IOMX.h +++ b/include/media/IOMX.h @@ -42,57 +42,57 @@ public: typedef void *buffer_id; typedef void *node_id; - virtual status_t list_nodes(List<String8> *list) = 0; + virtual status_t listNodes(List<String8> *list) = 0; - virtual status_t allocate_node(const char *name, node_id *node) = 0; - virtual status_t free_node(node_id node) = 0; + virtual status_t allocateNode( + const char *name, const sp<IOMXObserver> &observer, + node_id *node) = 0; - virtual status_t send_command( + virtual status_t freeNode(node_id node) = 0; + + virtual status_t sendCommand( node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0; - virtual status_t get_parameter( + virtual status_t getParameter( node_id node, OMX_INDEXTYPE index, void *params, size_t size) = 0; - virtual status_t set_parameter( + virtual status_t setParameter( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) = 0; - virtual status_t get_config( + virtual status_t getConfig( node_id node, OMX_INDEXTYPE index, void *params, size_t size) = 0; - virtual status_t set_config( + virtual status_t setConfig( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) = 0; - virtual status_t use_buffer( + virtual status_t useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) = 0; - virtual status_t allocate_buffer( + virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) = 0; - virtual status_t allocate_buffer_with_backup( + virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) = 0; - virtual status_t free_buffer( + virtual status_t freeBuffer( node_id node, OMX_U32 port_index, buffer_id buffer) = 0; - virtual status_t observe_node( - node_id node, const sp<IOMXObserver> &observer) = 0; - - virtual void fill_buffer(node_id node, buffer_id buffer) = 0; + virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0; - virtual void empty_buffer( + virtual status_t emptyBuffer( node_id node, buffer_id buffer, OMX_U32 range_offset, OMX_U32 range_length, OMX_U32 flags, OMX_TICKS timestamp) = 0; - virtual status_t get_extension_index( + virtual status_t getExtensionIndex( node_id node, const char *parameter_name, OMX_INDEXTYPE *index) = 0; @@ -162,7 +162,7 @@ class IOMXObserver : public IInterface { public: DECLARE_META_INTERFACE(OMXObserver); - virtual void on_message(const omx_message &msg) = 0; + virtual void onMessage(const omx_message &msg) = 0; }; class IOMXRenderer : public IInterface { diff --git a/include/media/stagefright/HTTPStream.h b/include/media/stagefright/HTTPStream.h index 3d0d67a..72e796c 100644 --- a/include/media/stagefright/HTTPStream.h +++ b/include/media/stagefright/HTTPStream.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <media/stagefright/MediaErrors.h> -#include <media/stagefright/string.h> +#include <media/stagefright/stagefright_string.h> #include <utils/KeyedVector.h> namespace android { diff --git a/include/media/stagefright/string.h b/include/media/stagefright/stagefright_string.h index 5dc7116..1ed4c86 100644 --- a/include/media/stagefright/string.h +++ b/include/media/stagefright/stagefright_string.h @@ -14,9 +14,9 @@ * limitations under the License. */ -#ifndef STRING_H_ +#ifndef STAGEFRIGHT_STRING_H_ -#define STRING_H_ +#define STAGEFRIGHT_STRING_H_ #include <utils/String8.h> @@ -51,4 +51,4 @@ private: } // namespace android -#endif // STRING_H_ +#endif // STAGEFRIGHT_STRING_H_ diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp index 98f7ef1..cca3e9b 100644 --- a/media/libmedia/IMediaPlayerService.cpp +++ b/media/libmedia/IMediaPlayerService.cpp @@ -35,7 +35,7 @@ enum { DECODE_FD, CREATE_MEDIA_RECORDER, CREATE_METADATA_RETRIEVER, - CREATE_OMX, + GET_OMX, SNOOP }; @@ -123,10 +123,10 @@ public: return interface_cast<IMemory>(reply.readStrongBinder()); } - virtual sp<IOMX> createOMX() { + virtual sp<IOMX> getOMX() { Parcel data, reply; data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor()); - remote()->transact(CREATE_OMX, data, &reply); + remote()->transact(GET_OMX, data, &reply); return interface_cast<IOMX>(reply.readStrongBinder()); } }; @@ -207,9 +207,9 @@ status_t BnMediaPlayerService::onTransact( reply->writeStrongBinder(retriever->asBinder()); return NO_ERROR; } break; - case CREATE_OMX: { + case GET_OMX: { CHECK_INTERFACE(IMediaPlayerService, data, reply); - sp<IOMX> omx = createOMX(); + sp<IOMX> omx = getOMX(); reply->writeStrongBinder(omx->asBinder()); return NO_ERROR; } break; diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp index 0cec7bb..88a7064 100644 --- a/media/libmedia/IOMX.cpp +++ b/media/libmedia/IOMX.cpp @@ -24,7 +24,6 @@ enum { ALLOC_BUFFER, ALLOC_BUFFER_WITH_BACKUP, FREE_BUFFER, - OBSERVE_NODE, FILL_BUFFER, EMPTY_BUFFER, GET_EXTENSION_INDEX, @@ -76,7 +75,7 @@ public: : BpInterface<IOMX>(impl) { } - virtual status_t list_nodes(List<String8> *list) { + virtual status_t listNodes(List<String8> *list) { list->clear(); Parcel data, reply; @@ -93,10 +92,12 @@ public: return OK; } - virtual status_t allocate_node(const char *name, node_id *node) { + virtual status_t allocateNode( + const char *name, const sp<IOMXObserver> &observer, node_id *node) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeCString(name); + data.writeStrongBinder(observer->asBinder()); remote()->transact(ALLOCATE_NODE, data, &reply); status_t err = reply.readInt32(); @@ -109,7 +110,7 @@ public: return err; } - virtual status_t free_node(node_id node) { + virtual status_t freeNode(node_id node) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeIntPtr((intptr_t)node); @@ -118,7 +119,7 @@ public: return reply.readInt32(); } - virtual status_t send_command( + virtual status_t sendCommand( node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); @@ -130,7 +131,7 @@ public: return reply.readInt32(); } - virtual status_t get_parameter( + virtual status_t getParameter( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { Parcel data, reply; @@ -151,7 +152,7 @@ public: return OK; } - virtual status_t set_parameter( + virtual status_t setParameter( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { Parcel data, reply; @@ -165,7 +166,7 @@ public: return reply.readInt32(); } - virtual status_t get_config( + virtual status_t getConfig( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { Parcel data, reply; @@ -186,7 +187,7 @@ public: return OK; } - virtual status_t set_config( + virtual status_t setConfig( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { Parcel data, reply; @@ -200,7 +201,7 @@ public: return reply.readInt32(); } - virtual status_t use_buffer( + virtual status_t useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) { Parcel data, reply; @@ -222,7 +223,7 @@ public: return err; } - virtual status_t allocate_buffer( + virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) { Parcel data, reply; @@ -244,7 +245,7 @@ public: return err; } - virtual status_t allocate_buffer_with_backup( + virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) { Parcel data, reply; @@ -266,7 +267,7 @@ public: return err; } - virtual status_t free_buffer( + virtual status_t freeBuffer( node_id node, OMX_U32 port_index, buffer_id buffer) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); @@ -278,26 +279,17 @@ public: return reply.readInt32(); } - virtual status_t observe_node( - node_id node, const sp<IOMXObserver> &observer) { - Parcel data, reply; - data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); - data.writeIntPtr((intptr_t)node); - data.writeStrongBinder(observer->asBinder()); - remote()->transact(OBSERVE_NODE, data, &reply); - - return reply.readInt32(); - } - - virtual void fill_buffer(node_id node, buffer_id buffer) { + virtual status_t fillBuffer(node_id node, buffer_id buffer) { Parcel data, reply; data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); data.writeIntPtr((intptr_t)node); data.writeIntPtr((intptr_t)buffer); remote()->transact(FILL_BUFFER, data, &reply, IBinder::FLAG_ONEWAY); + + return reply.readInt32(); } - virtual void empty_buffer( + virtual status_t emptyBuffer( node_id node, buffer_id buffer, OMX_U32 range_offset, OMX_U32 range_length, @@ -311,9 +303,11 @@ public: data.writeInt32(flags); data.writeInt64(timestamp); remote()->transact(EMPTY_BUFFER, data, &reply, IBinder::FLAG_ONEWAY); + + return reply.readInt32(); } - virtual status_t get_extension_index( + virtual status_t getExtensionIndex( node_id node, const char *parameter_name, OMX_INDEXTYPE *index) { @@ -375,7 +369,7 @@ status_t BnOMX::onTransact( CHECK_INTERFACE(IOMX, data, reply); List<String8> list; - list_nodes(&list); + listNodes(&list); reply->writeInt32(list.size()); for (List<String8>::iterator it = list.begin(); @@ -390,8 +384,14 @@ status_t BnOMX::onTransact( { CHECK_INTERFACE(IOMX, data, reply); + const char *name = data.readCString(); + + sp<IOMXObserver> observer = + interface_cast<IOMXObserver>(data.readStrongBinder()); + node_id node; - status_t err = allocate_node(data.readCString(), &node); + + status_t err = allocateNode(name, observer, &node); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)node); @@ -406,7 +406,7 @@ status_t BnOMX::onTransact( node_id node = (void*)data.readIntPtr(); - reply->writeInt32(free_node(node)); + reply->writeInt32(freeNode(node)); return NO_ERROR; } @@ -421,7 +421,7 @@ status_t BnOMX::onTransact( static_cast<OMX_COMMANDTYPE>(data.readInt32()); OMX_S32 param = data.readInt32(); - reply->writeInt32(send_command(node, cmd, param)); + reply->writeInt32(sendCommand(node, cmd, param)); return NO_ERROR; } @@ -439,7 +439,7 @@ status_t BnOMX::onTransact( void *params = malloc(size); data.read(params, size); - status_t err = get_parameter(node, index, params, size); + status_t err = getParameter(node, index, params, size); reply->writeInt32(err); @@ -463,7 +463,7 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); void *params = const_cast<void *>(data.readInplace(size)); - reply->writeInt32(set_parameter(node, index, params, size)); + reply->writeInt32(setParameter(node, index, params, size)); return NO_ERROR; } @@ -481,7 +481,7 @@ status_t BnOMX::onTransact( void *params = malloc(size); data.read(params, size); - status_t err = get_config(node, index, params, size); + status_t err = getConfig(node, index, params, size); reply->writeInt32(err); @@ -505,7 +505,7 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); void *params = const_cast<void *>(data.readInplace(size)); - reply->writeInt32(set_config(node, index, params, size)); + reply->writeInt32(setConfig(node, index, params, size)); return NO_ERROR; } @@ -520,7 +520,7 @@ status_t BnOMX::onTransact( interface_cast<IMemory>(data.readStrongBinder()); buffer_id buffer; - status_t err = use_buffer(node, port_index, params, &buffer); + status_t err = useBuffer(node, port_index, params, &buffer); reply->writeInt32(err); if (err == OK) { @@ -539,7 +539,7 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); buffer_id buffer; - status_t err = allocate_buffer(node, port_index, size, &buffer); + status_t err = allocateBuffer(node, port_index, size, &buffer); reply->writeInt32(err); if (err == OK) { @@ -559,7 +559,7 @@ status_t BnOMX::onTransact( interface_cast<IMemory>(data.readStrongBinder()); buffer_id buffer; - status_t err = allocate_buffer_with_backup( + status_t err = allocateBufferWithBackup( node, port_index, params, &buffer); reply->writeInt32(err); @@ -578,19 +578,7 @@ status_t BnOMX::onTransact( node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); buffer_id buffer = (void*)data.readIntPtr(); - reply->writeInt32(free_buffer(node, port_index, buffer)); - - return NO_ERROR; - } - - case OBSERVE_NODE: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - sp<IOMXObserver> observer = - interface_cast<IOMXObserver>(data.readStrongBinder()); - reply->writeInt32(observe_node(node, observer)); + reply->writeInt32(freeBuffer(node, port_index, buffer)); return NO_ERROR; } @@ -601,7 +589,7 @@ status_t BnOMX::onTransact( node_id node = (void*)data.readIntPtr(); buffer_id buffer = (void*)data.readIntPtr(); - fill_buffer(node, buffer); + reply->writeInt32(fillBuffer(node, buffer)); return NO_ERROR; } @@ -617,9 +605,10 @@ status_t BnOMX::onTransact( OMX_U32 flags = data.readInt32(); OMX_TICKS timestamp = data.readInt64(); - empty_buffer( - node, buffer, range_offset, range_length, - flags, timestamp); + reply->writeInt32( + emptyBuffer( + node, buffer, range_offset, range_length, + flags, timestamp)); return NO_ERROR; } @@ -632,7 +621,7 @@ status_t BnOMX::onTransact( const char *parameter_name = data.readCString(); OMX_INDEXTYPE index; - status_t err = get_extension_index(node, parameter_name, &index); + status_t err = getExtensionIndex(node, parameter_name, &index); reply->writeInt32(err); @@ -683,7 +672,7 @@ public: : BpInterface<IOMXObserver>(impl) { } - virtual void on_message(const omx_message &msg) { + virtual void onMessage(const omx_message &msg) { Parcel data, reply; data.writeInterfaceToken(IOMXObserver::getInterfaceDescriptor()); data.write(&msg, sizeof(msg)); @@ -705,7 +694,7 @@ status_t BnOMXObserver::onTransact( data.read(&msg, sizeof(msg)); // XXX Could use readInplace maybe? - on_message(msg); + onMessage(msg); return NO_ERROR; } diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk index f21eb73..fb569da 100644 --- a/media/libmediaplayerservice/Android.mk +++ b/media/libmediaplayerservice/Android.mk @@ -50,7 +50,7 @@ LOCAL_C_INCLUDES := external/tremor/Tremor \ $(JNI_H_INCLUDE) \ $(call include-path-for, graphics corecg) \ $(TOP)/external/opencore/extern_libs_v2/khronos/openmax/include \ - $(TOP)/frameworks/base/media/libstagefright/omx + $(TOP)/frameworks/base/media/libstagefright/include LOCAL_MODULE:= libmediaplayerservice diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 0b75a2b..0a6c365 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -284,8 +284,14 @@ sp<IMediaPlayer> MediaPlayerService::create(pid_t pid, const sp<IMediaPlayerClie return c; } -sp<IOMX> MediaPlayerService::createOMX() { - return new OMX; +sp<IOMX> MediaPlayerService::getOMX() { + Mutex::Autolock autoLock(mLock); + + if (mOMX.get() == NULL) { + mOMX = new OMX; + } + + return mOMX; } status_t MediaPlayerService::AudioCache::dump(int fd, const Vector<String16>& args) const diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 43c4915..b00f5b7 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -185,7 +185,7 @@ public: 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> snoop(); - virtual sp<IOMX> createOMX(); + virtual sp<IOMX> getOMX(); virtual status_t dump(int fd, const Vector<String16>& args); @@ -284,6 +284,7 @@ private: SortedVector< wp<Client> > mClients; SortedVector< wp<MediaRecorderClient> > mMediaRecorderClients; int32_t mNextConnId; + sp<IOMX> mOMX; }; // ---------------------------------------------------------------------------- diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp index 8eabe5d..2cdc351 100644 --- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp +++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp @@ -138,6 +138,12 @@ status_t MetadataRetrieverClient::setDataSource(const char *url) return UNKNOWN_ERROR; } player_type playerType = getPlayerType(url); +#if !defined(NO_OPENCORE) && defined(BUILD_WITH_FULL_STAGEFRIGHT) + if (playerType == STAGEFRIGHT_PLAYER) { + // Stagefright doesn't support metadata in this branch yet. + playerType = PV_PLAYER; + } +#endif LOGV("player type = %d", playerType); sp<MediaMetadataRetrieverBase> p = createRetriever(playerType); if (p == NULL) return NO_INIT; @@ -176,6 +182,12 @@ status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t } player_type playerType = getPlayerType(fd, offset, length); +#if !defined(NO_OPENCORE) && defined(BUILD_WITH_FULL_STAGEFRIGHT) + if (playerType == STAGEFRIGHT_PLAYER) { + // Stagefright doesn't support metadata in this branch yet. + playerType = PV_PLAYER; + } +#endif LOGV("player type = %d", playerType); sp<MediaMetadataRetrieverBase> p = createRetriever(playerType); if (p == NULL) { diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 3c343a3..9f71dae 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -33,7 +33,7 @@ LOCAL_SRC_FILES += \ TimeSource.cpp \ TimedEventQueue.cpp \ AudioPlayer.cpp \ - string.cpp + stagefright_string.cpp endif diff --git a/media/libstagefright/HTTPDataSource.cpp b/media/libstagefright/HTTPDataSource.cpp index 698223b..4dedebd 100644 --- a/media/libstagefright/HTTPDataSource.cpp +++ b/media/libstagefright/HTTPDataSource.cpp @@ -19,7 +19,7 @@ #include <media/stagefright/HTTPDataSource.h> #include <media/stagefright/HTTPStream.h> #include <media/stagefright/MediaDebug.h> -#include <media/stagefright/string.h> +#include <media/stagefright/stagefright_string.h> namespace android { diff --git a/media/libstagefright/OMXClient.cpp b/media/libstagefright/OMXClient.cpp index dba7a2a..9de873e 100644 --- a/media/libstagefright/OMXClient.cpp +++ b/media/libstagefright/OMXClient.cpp @@ -35,7 +35,7 @@ status_t OMXClient::connect() { CHECK(service.get() != NULL); - mOMX = service->createOMX(); + mOMX = service->getOMX(); CHECK(mOMX.get() != NULL); return OK; diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 1a23fb2..ebf1e0c 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -85,12 +85,15 @@ static const CodecInfo kEncoderInfo[] = { #define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__) struct OMXCodecObserver : public BnOMXObserver { - OMXCodecObserver(const wp<OMXCodec> &target) - : mTarget(target) { + OMXCodecObserver() { + } + + void setCodec(const sp<OMXCodec> &target) { + mTarget = target; } // from IOMXObserver - virtual void on_message(const omx_message &msg) { + virtual void onMessage(const omx_message &msg) { sp<OMXCodec> codec = mTarget.promote(); if (codec.get() != NULL) { @@ -177,6 +180,7 @@ sp<OMXCodec> OMXCodec::Create( CHECK(success); const char *componentName = NULL; + sp<OMXCodecObserver> observer = new OMXCodecObserver; IOMX::node_id node = 0; for (int index = 0;; ++index) { if (createEncoder) { @@ -200,7 +204,7 @@ sp<OMXCodec> OMXCodec::Create( LOGV("Attempting to allocate OMX node '%s'", componentName); - status_t err = omx->allocate_node(componentName, &node); + status_t err = omx->allocateNode(componentName, observer, &node); if (err == OK) { LOGI("Successfully allocated OMX node '%s'", componentName); break; @@ -230,7 +234,6 @@ sp<OMXCodec> OMXCodec::Create( } if (!strncmp(componentName, "OMX.qcom.video.decoder.", 23)) { // XXX Required on P....on only. - quirks |= kRequiresAllocateBufferOnInputPorts; quirks |= kRequiresAllocateBufferOnOutputPorts; quirks |= kOutputDimensionsAre16Aligned; } @@ -249,6 +252,8 @@ sp<OMXCodec> OMXCodec::Create( omx, node, quirks, createEncoder, mime, componentName, source); + observer->setCodec(codec); + uint32_t type; const void *data; size_t size; @@ -331,7 +336,9 @@ sp<OMXCodec> OMXCodec::Create( if (!strcmp(componentName, "OMX.TI.Video.Decoder") && (profile != kAVCProfileBaseline || level > 39)) { - // This stream exceeds the decoder's capabilities. + // This stream exceeds the decoder's capabilities. The decoder + // does not handle this gracefully and would clobber the heap + // and wreak havoc instead... LOGE("Profile and/or level exceed the decoder's capabilities."); return NULL; @@ -406,7 +413,7 @@ void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) { InitOMXParams(&def); def.nPortIndex = portIndex; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -415,7 +422,7 @@ void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) { } - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -433,7 +440,7 @@ status_t OMXCodec::setVideoPortFormatType( OMX_U32 index = 0; for (;;) { format.nIndex = index; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamVideoPortFormat, &format, sizeof(format)); @@ -478,8 +485,8 @@ status_t OMXCodec::setVideoPortFormatType( return UNKNOWN_ERROR; } - CODEC_LOGI("found a match."); - status_t err = mOMX->set_parameter( + CODEC_LOGV("found a match."); + status_t err = mOMX->setParameter( mNode, OMX_IndexParamVideoPortFormat, &format, sizeof(format)); @@ -522,7 +529,7 @@ void OMXCodec::setVideoInputFormat( OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -534,7 +541,7 @@ void OMXCodec::setVideoInputFormat( video_def->eCompressionFormat = compressionFormat; video_def->eColorFormat = OMX_COLOR_FormatUnused; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -543,7 +550,7 @@ void OMXCodec::setVideoInputFormat( InitOMXParams(&def); def.nPortIndex = kPortIndexInput; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -557,7 +564,7 @@ void OMXCodec::setVideoInputFormat( video_def->eCompressionFormat = OMX_VIDEO_CodingUnused; video_def->eColorFormat = colorFormat; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -588,7 +595,7 @@ void OMXCodec::setVideoOutputFormat( format.nPortIndex = kPortIndexOutput; format.nIndex = 0; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamVideoPortFormat, &format, sizeof(format)); CHECK_EQ(err, OK); @@ -601,7 +608,7 @@ void OMXCodec::setVideoOutputFormat( || format.eColorFormat == OMX_COLOR_FormatCbYCrY || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar); - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamVideoPortFormat, &format, sizeof(format)); CHECK_EQ(err, OK); @@ -614,7 +621,7 @@ void OMXCodec::setVideoOutputFormat( OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -634,7 +641,7 @@ void OMXCodec::setVideoOutputFormat( video_def->eColorFormat = OMX_COLOR_FormatUnused; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -643,7 +650,7 @@ void OMXCodec::setVideoOutputFormat( InitOMXParams(&def); def.nPortIndex = kPortIndexOutput; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); CHECK_EQ(def.eDomain, OMX_PortDomainVideo); @@ -656,7 +663,7 @@ void OMXCodec::setVideoOutputFormat( video_def->nFrameWidth = width; video_def->nFrameHeight = height; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -684,9 +691,6 @@ OMXCodec::OMXCodec( mPortStatus[kPortIndexInput] = ENABLED; mPortStatus[kPortIndexOutput] = ENABLED; - mObserver = new OMXCodecObserver(this); - mOMX->observe_node(mNode, mObserver); - setComponentRole(); } @@ -744,7 +748,7 @@ void OMXCodec::setComponentRole( roleParams.cRole[OMX_MAX_STRINGNAME_SIZE - 1] = '\0'; - status_t err = omx->set_parameter( + status_t err = omx->setParameter( node, OMX_IndexParamStandardComponentRole, &roleParams, sizeof(roleParams)); @@ -761,10 +765,7 @@ void OMXCodec::setComponentRole() { OMXCodec::~OMXCodec() { CHECK(mState == LOADED || mState == ERROR); - status_t err = mOMX->observe_node(mNode, NULL); - CHECK_EQ(err, OK); - - err = mOMX->free_node(mNode); + status_t err = mOMX->freeNode(mNode); CHECK_EQ(err, OK); mNode = NULL; @@ -786,7 +787,7 @@ status_t OMXCodec::init() { status_t err; if (!(mQuirks & kRequiresLoadedToIdleAfterAllocation)) { - err = mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle); + err = mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle); CHECK_EQ(err, OK); setState(LOADED_TO_IDLE); } @@ -795,7 +796,7 @@ status_t OMXCodec::init() { CHECK_EQ(err, OK); if (mQuirks & kRequiresLoadedToIdleAfterAllocation) { - err = mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle); + err = mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle); CHECK_EQ(err, OK); setState(LOADED_TO_IDLE); @@ -832,7 +833,7 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { InitOMXParams(&def); def.nPortIndex = portIndex; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); if (err != OK) { @@ -849,14 +850,14 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { IOMX::buffer_id buffer; if (portIndex == kPortIndexInput && (mQuirks & kRequiresAllocateBufferOnInputPorts)) { - err = mOMX->allocate_buffer_with_backup( + err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); } else if (portIndex == kPortIndexOutput && (mQuirks & kRequiresAllocateBufferOnOutputPorts)) { - err = mOMX->allocate_buffer_with_backup( + err = mOMX->allocateBufferWithBackup( mNode, portIndex, mem, &buffer); } else { - err = mOMX->use_buffer(mNode, portIndex, mem, &buffer); + err = mOMX->useBuffer(mNode, portIndex, mem, &buffer); } if (err != OK) { @@ -923,7 +924,7 @@ void OMXCodec::on_message(const omx_message &msg) { CODEC_LOGV("Port is disabled, freeing buffer %p", buffer); status_t err = - mOMX->free_buffer(mNode, kPortIndexInput, buffer); + mOMX->freeBuffer(mNode, kPortIndexInput, buffer); CHECK_EQ(err, OK); buffers->removeAt(i); @@ -969,7 +970,7 @@ void OMXCodec::on_message(const omx_message &msg) { CODEC_LOGV("Port is disabled, freeing buffer %p", buffer); status_t err = - mOMX->free_buffer(mNode, kPortIndexOutput, buffer); + mOMX->freeBuffer(mNode, kPortIndexOutput, buffer); CHECK_EQ(err, OK); buffers->removeAt(i); @@ -1139,7 +1140,7 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) { mPortStatus[kPortIndexOutput] = SHUTTING_DOWN; status_t err = - mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle); + mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle); CHECK_EQ(err, OK); } } else { @@ -1179,7 +1180,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { { CODEC_LOGV("Now Idle."); if (mState == LOADED_TO_IDLE) { - status_t err = mOMX->send_command( + status_t err = mOMX->sendCommand( mNode, OMX_CommandStateSet, OMX_StateExecuting); CHECK_EQ(err, OK); @@ -1196,7 +1197,7 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) { countBuffersWeOwn(mPortBuffers[kPortIndexOutput]), mPortBuffers[kPortIndexOutput].size()); - status_t err = mOMX->send_command( + status_t err = mOMX->sendCommand( mNode, OMX_CommandStateSet, OMX_StateLoaded); CHECK_EQ(err, OK); @@ -1279,7 +1280,7 @@ status_t OMXCodec::freeBuffersOnPort( CODEC_LOGV("freeing buffer %p on port %ld", info->mBuffer, portIndex); status_t err = - mOMX->free_buffer(mNode, portIndex, info->mBuffer); + mOMX->freeBuffer(mNode, portIndex, info->mBuffer); if (err != OK) { stickyErr = err; @@ -1339,7 +1340,7 @@ bool OMXCodec::flushPortAsync(OMX_U32 portIndex) { } status_t err = - mOMX->send_command(mNode, OMX_CommandFlush, portIndex); + mOMX->sendCommand(mNode, OMX_CommandFlush, portIndex); CHECK_EQ(err, OK); return true; @@ -1352,7 +1353,7 @@ void OMXCodec::disablePortAsync(OMX_U32 portIndex) { mPortStatus[portIndex] = DISABLING; status_t err = - mOMX->send_command(mNode, OMX_CommandPortDisable, portIndex); + mOMX->sendCommand(mNode, OMX_CommandPortDisable, portIndex); CHECK_EQ(err, OK); freeBuffersOnPort(portIndex, true); @@ -1365,7 +1366,7 @@ void OMXCodec::enablePortAsync(OMX_U32 portIndex) { mPortStatus[portIndex] = ENABLING; status_t err = - mOMX->send_command(mNode, OMX_CommandPortEnable, portIndex); + mOMX->sendCommand(mNode, OMX_CommandPortEnable, portIndex); CHECK_EQ(err, OK); } @@ -1417,10 +1418,11 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { memcpy(info->mMem->pointer(), specific->mData, specific->mSize); } - mOMX->empty_buffer( + status_t err = mOMX->emptyBuffer( mNode, info->mBuffer, 0, size, OMX_BUFFERFLAG_ENDOFFRAME | OMX_BUFFERFLAG_CODECCONFIG, 0); + CHECK_EQ(err, OK); info->mOwnedByComponent = true; @@ -1473,16 +1475,21 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { } } - mOMX->empty_buffer( - mNode, info->mBuffer, 0, srcLength, - flags, timestamp); - - info->mOwnedByComponent = true; - if (srcBuffer != NULL) { srcBuffer->release(); srcBuffer = NULL; } + + err = mOMX->emptyBuffer( + mNode, info->mBuffer, 0, srcLength, + flags, timestamp); + + if (err != OK) { + setState(ERROR); + return; + } + + info->mOwnedByComponent = true; } void OMXCodec::fillOutputBuffer(BufferInfo *info) { @@ -1495,7 +1502,8 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) { } CODEC_LOGV("Calling fill_buffer on buffer %p", info->mBuffer); - mOMX->fill_buffer(mNode, info->mBuffer); + status_t err = mOMX->fillBuffer(mNode, info->mBuffer); + CHECK_EQ(err, OK); info->mOwnedByComponent = true; } @@ -1539,7 +1547,7 @@ void OMXCodec::setRawAudioFormat( InitOMXParams(&pcmParams); pcmParams.nPortIndex = portIndex; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamAudioPcm, &pcmParams, sizeof(pcmParams)); CHECK_EQ(err, OK); @@ -1560,7 +1568,7 @@ void OMXCodec::setRawAudioFormat( pcmParams.eChannelMapping[1] = OMX_AUDIO_ChannelRF; } - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamAudioPcm, &pcmParams, sizeof(pcmParams)); CHECK_EQ(err, OK); @@ -1573,14 +1581,14 @@ void OMXCodec::setAMRFormat() { def.nPortIndex = kPortIndexInput; status_t err = - mOMX->get_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); + mOMX->getParameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); CHECK_EQ(err, OK); def.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF; def.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; - err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); + err = mOMX->setParameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -1604,14 +1612,14 @@ void OMXCodec::setAMRWBFormat() { def.nPortIndex = kPortIndexInput; status_t err = - mOMX->get_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); + mOMX->getParameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); CHECK_EQ(err, OK); def.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF; def.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0; - err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); + err = mOMX->setParameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -1636,7 +1644,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) { InitOMXParams(&profile); profile.nPortIndex = kPortIndexInput; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); CHECK_EQ(err, OK); @@ -1644,7 +1652,7 @@ void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) { profile.nSampleRate = sampleRate; profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); CHECK_EQ(err, OK); } @@ -1668,7 +1676,7 @@ void OMXCodec::setImageOutputFormat( InitOMXParams(&def); def.nPortIndex = kPortIndexOutput; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -1717,7 +1725,7 @@ void OMXCodec::setImageOutputFormat( def.nBufferCountActual = def.nBufferCountMin; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -1728,7 +1736,7 @@ void OMXCodec::setJPEGInputFormat( InitOMXParams(&def); def.nPortIndex = kPortIndexInput; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -1742,7 +1750,7 @@ void OMXCodec::setJPEGInputFormat( def.nBufferSize = compressedSize; def.nBufferCountActual = def.nBufferCountMin; - err = mOMX->set_parameter( + err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); } @@ -1832,7 +1840,7 @@ status_t OMXCodec::stop() { mPortStatus[kPortIndexOutput] = SHUTTING_DOWN; status_t err = - mOMX->send_command(mNode, OMX_CommandStateSet, OMX_StateIdle); + mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle); CHECK_EQ(err, OK); } @@ -1869,9 +1877,24 @@ status_t OMXCodec::read( return UNKNOWN_ERROR; } + bool seeking = false; + int64_t seekTimeUs; + if (options && options->getSeekTo(&seekTimeUs)) { + seeking = true; + } + if (mInitialBufferSubmit) { mInitialBufferSubmit = false; + if (seeking) { + CHECK(seekTimeUs >= 0); + mSeekTimeUs = seekTimeUs; + + // There's no reason to trigger the code below, there's + // nothing to flush yet. + seeking = false; + } + drainInputBuffers(); if (mState == EXECUTING) { @@ -1881,8 +1904,7 @@ status_t OMXCodec::read( } } - int64_t seekTimeUs; - if (options && options->getSeekTo(&seekTimeUs)) { + if (seeking) { CODEC_LOGV("seeking to %lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6); mSignalledEOS = false; @@ -2164,7 +2186,7 @@ void OMXCodec::dumpPortStatus(OMX_U32 portIndex) { InitOMXParams(&def); def.nPortIndex = portIndex; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -2230,7 +2252,7 @@ void OMXCodec::dumpPortStatus(OMX_U32 portIndex) { InitOMXParams(¶ms); params.nPortIndex = portIndex; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamAudioPcm, ¶ms, sizeof(params)); CHECK_EQ(err, OK); @@ -2249,7 +2271,7 @@ void OMXCodec::dumpPortStatus(OMX_U32 portIndex) { InitOMXParams(&amr); amr.nPortIndex = portIndex; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamAudioAmr, &amr, sizeof(amr)); CHECK_EQ(err, OK); @@ -2281,7 +2303,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { InitOMXParams(&def); def.nPortIndex = kPortIndexOutput; - status_t err = mOMX->get_parameter( + status_t err = mOMX->getParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); @@ -2307,7 +2329,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { InitOMXParams(¶ms); params.nPortIndex = kPortIndexOutput; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamAudioPcm, ¶ms, sizeof(params)); CHECK_EQ(err, OK); @@ -2339,7 +2361,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { InitOMXParams(&amr); amr.nPortIndex = kPortIndexOutput; - err = mOMX->get_parameter( + err = mOMX->getParameter( mNode, OMX_IndexParamAudioAmr, &amr, sizeof(amr)); CHECK_EQ(err, OK); @@ -2436,8 +2458,9 @@ status_t QueryCodecs( return OK; } + sp<OMXCodecObserver> observer = new OMXCodecObserver; IOMX::node_id node; - status_t err = omx->allocate_node(componentName, &node); + status_t err = omx->allocateNode(componentName, observer, &node); if (err != OK) { continue; @@ -2455,7 +2478,7 @@ status_t QueryCodecs( param.nPortIndex = queryDecoders ? 0 : 1; for (param.nProfileIndex = 0;; ++param.nProfileIndex) { - err = omx->get_parameter( + err = omx->getParameter( node, OMX_IndexParamVideoProfileLevelQuerySupported, ¶m, sizeof(param)); @@ -2470,7 +2493,7 @@ status_t QueryCodecs( caps->mProfileLevels.push(profileLevel); } - CHECK_EQ(omx->free_node(node), OK); + CHECK_EQ(omx->freeNode(node), OK); } } diff --git a/media/libstagefright/ShoutcastSource.cpp b/media/libstagefright/ShoutcastSource.cpp index 8e8f4fa..346b5aa 100644 --- a/media/libstagefright/ShoutcastSource.cpp +++ b/media/libstagefright/ShoutcastSource.cpp @@ -23,7 +23,7 @@ #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MetaData.h> #include <media/stagefright/ShoutcastSource.h> -#include <media/stagefright/string.h> +#include <media/stagefright/stagefright_string.h> namespace android { diff --git a/media/libstagefright/omx/OMX.h b/media/libstagefright/include/OMX.h index 6325f79..d0bd61e 100644 --- a/media/libstagefright/omx/OMX.h +++ b/media/libstagefright/include/OMX.h @@ -19,66 +19,67 @@ #include <media/IOMX.h> #include <utils/threads.h> +#include <utils/KeyedVector.h> namespace android { -class NodeMeta; +class OMXNodeInstance; -class OMX : public BnOMX { +class OMX : public BnOMX, + public IBinder::DeathRecipient { public: OMX(); - virtual status_t list_nodes(List<String8> *list); + virtual status_t listNodes(List<String8> *list); - virtual status_t allocate_node(const char *name, node_id *node); - virtual status_t free_node(node_id node); + virtual status_t allocateNode( + const char *name, const sp<IOMXObserver> &observer, node_id *node); - virtual status_t send_command( + virtual status_t freeNode(node_id node); + + virtual status_t sendCommand( node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param); - virtual status_t get_parameter( + virtual status_t getParameter( node_id node, OMX_INDEXTYPE index, void *params, size_t size); - virtual status_t set_parameter( + virtual status_t setParameter( node_id node, OMX_INDEXTYPE index, const void *params, size_t size); - virtual status_t get_config( + virtual status_t getConfig( node_id node, OMX_INDEXTYPE index, void *params, size_t size); - virtual status_t set_config( + virtual status_t setConfig( node_id node, OMX_INDEXTYPE index, const void *params, size_t size); - virtual status_t use_buffer( + virtual status_t useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer); - virtual status_t allocate_buffer( + virtual status_t allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer); - virtual status_t allocate_buffer_with_backup( + virtual status_t allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer); - virtual status_t free_buffer( + virtual status_t freeBuffer( node_id node, OMX_U32 port_index, buffer_id buffer); - virtual status_t observe_node( - node_id node, const sp<IOMXObserver> &observer); - - virtual void fill_buffer(node_id node, buffer_id buffer); + virtual status_t fillBuffer(node_id node, buffer_id buffer); - virtual void empty_buffer( + virtual status_t emptyBuffer( node_id node, buffer_id buffer, OMX_U32 range_offset, OMX_U32 range_length, OMX_U32 flags, OMX_TICKS timestamp); - virtual status_t get_extension_index( + virtual status_t getExtensionIndex( node_id node, const char *parameter_name, OMX_INDEXTYPE *index); @@ -90,44 +91,38 @@ public: size_t encodedWidth, size_t encodedHeight, size_t displayWidth, size_t displayHeight); -private: - static OMX_CALLBACKTYPE kCallbacks; - - Mutex mLock; - - struct CallbackDispatcher; - sp<CallbackDispatcher> mDispatcher; - - static OMX_ERRORTYPE OnEvent( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - - static OMX_ERRORTYPE OnEmptyBufferDone( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - static OMX_ERRORTYPE OnFillBufferDone( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); + virtual void binderDied(const wp<IBinder> &the_late_who); OMX_ERRORTYPE OnEvent( - NodeMeta *meta, + node_id node, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData); - + OMX_ERRORTYPE OnEmptyBufferDone( - NodeMeta *meta, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); + node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); OMX_ERRORTYPE OnFillBufferDone( - NodeMeta *meta, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); + node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); + + void invalidateNodeID(node_id node); + +private: + Mutex mLock; + + struct CallbackDispatcher; + sp<CallbackDispatcher> mDispatcher; + + int32_t mNodeCounter; + + KeyedVector<wp<IBinder>, OMXNodeInstance *> mLiveNodes; + KeyedVector<node_id, OMXNodeInstance *> mNodeIDToInstance; + + node_id makeNodeID(OMXNodeInstance *instance); + OMXNodeInstance *findInstance(node_id node); + + void invalidateNodeID_l(node_id node); OMX(const OMX &); OMX &operator=(const OMX &); diff --git a/media/libstagefright/include/OMXNodeInstance.h b/media/libstagefright/include/OMXNodeInstance.h new file mode 100644 index 0000000..09a8816 --- /dev/null +++ b/media/libstagefright/include/OMXNodeInstance.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2009 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 OMX_NODE_INSTANCE_H_ + +#define OMX_NODE_INSTANCE_H_ + +#include "OMX.h" + +#include <utils/RefBase.h> +#include <utils/threads.h> + +namespace android { + +class IOMXObserver; + +struct OMXNodeInstance { + OMXNodeInstance( + OMX *owner, const sp<IOMXObserver> &observer); + + void setHandle(OMX::node_id node_id, OMX_HANDLETYPE handle); + + OMX *owner(); + sp<IOMXObserver> observer(); + OMX::node_id nodeID(); + + status_t freeNode(); + + status_t sendCommand(OMX_COMMANDTYPE cmd, OMX_S32 param); + status_t getParameter(OMX_INDEXTYPE index, void *params, size_t size); + + status_t setParameter( + OMX_INDEXTYPE index, const void *params, size_t size); + + status_t getConfig(OMX_INDEXTYPE index, void *params, size_t size); + status_t setConfig(OMX_INDEXTYPE index, const void *params, size_t size); + + status_t useBuffer( + OMX_U32 portIndex, const sp<IMemory> ¶ms, + OMX::buffer_id *buffer); + + status_t allocateBuffer( + OMX_U32 portIndex, size_t size, OMX::buffer_id *buffer); + + status_t allocateBufferWithBackup( + OMX_U32 portIndex, const sp<IMemory> ¶ms, + OMX::buffer_id *buffer); + + status_t freeBuffer(OMX_U32 portIndex, OMX::buffer_id buffer); + + status_t fillBuffer(OMX::buffer_id buffer); + + status_t emptyBuffer( + OMX::buffer_id buffer, + OMX_U32 rangeOffset, OMX_U32 rangeLength, + OMX_U32 flags, OMX_TICKS timestamp); + + status_t getExtensionIndex( + const char *parameterName, OMX_INDEXTYPE *index); + + void onMessage(const omx_message &msg); + void onObserverDied(); + void onGetHandleFailed(); + + static OMX_CALLBACKTYPE kCallbacks; + +private: + Mutex mLock; + + OMX *mOwner; + OMX::node_id mNodeID; + OMX_HANDLETYPE mHandle; + sp<IOMXObserver> mObserver; + + struct ActiveBuffer { + OMX_U32 mPortIndex; + OMX::buffer_id mID; + }; + Vector<ActiveBuffer> mActiveBuffers; + + ~OMXNodeInstance(); + + void addActiveBuffer(OMX_U32 portIndex, OMX::buffer_id id); + void removeActiveBuffer(OMX_U32 portIndex, OMX::buffer_id id); + void freeActiveBuffers(); + + static OMX_ERRORTYPE OnEvent( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_EVENTTYPE eEvent, + OMX_IN OMX_U32 nData1, + OMX_IN OMX_U32 nData2, + OMX_IN OMX_PTR pEventData); + + static OMX_ERRORTYPE OnEmptyBufferDone( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); + + static OMX_ERRORTYPE OnFillBufferDone( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); + + OMXNodeInstance(const OMXNodeInstance &); + OMXNodeInstance &operator=(const OMXNodeInstance &); +}; + +} // namespace android + +#endif // OMX_NODE_INSTANCE_H_ + diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk index 4cadccd..20fb4f3 100644 --- a/media/libstagefright/omx/Android.mk +++ b/media/libstagefright/omx/Android.mk @@ -11,6 +11,7 @@ LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) LOCAL_SRC_FILES:= \ OMX.cpp \ + OMXNodeInstance.cpp \ QComHardwareRenderer.cpp \ SoftwareRenderer.cpp \ TIHardwareRenderer.cpp diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp index 8b83dd6..9ac0d44 100644 --- a/media/libstagefright/omx/OMX.cpp +++ b/media/libstagefright/omx/OMX.cpp @@ -18,13 +18,13 @@ #define LOG_TAG "OMX" #include <utils/Log.h> -#include <sys/socket.h> - -#include "OMX.h" +#include "../include/OMX.h" #include "OMXRenderer.h" #include "pv_omxcore.h" +#include "../include/OMXNodeInstance.h" + #include <binder/IMemory.h> #include <media/stagefright/MediaDebug.h> #include <media/stagefright/QComHardwareRenderer.h> @@ -36,47 +36,10 @@ namespace android { -class NodeMeta { -public: - NodeMeta(OMX *owner) - : mOwner(owner), - mHandle(NULL) { - } - - OMX *owner() const { - return mOwner; - } - - void setHandle(OMX_HANDLETYPE handle) { - CHECK_EQ(mHandle, NULL); - mHandle = handle; - } - - OMX_HANDLETYPE handle() const { - return mHandle; - } - - void setObserver(const sp<IOMXObserver> &observer) { - mObserver = observer; - } - - sp<IOMXObserver> observer() { - return mObserver; - } - -private: - OMX *mOwner; - OMX_HANDLETYPE mHandle; - sp<IOMXObserver> mObserver; - - NodeMeta(const NodeMeta &); - NodeMeta &operator=(const NodeMeta &); -}; - //////////////////////////////////////////////////////////////////////////////// struct OMX::CallbackDispatcher : public RefBase { - CallbackDispatcher(); + CallbackDispatcher(OMX *owner); void post(const omx_message &msg); @@ -85,6 +48,8 @@ protected: private: Mutex mLock; + + OMX *mOwner; bool mDone; Condition mQueueChanged; List<omx_message> mQueue; @@ -100,8 +65,9 @@ private: CallbackDispatcher &operator=(const CallbackDispatcher &); }; -OMX::CallbackDispatcher::CallbackDispatcher() - : mDone(false) { +OMX::CallbackDispatcher::CallbackDispatcher(OMX *owner) + : mOwner(owner), + mDone(false) { pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); @@ -130,12 +96,12 @@ void OMX::CallbackDispatcher::post(const omx_message &msg) { } void OMX::CallbackDispatcher::dispatch(const omx_message &msg) { - NodeMeta *meta = static_cast<NodeMeta *>(msg.node); - - sp<IOMXObserver> observer = meta->observer(); - if (observer.get() != NULL) { - observer->on_message(msg); + OMXNodeInstance *instance = mOwner->findInstance(msg.node); + if (instance == NULL) { + LOGV("Would have dispatched a message to a node that's already gone."); + return; } + instance->onMessage(msg); } // static @@ -213,46 +179,30 @@ private: BufferMeta &operator=(const BufferMeta &); }; -// static -OMX_CALLBACKTYPE OMX::kCallbacks = { - &OnEvent, &OnEmptyBufferDone, &OnFillBufferDone -}; - -// static -OMX_ERRORTYPE OMX::OnEvent( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData) { - NodeMeta *meta = static_cast<NodeMeta *>(pAppData); - return meta->owner()->OnEvent(meta, eEvent, nData1, nData2, pEventData); +OMX::OMX() + : mDispatcher(new CallbackDispatcher(this)), + mNodeCounter(0) { } -// static -OMX_ERRORTYPE OMX::OnEmptyBufferDone( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { - NodeMeta *meta = static_cast<NodeMeta *>(pAppData); - return meta->owner()->OnEmptyBufferDone(meta, pBuffer); -} +void OMX::binderDied(const wp<IBinder> &the_late_who) { + OMXNodeInstance *instance; -// static -OMX_ERRORTYPE OMX::OnFillBufferDone( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { - NodeMeta *meta = static_cast<NodeMeta *>(pAppData); - return meta->owner()->OnFillBufferDone(meta, pBuffer); -} + { + Mutex::Autolock autoLock(mLock); -OMX::OMX() - : mDispatcher(new CallbackDispatcher) { + ssize_t index = mLiveNodes.indexOfKey(the_late_who); + CHECK(index >= 0); + + instance = mLiveNodes.editValueAt(index); + mLiveNodes.removeItemsAt(index); + + invalidateNodeID_l(instance->nodeID()); + } + + instance->onObserverDied(); } -status_t OMX::list_nodes(List<String8> *list) { +status_t OMX::listNodes(List<String8> *list) { OMX_MasterInit(); // XXX Put this somewhere else. list->clear(); @@ -269,204 +219,132 @@ status_t OMX::list_nodes(List<String8> *list) { return OK; } -status_t OMX::allocate_node(const char *name, node_id *node) { +status_t OMX::allocateNode( + const char *name, const sp<IOMXObserver> &observer, node_id *node) { Mutex::Autolock autoLock(mLock); *node = 0; OMX_MasterInit(); // XXX Put this somewhere else. - NodeMeta *meta = new NodeMeta(this); + OMXNodeInstance *instance = new OMXNodeInstance(this, observer); OMX_HANDLETYPE handle; OMX_ERRORTYPE err = OMX_MasterGetHandle( - &handle, const_cast<char *>(name), meta, &kCallbacks); + &handle, const_cast<char *>(name), instance, + &OMXNodeInstance::kCallbacks); if (err != OMX_ErrorNone) { LOGE("FAILED to allocate omx component '%s'", name); - delete meta; - meta = NULL; + instance->onGetHandleFailed(); return UNKNOWN_ERROR; } - meta->setHandle(handle); + *node = makeNodeID(instance); - *node = meta; + instance->setHandle(*node, handle); + + mLiveNodes.add(observer->asBinder(), instance); + observer->asBinder()->linkToDeath(this); return OK; } -status_t OMX::free_node(node_id node) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - - OMX_ERRORTYPE err = OMX_MasterFreeHandle(meta->handle()); +status_t OMX::freeNode(node_id node) { + OMXNodeInstance *instance = findInstance(node); - delete meta; - meta = NULL; + ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder()); + CHECK(index >= 0); + mLiveNodes.removeItemsAt(index); + instance->observer()->asBinder()->unlinkToDeath(this); - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return instance->freeNode(); } -status_t OMX::send_command( +status_t OMX::sendCommand( node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = OMX_SendCommand(meta->handle(), cmd, param, NULL); - - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return findInstance(node)->sendCommand(cmd, param); } -status_t OMX::get_parameter( +status_t OMX::getParameter( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = OMX_GetParameter(meta->handle(), index, params); - - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return findInstance(node)->getParameter( + index, params, size); } -status_t OMX::set_parameter( +status_t OMX::setParameter( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_SetParameter(meta->handle(), index, const_cast<void *>(params)); - - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return findInstance(node)->setParameter( + index, params, size); } -status_t OMX::get_config( +status_t OMX::getConfig( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = OMX_GetConfig(meta->handle(), index, params); - - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return findInstance(node)->getConfig( + index, params, size); } -status_t OMX::set_config( +status_t OMX::setConfig( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { - Mutex::Autolock autoLock(mLock); - - NodeMeta *meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_SetConfig(meta->handle(), index, const_cast<void *>(params)); - - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; + return findInstance(node)->setConfig( + index, params, size); } -status_t OMX::use_buffer( +status_t OMX::useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) { - Mutex::Autolock autoLock(mLock); - - BufferMeta *buffer_meta = new BufferMeta(this, params); - - OMX_BUFFERHEADERTYPE *header; - - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_UseBuffer(node_meta->handle(), &header, port_index, buffer_meta, - params->size(), static_cast<OMX_U8 *>(params->pointer())); - - if (err != OMX_ErrorNone) { - LOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err); - - delete buffer_meta; - buffer_meta = NULL; - - *buffer = 0; - return UNKNOWN_ERROR; - } - - *buffer = header; - - return OK; + return findInstance(node)->useBuffer( + port_index, params, buffer); } -status_t OMX::allocate_buffer( +status_t OMX::allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer) { - Mutex::Autolock autoLock(mLock); - - BufferMeta *buffer_meta = new BufferMeta(this, size); - - OMX_BUFFERHEADERTYPE *header; - - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_AllocateBuffer(node_meta->handle(), &header, port_index, - buffer_meta, size); - - if (err != OMX_ErrorNone) { - delete buffer_meta; - buffer_meta = NULL; - - *buffer = 0; - return UNKNOWN_ERROR; - } - - *buffer = header; - - return OK; + return findInstance(node)->allocateBuffer( + port_index, size, buffer); } -status_t OMX::allocate_buffer_with_backup( +status_t OMX::allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, buffer_id *buffer) { - Mutex::Autolock autoLock(mLock); - - BufferMeta *buffer_meta = new BufferMeta(this, params, true); - - OMX_BUFFERHEADERTYPE *header; - - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_AllocateBuffer( - node_meta->handle(), &header, port_index, buffer_meta, - params->size()); - - if (err != OMX_ErrorNone) { - delete buffer_meta; - buffer_meta = NULL; - - *buffer = 0; - return UNKNOWN_ERROR; - } - - *buffer = header; - - return OK; + return findInstance(node)->allocateBufferWithBackup( + port_index, params, buffer); } -status_t OMX::free_buffer(node_id node, OMX_U32 port_index, buffer_id buffer) { - OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; - BufferMeta *buffer_meta = static_cast<BufferMeta *>(header->pAppPrivate); +status_t OMX::freeBuffer(node_id node, OMX_U32 port_index, buffer_id buffer) { + return findInstance(node)->freeBuffer( + port_index, buffer); +} - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - OMX_ERRORTYPE err = - OMX_FreeBuffer(node_meta->handle(), port_index, header); +status_t OMX::fillBuffer(node_id node, buffer_id buffer) { + return findInstance(node)->fillBuffer(buffer); +} - delete buffer_meta; - buffer_meta = NULL; +status_t OMX::emptyBuffer( + node_id node, + buffer_id buffer, + OMX_U32 range_offset, OMX_U32 range_length, + OMX_U32 flags, OMX_TICKS timestamp) { + return findInstance(node)->emptyBuffer( + buffer, range_offset, range_length, flags, timestamp); +} - return (err != OMX_ErrorNone) ? UNKNOWN_ERROR : OK; +status_t OMX::getExtensionIndex( + node_id node, + const char *parameter_name, + OMX_INDEXTYPE *index) { + return findInstance(node)->getExtensionIndex( + parameter_name, index); } OMX_ERRORTYPE OMX::OnEvent( - NodeMeta *meta, + node_id node, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, @@ -475,7 +353,7 @@ OMX_ERRORTYPE OMX::OnEvent( omx_message msg; msg.type = omx_message::EVENT; - msg.node = meta; + msg.node = node; msg.u.event_data.event = eEvent; msg.u.event_data.data1 = nData1; msg.u.event_data.data2 = nData2; @@ -484,14 +362,14 @@ OMX_ERRORTYPE OMX::OnEvent( return OMX_ErrorNone; } - + OMX_ERRORTYPE OMX::OnEmptyBufferDone( - NodeMeta *meta, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { + node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { LOGV("OnEmptyBufferDone buffer=%p", pBuffer); omx_message msg; msg.type = omx_message::EMPTY_BUFFER_DONE; - msg.node = meta; + msg.node = node; msg.u.buffer_data.buffer = pBuffer; mDispatcher->post(msg); @@ -500,14 +378,12 @@ OMX_ERRORTYPE OMX::OnEmptyBufferDone( } OMX_ERRORTYPE OMX::OnFillBufferDone( - NodeMeta *meta, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { + node_id node, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { LOGV("OnFillBufferDone buffer=%p", pBuffer); - BufferMeta *buffer_meta = static_cast<BufferMeta *>(pBuffer->pAppPrivate); - buffer_meta->CopyFromOMX(pBuffer); omx_message msg; msg.type = omx_message::FILL_BUFFER_DONE; - msg.node = meta; + msg.node = node; msg.u.extended_buffer_data.buffer = pBuffer; msg.u.extended_buffer_data.range_offset = pBuffer->nOffset; msg.u.extended_buffer_data.range_length = pBuffer->nFilledLen; @@ -520,62 +396,31 @@ OMX_ERRORTYPE OMX::OnFillBufferDone( return OMX_ErrorNone; } -status_t OMX::observe_node( - node_id node, const sp<IOMXObserver> &observer) { - NodeMeta *node_meta = static_cast<NodeMeta *>(node); +OMX::node_id OMX::makeNodeID(OMXNodeInstance *instance) { + // mLock is already held. - node_meta->setObserver(observer); + node_id node = (node_id)++mNodeCounter; + mNodeIDToInstance.add(node, instance); - return OK; + return node; } -void OMX::fill_buffer(node_id node, buffer_id buffer) { - OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; - header->nFilledLen = 0; - header->nOffset = 0; - header->nFlags = 0; +OMXNodeInstance *OMX::findInstance(node_id node) { + Mutex::Autolock autoLock(mLock); - NodeMeta *node_meta = static_cast<NodeMeta *>(node); + ssize_t index = mNodeIDToInstance.indexOfKey(node); - OMX_ERRORTYPE err = - OMX_FillThisBuffer(node_meta->handle(), header); - CHECK_EQ(err, OMX_ErrorNone); + return index < 0 ? NULL : mNodeIDToInstance.valueAt(index); } -void OMX::empty_buffer( - node_id node, - buffer_id buffer, - OMX_U32 range_offset, OMX_U32 range_length, - OMX_U32 flags, OMX_TICKS timestamp) { - OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; - header->nFilledLen = range_length; - header->nOffset = range_offset; - header->nFlags = flags; - header->nTimeStamp = timestamp; - - BufferMeta *buffer_meta = - static_cast<BufferMeta *>(header->pAppPrivate); - buffer_meta->CopyToOMX(header); - - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - - OMX_ERRORTYPE err = - OMX_EmptyThisBuffer(node_meta->handle(), header); - CHECK_EQ(err, OMX_ErrorNone); +void OMX::invalidateNodeID(node_id node) { + Mutex::Autolock autoLock(mLock); + invalidateNodeID_l(node); } -status_t OMX::get_extension_index( - node_id node, - const char *parameter_name, - OMX_INDEXTYPE *index) { - NodeMeta *node_meta = static_cast<NodeMeta *>(node); - - OMX_ERRORTYPE err = - OMX_GetExtensionIndex( - node_meta->handle(), - const_cast<char *>(parameter_name), index); - - return err == OMX_ErrorNone ? OK : UNKNOWN_ERROR; +void OMX::invalidateNodeID_l(node_id node) { + // mLock is held. + mNodeIDToInstance.removeItem(node); } //////////////////////////////////////////////////////////////////////////////// diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp new file mode 100644 index 0000000..8218918 --- /dev/null +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -0,0 +1,461 @@ +/* + * Copyright (C) 2009 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. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "OMXNodeInstance" +#include <utils/Log.h> + +#include "../include/OMXNodeInstance.h" + +#include "pv_omxcore.h" + +#include <binder/IMemory.h> +#include <media/stagefright/MediaDebug.h> + +namespace android { + +struct BufferMeta { + BufferMeta(const sp<IMemory> &mem, bool is_backup = false) + : mMem(mem), + mIsBackup(is_backup) { + } + + BufferMeta(size_t size) + : mSize(size), + mIsBackup(false) { + } + + void CopyFromOMX(const OMX_BUFFERHEADERTYPE *header) { + if (!mIsBackup) { + return; + } + + memcpy((OMX_U8 *)mMem->pointer() + header->nOffset, + header->pBuffer + header->nOffset, + header->nFilledLen); + } + + void CopyToOMX(const OMX_BUFFERHEADERTYPE *header) { + if (!mIsBackup) { + return; + } + + memcpy(header->pBuffer + header->nOffset, + (const OMX_U8 *)mMem->pointer() + header->nOffset, + header->nFilledLen); + } + +private: + sp<IMemory> mMem; + size_t mSize; + bool mIsBackup; + + BufferMeta(const BufferMeta &); + BufferMeta &operator=(const BufferMeta &); +}; + +// static +OMX_CALLBACKTYPE OMXNodeInstance::kCallbacks = { + &OnEvent, &OnEmptyBufferDone, &OnFillBufferDone +}; + +OMXNodeInstance::OMXNodeInstance( + OMX *owner, const sp<IOMXObserver> &observer) + : mOwner(owner), + mNodeID(NULL), + mHandle(NULL), + mObserver(observer) { +} + +OMXNodeInstance::~OMXNodeInstance() { + CHECK_EQ(mHandle, NULL); +} + +void OMXNodeInstance::setHandle(OMX::node_id node_id, OMX_HANDLETYPE handle) { + CHECK_EQ(mHandle, NULL); + mNodeID = node_id; + mHandle = handle; +} + +OMX *OMXNodeInstance::owner() { + return mOwner; +} + +sp<IOMXObserver> OMXNodeInstance::observer() { + return mObserver; +} + +OMX::node_id OMXNodeInstance::nodeID() { + return mNodeID; +} + +static status_t StatusFromOMXError(OMX_ERRORTYPE err) { + return (err == OMX_ErrorNone) ? OK : UNKNOWN_ERROR; +} + +status_t OMXNodeInstance::freeNode() { + // Transition the node from its current state all the way down + // to "Loaded". + // This ensures that all active buffers are properly freed even + // for components that don't do this themselves on a call to + // "FreeHandle". + + OMX_STATETYPE state; + CHECK_EQ(OMX_GetState(mHandle, &state), OMX_ErrorNone); + switch (state) { + case OMX_StateExecuting: + { + LOGV("forcing Executing->Idle"); + sendCommand(OMX_CommandStateSet, OMX_StateIdle); + OMX_ERRORTYPE err; + while ((err = OMX_GetState(mHandle, &state)) == OMX_ErrorNone + && state != OMX_StateIdle) { + usleep(100000); + } + CHECK_EQ(err, OMX_ErrorNone); + + // fall through + } + + case OMX_StateIdle: + { + LOGV("forcing Idle->Loaded"); + sendCommand(OMX_CommandStateSet, OMX_StateLoaded); + + freeActiveBuffers(); + + OMX_ERRORTYPE err; + while ((err = OMX_GetState(mHandle, &state)) == OMX_ErrorNone + && state != OMX_StateLoaded) { + LOGV("waiting for Loaded state..."); + usleep(100000); + } + CHECK_EQ(err, OMX_ErrorNone); + + // fall through + } + + case OMX_StateLoaded: + case OMX_StateInvalid: + break; + + default: + CHECK(!"should not be here, unknown state."); + break; + } + + OMX_ERRORTYPE err = OMX_MasterFreeHandle(mHandle); + mHandle = NULL; + + if (err != OMX_ErrorNone) { + LOGE("FreeHandle FAILED with error 0x%08x.", err); + } + + mOwner->invalidateNodeID(mNodeID); + mNodeID = NULL; + + LOGV("OMXNodeInstance going away."); + delete this; + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::sendCommand( + OMX_COMMANDTYPE cmd, OMX_S32 param) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_SendCommand(mHandle, cmd, param, NULL); + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::getParameter( + OMX_INDEXTYPE index, void *params, size_t size) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_GetParameter(mHandle, index, params); + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::setParameter( + OMX_INDEXTYPE index, const void *params, size_t size) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_SetParameter( + mHandle, index, const_cast<void *>(params)); + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::getConfig( + OMX_INDEXTYPE index, void *params, size_t size) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_GetConfig(mHandle, index, params); + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::setConfig( + OMX_INDEXTYPE index, const void *params, size_t size) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_SetConfig( + mHandle, index, const_cast<void *>(params)); + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::useBuffer( + OMX_U32 portIndex, const sp<IMemory> ¶ms, + OMX::buffer_id *buffer) { + Mutex::Autolock autoLock(mLock); + + BufferMeta *buffer_meta = new BufferMeta(params); + + OMX_BUFFERHEADERTYPE *header; + + OMX_ERRORTYPE err = OMX_UseBuffer( + mHandle, &header, portIndex, buffer_meta, + params->size(), static_cast<OMX_U8 *>(params->pointer())); + + if (err != OMX_ErrorNone) { + LOGE("OMX_UseBuffer failed with error %d (0x%08x)", err, err); + + delete buffer_meta; + buffer_meta = NULL; + + *buffer = 0; + + return UNKNOWN_ERROR; + } + + *buffer = header; + + addActiveBuffer(portIndex, *buffer); + + return OK; +} + +status_t OMXNodeInstance::allocateBuffer( + OMX_U32 portIndex, size_t size, OMX::buffer_id *buffer) { + Mutex::Autolock autoLock(mLock); + + BufferMeta *buffer_meta = new BufferMeta(size); + + OMX_BUFFERHEADERTYPE *header; + + OMX_ERRORTYPE err = OMX_AllocateBuffer( + mHandle, &header, portIndex, buffer_meta, size); + + if (err != OMX_ErrorNone) { + LOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err); + + delete buffer_meta; + buffer_meta = NULL; + + *buffer = 0; + + return UNKNOWN_ERROR; + } + + *buffer = header; + + addActiveBuffer(portIndex, *buffer); + + return OK; +} + +status_t OMXNodeInstance::allocateBufferWithBackup( + OMX_U32 portIndex, const sp<IMemory> ¶ms, + OMX::buffer_id *buffer) { + Mutex::Autolock autoLock(mLock); + + BufferMeta *buffer_meta = new BufferMeta(params, true); + + OMX_BUFFERHEADERTYPE *header; + + OMX_ERRORTYPE err = OMX_AllocateBuffer( + mHandle, &header, portIndex, buffer_meta, params->size()); + + if (err != OMX_ErrorNone) { + LOGE("OMX_AllocateBuffer failed with error %d (0x%08x)", err, err); + + delete buffer_meta; + buffer_meta = NULL; + + *buffer = 0; + + return UNKNOWN_ERROR; + } + + *buffer = header; + + addActiveBuffer(portIndex, *buffer); + + return OK; +} + +status_t OMXNodeInstance::freeBuffer( + OMX_U32 portIndex, OMX::buffer_id buffer) { + Mutex::Autolock autoLock(mLock); + + removeActiveBuffer(portIndex, buffer); + + OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; + BufferMeta *buffer_meta = static_cast<BufferMeta *>(header->pAppPrivate); + + OMX_ERRORTYPE err = OMX_FreeBuffer(mHandle, portIndex, header); + + delete buffer_meta; + buffer_meta = NULL; + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::fillBuffer(OMX::buffer_id buffer) { + Mutex::Autolock autoLock(mLock); + + OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; + header->nFilledLen = 0; + header->nOffset = 0; + header->nFlags = 0; + + OMX_ERRORTYPE err = OMX_FillThisBuffer(mHandle, header); + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::emptyBuffer( + OMX::buffer_id buffer, + OMX_U32 rangeOffset, OMX_U32 rangeLength, + OMX_U32 flags, OMX_TICKS timestamp) { + Mutex::Autolock autoLock(mLock); + + OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)buffer; + header->nFilledLen = rangeLength; + header->nOffset = rangeOffset; + header->nFlags = flags; + header->nTimeStamp = timestamp; + + BufferMeta *buffer_meta = + static_cast<BufferMeta *>(header->pAppPrivate); + buffer_meta->CopyToOMX(header); + + OMX_ERRORTYPE err = OMX_EmptyThisBuffer(mHandle, header); + + return StatusFromOMXError(err); +} + +status_t OMXNodeInstance::getExtensionIndex( + const char *parameterName, OMX_INDEXTYPE *index) { + Mutex::Autolock autoLock(mLock); + + OMX_ERRORTYPE err = OMX_GetExtensionIndex( + mHandle, const_cast<char *>(parameterName), index); + + return StatusFromOMXError(err); +} + +void OMXNodeInstance::onMessage(const omx_message &msg) { + if (msg.type == omx_message::FILL_BUFFER_DONE) { + OMX_BUFFERHEADERTYPE *buffer = + static_cast<OMX_BUFFERHEADERTYPE *>( + msg.u.extended_buffer_data.buffer); + + BufferMeta *buffer_meta = + static_cast<BufferMeta *>(buffer->pAppPrivate); + + buffer_meta->CopyFromOMX(buffer); + } + + mObserver->onMessage(msg); +} + +void OMXNodeInstance::onObserverDied() { + LOGE("!!! Observer died. Quickly, do something, ... anything..."); + + // Try to force shutdown of the node and hope for the best. + freeNode(); +} + +void OMXNodeInstance::onGetHandleFailed() { + delete this; +} + +// static +OMX_ERRORTYPE OMXNodeInstance::OnEvent( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_EVENTTYPE eEvent, + OMX_IN OMX_U32 nData1, + OMX_IN OMX_U32 nData2, + OMX_IN OMX_PTR pEventData) { + OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData); + return instance->owner()->OnEvent( + instance->nodeID(), eEvent, nData1, nData2, pEventData); +} + +// static +OMX_ERRORTYPE OMXNodeInstance::OnEmptyBufferDone( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { + OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData); + return instance->owner()->OnEmptyBufferDone(instance->nodeID(), pBuffer); +} + +// static +OMX_ERRORTYPE OMXNodeInstance::OnFillBufferDone( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer) { + OMXNodeInstance *instance = static_cast<OMXNodeInstance *>(pAppData); + return instance->owner()->OnFillBufferDone(instance->nodeID(), pBuffer); +} + +void OMXNodeInstance::addActiveBuffer(OMX_U32 portIndex, OMX::buffer_id id) { + ActiveBuffer active; + active.mPortIndex = portIndex; + active.mID = id; + mActiveBuffers.push(active); +} + +void OMXNodeInstance::removeActiveBuffer( + OMX_U32 portIndex, OMX::buffer_id id) { + bool found = false; + for (size_t i = 0; i < mActiveBuffers.size(); ++i) { + if (mActiveBuffers[i].mPortIndex == portIndex + && mActiveBuffers[i].mID == id) { + found = true; + mActiveBuffers.removeItemsAt(i); + break; + } + } + + if (!found) { + LOGW("Attempt to remove an active buffer we know nothing about..."); + } +} + +void OMXNodeInstance::freeActiveBuffers() { + // Make sure to count down here, as freeBuffer will in turn remove + // the active buffer from the vector... + for (size_t i = mActiveBuffers.size(); i--;) { + freeBuffer(mActiveBuffers[i].mPortIndex, mActiveBuffers[i].mID); + } +} + +} // namespace android + diff --git a/media/libstagefright/string.cpp b/media/libstagefright/stagefright_string.cpp index 5b16784..2aedb80 100644 --- a/media/libstagefright/string.cpp +++ b/media/libstagefright/stagefright_string.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <media/stagefright/string.h> +#include <media/stagefright/stagefright_string.h> namespace android { diff --git a/packages/SubscribedFeedsProvider/Android.mk b/packages/SubscribedFeedsProvider/Android.mk deleted file mode 100644 index bed6a16..0000000 --- a/packages/SubscribedFeedsProvider/Android.mk +++ /dev/null @@ -1,11 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := user - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_PACKAGE_NAME := SubscribedFeedsProvider -LOCAL_CERTIFICATE := platform - -include $(BUILD_PACKAGE) diff --git a/packages/SubscribedFeedsProvider/AndroidManifest.xml b/packages/SubscribedFeedsProvider/AndroidManifest.xml deleted file mode 100644 index a3938bd..0000000 --- a/packages/SubscribedFeedsProvider/AndroidManifest.xml +++ /dev/null @@ -1,35 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.providers.subscribedfeeds" - android:sharedUserId="android.uid.system"> - - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> - <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> - <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_READ" /> - <uses-permission android:name="android.permission.SUBSCRIBED_FEEDS_WRITE" /> - - <application android:process="system" - android:allowClearUserData="false" - android:icon="@drawable/app_icon" - android:label="@string/app_label"> - <uses-library android:name="com.google.android.gtalkservice" /> - <provider android:name="SubscribedFeedsProvider" - android:authorities="subscribedfeeds" - android:label="@string/provider_label" - android:multiprocess="false" - android:readPermission="android.permission.SUBSCRIBED_FEEDS_READ" - android:writePermission="android.permission.SUBSCRIBED_FEEDS_WRITE" /> - <receiver android:name="SubscribedFeedsBroadcastReceiver"> - <intent-filter> - <action android:name="android.intent.action.REMOTE_INTENT" /> - <category android:name="GSYNC_TICKLE"/> - </intent-filter> - <intent-filter> - <action android:name="android.intent.action.BOOT_COMPLETED" /> - </intent-filter> - <intent-filter> - <action android:name="com.android.subscribedfeeds.action.REFRESH" /> - </intent-filter> - </receiver> - <service android:name="SubscribedFeedsIntentService"/> - </application> -</manifest> diff --git a/packages/SubscribedFeedsProvider/MODULE_LICENSE_APACHE2 b/packages/SubscribedFeedsProvider/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29..0000000 --- a/packages/SubscribedFeedsProvider/MODULE_LICENSE_APACHE2 +++ /dev/null diff --git a/packages/SubscribedFeedsProvider/NOTICE b/packages/SubscribedFeedsProvider/NOTICE deleted file mode 100644 index c5b1efa..0000000 --- a/packages/SubscribedFeedsProvider/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (c) 2005-2008, 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. - - 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. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/packages/SubscribedFeedsProvider/res/drawable/app_icon.png b/packages/SubscribedFeedsProvider/res/drawable/app_icon.png Binary files differdeleted file mode 100644 index 13d8cdd..0000000 --- a/packages/SubscribedFeedsProvider/res/drawable/app_icon.png +++ /dev/null diff --git a/packages/SubscribedFeedsProvider/res/values-cs/strings.xml b/packages/SubscribedFeedsProvider/res/values-cs/strings.xml deleted file mode 100644 index 5b06f7b..0000000 --- a/packages/SubscribedFeedsProvider/res/values-cs/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Synchronizace zdrojů"</string> - <string name="provider_label" msgid="3669714991966737047">"Zobrazit odběry"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-da/strings.xml b/packages/SubscribedFeedsProvider/res/values-da/strings.xml deleted file mode 100644 index f8867a2..0000000 --- a/packages/SubscribedFeedsProvider/res/values-da/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Synkroniser feeds"</string> - <string name="provider_label" msgid="3669714991966737047">"Push-abonnementer"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-de/strings.xml b/packages/SubscribedFeedsProvider/res/values-de/strings.xml deleted file mode 100644 index 8bfd721..0000000 --- a/packages/SubscribedFeedsProvider/res/values-de/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Feedsynchronisierung"</string> - <string name="provider_label" msgid="3669714991966737047">"Push-Abos"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-el/strings.xml b/packages/SubscribedFeedsProvider/res/values-el/strings.xml deleted file mode 100644 index 11a3486..0000000 --- a/packages/SubscribedFeedsProvider/res/values-el/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Συγχρονισμός ροών δεδομένων"</string> - <string name="provider_label" msgid="3669714991966737047">"Προώθηση συνδρομών"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-es-rUS/strings.xml b/packages/SubscribedFeedsProvider/res/values-es-rUS/strings.xml deleted file mode 100644 index 75f1b9f..0000000 --- a/packages/SubscribedFeedsProvider/res/values-es-rUS/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Canales de sincronización"</string> - <string name="provider_label" msgid="3669714991966737047">"Suscripciones de inserción"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-es/strings.xml b/packages/SubscribedFeedsProvider/res/values-es/strings.xml deleted file mode 100644 index 59d1693..0000000 --- a/packages/SubscribedFeedsProvider/res/values-es/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Sincronización de feeds"</string> - <string name="provider_label" msgid="3669714991966737047">"Enviar suscripciones"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-fr/strings.xml b/packages/SubscribedFeedsProvider/res/values-fr/strings.xml deleted file mode 100644 index ab1aae9..0000000 --- a/packages/SubscribedFeedsProvider/res/values-fr/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Synchronisation des flux"</string> - <string name="provider_label" msgid="3669714991966737047">"Abonnements Push"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-it/strings.xml b/packages/SubscribedFeedsProvider/res/values-it/strings.xml deleted file mode 100644 index 2a6dd54..0000000 --- a/packages/SubscribedFeedsProvider/res/values-it/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Sincronizzazione feed"</string> - <string name="provider_label" msgid="3669714991966737047">"Sottoscrizioni push"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-ja/strings.xml b/packages/SubscribedFeedsProvider/res/values-ja/strings.xml deleted file mode 100644 index 6a0812a..0000000 --- a/packages/SubscribedFeedsProvider/res/values-ja/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"フィードの同期"</string> - <string name="provider_label" msgid="3669714991966737047">"プッシュ型登録"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-ko/strings.xml b/packages/SubscribedFeedsProvider/res/values-ko/strings.xml deleted file mode 100644 index 0912732..0000000 --- a/packages/SubscribedFeedsProvider/res/values-ko/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"피드 동기화"</string> - <string name="provider_label" msgid="3669714991966737047">"구독정보 푸시"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-nb/strings.xml b/packages/SubscribedFeedsProvider/res/values-nb/strings.xml deleted file mode 100644 index 30a2c5e..0000000 --- a/packages/SubscribedFeedsProvider/res/values-nb/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Strømsynkronisering"</string> - <string name="provider_label" msgid="3669714991966737047">"Push-abonnementer"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-nl/strings.xml b/packages/SubscribedFeedsProvider/res/values-nl/strings.xml deleted file mode 100644 index b74e66b..0000000 --- a/packages/SubscribedFeedsProvider/res/values-nl/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Feeds synchroniseren"</string> - <string name="provider_label" msgid="3669714991966737047">"Abonnementen doorvoeren"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-pl/strings.xml b/packages/SubscribedFeedsProvider/res/values-pl/strings.xml deleted file mode 100644 index ed6c1d0..0000000 --- a/packages/SubscribedFeedsProvider/res/values-pl/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Synchronizowanie kanałów"</string> - <string name="provider_label" msgid="3669714991966737047">"Subskrypcje w trybie push"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-pt-rPT/strings.xml b/packages/SubscribedFeedsProvider/res/values-pt-rPT/strings.xml deleted file mode 100644 index 29f69ac..0000000 --- a/packages/SubscribedFeedsProvider/res/values-pt-rPT/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Sincronizar feeds"</string> - <string name="provider_label" msgid="3669714991966737047">"Transferir Subscrições"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-pt/strings.xml b/packages/SubscribedFeedsProvider/res/values-pt/strings.xml deleted file mode 100644 index 081190d..0000000 --- a/packages/SubscribedFeedsProvider/res/values-pt/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Sincronizar feeds"</string> - <string name="provider_label" msgid="3669714991966737047">"Enviar inscrições"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-ru/strings.xml b/packages/SubscribedFeedsProvider/res/values-ru/strings.xml deleted file mode 100644 index 24ead0a..0000000 --- a/packages/SubscribedFeedsProvider/res/values-ru/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Фиды синхронизации"</string> - <string name="provider_label" msgid="3669714991966737047">"Подписки Push"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-sv/strings.xml b/packages/SubscribedFeedsProvider/res/values-sv/strings.xml deleted file mode 100644 index 55499c5..0000000 --- a/packages/SubscribedFeedsProvider/res/values-sv/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Synkroniseringsflöden"</string> - <string name="provider_label" msgid="3669714991966737047">"Push-prenumerationer"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-tr/strings.xml b/packages/SubscribedFeedsProvider/res/values-tr/strings.xml deleted file mode 100644 index baa3330..0000000 --- a/packages/SubscribedFeedsProvider/res/values-tr/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"Senkronizasyon Yayınları"</string> - <string name="provider_label" msgid="3669714991966737047">"Abonelik Şart Koş"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-zh-rCN/strings.xml b/packages/SubscribedFeedsProvider/res/values-zh-rCN/strings.xml deleted file mode 100644 index 05edb80..0000000 --- a/packages/SubscribedFeedsProvider/res/values-zh-rCN/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"同步供稿"</string> - <string name="provider_label" msgid="3669714991966737047">"推送订阅"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values-zh-rTW/strings.xml b/packages/SubscribedFeedsProvider/res/values-zh-rTW/strings.xml deleted file mode 100644 index 5e5bcc5..0000000 --- a/packages/SubscribedFeedsProvider/res/values-zh-rTW/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2009 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. ---> -<resources xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="app_label" msgid="5400580392303600842">"同步資訊提供"</string> - <string name="provider_label" msgid="3669714991966737047">"預先載入訂閱項目"</string> -</resources> diff --git a/packages/SubscribedFeedsProvider/res/values/strings.xml b/packages/SubscribedFeedsProvider/res/values/strings.xml deleted file mode 100644 index c4c2484..0000000 --- a/packages/SubscribedFeedsProvider/res/values/strings.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 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. ---> - -<resources> - <!-- Title of the feed synchronization activity. --> - <string name="app_label">Sync Feeds</string> - - <!-- What to show in messaging that refers to this provider, e.g. AccountSyncSettings --> - <string name="provider_label">Push Subscriptions</string> - -</resources> - diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java deleted file mode 100644 index ea14307..0000000 --- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsBroadcastReceiver.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -** Copyright 2006, 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. -*/ - -package com.android.providers.subscribedfeeds; - -import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -/** - * Handles the XMPP_CONNECTED_ACTION intent by updating all the - * subscribed feeds with the new jabber id and initiating a sync - * for all subscriptions. - * - * Handles the TICKLE_ACTION intent by finding the matching - * subscribed feed and intiating a sync for it. - */ -public class SubscribedFeedsBroadcastReceiver extends BroadcastReceiver { - - private static final String TAG = "Sync"; - - public void onReceive(Context context, Intent intent) { - if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received intent " + intent); - if (intent.getAction().equals(Intent.ACTION_REMOTE_INTENT)) { - setResultCode(Activity.RESULT_OK); - } - intent.setClass(context, SubscribedFeedsIntentService.class); - context.startService(intent); - } -} diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java deleted file mode 100644 index 2e910b7..0000000 --- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsIntentService.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.android.providers.subscribedfeeds; - -import android.content.Intent; -import android.content.Context; -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.SharedPreferences; -import android.util.Log; -import android.util.Config; -import android.util.EventLog; -import android.app.IntentService; -import android.provider.SubscribedFeeds; -import android.provider.SyncConstValue; -import android.database.Cursor; -import android.database.sqlite.SQLiteFullException; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.os.Bundle; -import android.text.TextUtils; -import android.accounts.Account; - -import java.util.ArrayList; -import java.util.Calendar; - -import com.google.android.collect.Lists; - -/** - * A service to handle various intents asynchronously. - */ -public class SubscribedFeedsIntentService extends IntentService { - private static final String TAG = "Sync"; - - private static final String[] sAccountProjection = - new String[] {SubscribedFeeds.Accounts._SYNC_ACCOUNT, - SubscribedFeeds.Accounts._SYNC_ACCOUNT_TYPE}; - - /** How often to refresh the subscriptions, in milliseconds */ - private static final long SUBSCRIPTION_REFRESH_INTERVAL = 1000L * 60 * 60 * 24; // one day - - private static final String sRefreshTime = "refreshTime"; - - private static final String sSubscribedFeedsPrefs = "subscribedFeeds"; - - private static final String REMOTE_INTENT_ACTION = Intent.ACTION_REMOTE_INTENT; - - private static final String SUBSCRIBED_FEEDS_REFRESH_ACTION = - "com.android.subscribedfeeds.action.REFRESH"; - - private static final int LOG_TICKLE = 2742; - - public SubscribedFeedsIntentService() { - super("SubscribedFeedsIntentService"); - } - - protected void onHandleIntent(Intent intent) { - if (REMOTE_INTENT_ACTION.equals(intent.getAction())) { - boolean fromTrustedServer = intent.getBooleanExtra( - "android.intent.extra.from_trusted_server", false); - if (fromTrustedServer) { - String accountName = intent.getStringExtra("account"); - String token = intent.getStringExtra(Intent.EXTRA_REMOTE_INTENT_TOKEN); - - if (TextUtils.isEmpty(accountName) || TextUtils.isEmpty(token)) { - if (Config.LOGD) { - Log.d(TAG, "Ignoring malformed tickle -- missing account or token."); - } - return; - } - - if (Config.LOGD) { - Log.d(TAG, "Received network tickle for " - + accountName + " - " + token); - } - - handleTickle(this, accountName, token); - } else { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.v(TAG, "Ignoring tickle -- not from trusted server."); - } - } - - } else if (Intent.ACTION_BOOT_COMPLETED.equals( - intent.getAction())) { - if (Config.LOGD) { - Log.d(TAG, "Received boot completed action"); - } - // load the time from the shared preferences and schedule an alarm - long refreshTime = getSharedPreferences( - sSubscribedFeedsPrefs, - Context.MODE_WORLD_READABLE).getLong(sRefreshTime, 0); - scheduleRefresh(this, refreshTime); - } else if (SUBSCRIBED_FEEDS_REFRESH_ACTION.equals(intent.getAction())) { - if (Config.LOGD) { - Log.d(TAG, "Received sSubscribedFeedsRefreshIntent"); - } - handleRefreshAlarm(this); - } - } - private void scheduleRefresh(Context context, long when) { - AlarmManager alarmManager = (AlarmManager) context.getSystemService( - Context.ALARM_SERVICE); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, - 0, new Intent(SUBSCRIBED_FEEDS_REFRESH_ACTION), 0); - alarmManager.set(AlarmManager.RTC, when, pendingIntent); - } - - private void handleTickle(Context context, String accountName, String feed) { - Cursor c = null; - final String where = SubscribedFeeds.Feeds._SYNC_ACCOUNT + "= ? " - + "and " + SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "= ? " - + "and " + SubscribedFeeds.Feeds.FEED + "= ?"; - try { - // TODO(fredq) fix the hardcoded type - final Account account = new Account(accountName, "com.google"); - c = context.getContentResolver().query(SubscribedFeeds.Feeds.CONTENT_URI, - null, where, new String[]{account.name, account.type, feed}, null); - if (c.getCount() == 0) { - Log.w(TAG, "received tickle for non-existent feed: " - + "account " + accountName + ", feed " + feed); - EventLog.writeEvent(LOG_TICKLE, "unknown"); - } - while (c.moveToNext()) { - // initiate a sync - String authority = c.getString(c.getColumnIndexOrThrow( - SubscribedFeeds.Feeds.AUTHORITY)); - EventLog.writeEvent(LOG_TICKLE, authority); - if (!ContentResolver.getSyncAutomatically(account, authority)) { - Log.d(TAG, "supressing tickle since provider " + authority - + " is configured to not sync automatically"); - continue; - } - Bundle extras = new Bundle(); - extras.putString("feed", feed); - ContentResolver.requestSync(account, authority, extras); - } - } finally { - if (c != null) c.deactivate(); - } - } - - /** - * Cause all the subscribed feeds to be marked dirty and their - * authtokens to be refreshed, which will result in new authtokens - * being sent to the subscription server. Then reschedules this - * event for one week in the future. - * - * @param context Context we are running within - */ - private void handleRefreshAlarm(Context context) { - // retrieve the list of accounts from the subscribed feeds - ArrayList<Account> accounts = Lists.newArrayList(); - ContentResolver contentResolver = context.getContentResolver(); - Cursor c = contentResolver.query(SubscribedFeeds.Accounts.CONTENT_URI, - sAccountProjection, null, null, null); - try { - while (c.moveToNext()) { - String accountName = c.getString(0); - String accountType = c.getString(1); - accounts.add(new Account(accountName, accountType)); - } - } finally { - c.close(); - } - - // Clear the auth tokens for all these accounts so that we are sure - // they will still be valid until the next time we refresh them. - // TODO(fredq): add this when the google login service is done - - // mark the feeds dirty, by setting the accounts to the same value, - // which will trigger a sync. - try { - ContentValues values = new ContentValues(); - for (Account account : accounts) { - values.put(SyncConstValue._SYNC_ACCOUNT, account.name); - values.put(SyncConstValue._SYNC_ACCOUNT_TYPE, account.type); - contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values, - SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=? AND " - + SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "=?", - new String[] {account.name, account.type}); - } - } catch (SQLiteFullException e) { - Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping"); - } - - // Schedule a refresh. - long refreshTime = Calendar.getInstance().getTimeInMillis() + SUBSCRIPTION_REFRESH_INTERVAL; - scheduleRefresh(context, refreshTime); - SharedPreferences.Editor editor = context.getSharedPreferences(sSubscribedFeedsPrefs, - Context.MODE_WORLD_READABLE).edit(); - editor.putLong(sRefreshTime, refreshTime); - editor.commit(); - } -} diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java deleted file mode 100644 index 8585082..0000000 --- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java +++ /dev/null @@ -1,391 +0,0 @@ -/* -** Copyright 2006, 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. -*/ - -package com.android.providers.subscribedfeeds; - -import android.accounts.Account; -import android.content.UriMatcher; -import android.content.*; -import android.database.Cursor; -import android.database.DatabaseUtils; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteQueryBuilder; -import android.net.Uri; -import android.provider.SubscribedFeeds; -import android.text.TextUtils; -import android.util.Config; -import android.util.Log; - -import java.util.Collections; -import java.util.Map; -import java.util.HashMap; - -/** - * Manages a list of feeds for which this client is interested in receiving - * change notifications. - */ -public class SubscribedFeedsProvider extends AbstractSyncableContentProvider { - private static final String TAG = "SubscribedFeedsProvider"; - private static final String DATABASE_NAME = "subscribedfeeds.db"; - private static final int DATABASE_VERSION = 11; - - private static final int FEEDS = 1; - private static final int FEED_ID = 2; - private static final int DELETED_FEEDS = 3; - private static final int ACCOUNTS = 4; - - private static final Map<String, String> ACCOUNTS_PROJECTION_MAP; - - private static final UriMatcher sURLMatcher = - new UriMatcher(UriMatcher.NO_MATCH); - - private static String sFeedsTable = "feeds"; - private static Uri sFeedsUrl = - Uri.parse("content://subscribedfeeds/feeds/"); - private static String sDeletedFeedsTable = "_deleted_feeds"; - private static Uri sDeletedFeedsUrl = - Uri.parse("content://subscribedfeeds/deleted_feeds/"); - - public SubscribedFeedsProvider() { - super(DATABASE_NAME, DATABASE_VERSION, sFeedsUrl); - } - - static { - sURLMatcher.addURI("subscribedfeeds", "feeds", FEEDS); - sURLMatcher.addURI("subscribedfeeds", "feeds/#", FEED_ID); - sURLMatcher.addURI("subscribedfeeds", "deleted_feeds", DELETED_FEEDS); - sURLMatcher.addURI("subscribedfeeds", "accounts", ACCOUNTS); - } - - @Override - protected boolean upgradeDatabase(SQLiteDatabase db, - int oldVersion, int newVersion) { - Log.w(TAG, "Upgrading database from version " + oldVersion + - " to " + newVersion + - ", which will destroy all old data"); - db.execSQL("DROP TRIGGER IF EXISTS feed_cleanup"); - db.execSQL("DROP TABLE IF EXISTS _deleted_feeds"); - db.execSQL("DROP TABLE IF EXISTS feeds"); - bootstrapDatabase(db); - return false; // this was lossy - } - - @Override - protected void bootstrapDatabase(SQLiteDatabase db) { - super.bootstrapDatabase(db); - db.execSQL("CREATE TABLE feeds (" + - "_id INTEGER PRIMARY KEY," + - "_sync_account TEXT," + // From the sync source - "_sync_account_type TEXT," + // From the sync source - "_sync_id TEXT," + // From the sync source - "_sync_time TEXT," + // From the sync source - "_sync_version TEXT," + // From the sync source - "_sync_local_id INTEGER," + // Used while syncing, - // never stored persistently - "_sync_dirty INTEGER," + // if syncable, set if the record - // has local, unsynced, changes - "_sync_mark INTEGER," + // Used to filter out new rows - "feed TEXT," + - "authority TEXT," + - "service TEXT" + - ");"); - - // Trigger to completely remove feeds data when they're deleted - db.execSQL("CREATE TRIGGER feed_cleanup DELETE ON feeds " + - "WHEN old._sync_id is not null " + - "BEGIN " + - "INSERT INTO _deleted_feeds " + - "(_sync_id, _sync_account, _sync_account_type, _sync_version) " + - "VALUES (old._sync_id, old._sync_account, old._sync_account_type, " + - "old._sync_version);" + - "END"); - - db.execSQL("CREATE TABLE _deleted_feeds (" + - "_sync_version TEXT," + // From the sync source - "_sync_id TEXT," + - (isTemporary() ? "_sync_local_id INTEGER," : "") + // Used while syncing, - "_sync_account TEXT," + - "_sync_account_type TEXT," + - "_sync_mark INTEGER, " + // Used to filter out new rows - "UNIQUE(_sync_id))"); - } - - @Override - protected void onAccountsChanged(Account[] accountsArray) { - super.onAccountsChanged(accountsArray); - for (Account account : accountsArray) { - if (account.type.equals("com.google")) { - ContentResolver.setSyncAutomatically(account, "subscribedfeeds", true); - } - } - } - - @Override - protected void onDatabaseOpened(SQLiteDatabase db) { - db.markTableSyncable("feeds", "_deleted_feeds"); - } - - @Override - protected Iterable<FeedMerger> getMergers() { - return Collections.singletonList(new FeedMerger()); - } - - @Override - public String getType(Uri url) { - int match = sURLMatcher.match(url); - switch (match) { - case FEEDS: - return SubscribedFeeds.Feeds.CONTENT_TYPE; - case FEED_ID: - return SubscribedFeeds.Feeds.CONTENT_ITEM_TYPE; - default: - throw new IllegalArgumentException("Unknown URL"); - } - } - - @Override - public Cursor queryInternal(Uri url, String[] projection, - String selection, String[] selectionArgs, String sortOrder) { - SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - - - // Generate the body of the query - int match = sURLMatcher.match(url); - - if (Config.LOGV) Log.v(TAG, "SubscribedFeedsProvider.query: url=" + - url + ", match is " + match); - - switch (match) { - case FEEDS: - qb.setTables(sFeedsTable); - break; - case DELETED_FEEDS: - if (!isTemporary()) { - throw new UnsupportedOperationException(); - } - qb.setTables(sDeletedFeedsTable); - break; - case ACCOUNTS: - qb.setTables(sFeedsTable); - qb.setDistinct(true); - qb.setProjectionMap(ACCOUNTS_PROJECTION_MAP); - return qb.query(getDatabase(), projection, selection, selectionArgs, - SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "," - + SubscribedFeeds.Feeds._SYNC_ACCOUNT, null, sortOrder); - case FEED_ID: - qb.setTables(sFeedsTable); - qb.appendWhere(sFeedsTable + "._id="); - qb.appendWhere(url.getPathSegments().get(1)); - break; - default: - throw new IllegalArgumentException("Unknown URL " + url); - } - - // run the query - return qb.query(getDatabase(), projection, selection, selectionArgs, - null, null, sortOrder); - } - - @Override - public Uri insertInternal(Uri url, ContentValues initialValues) { - final SQLiteDatabase db = getDatabase(); - Uri resultUri = null; - long rowID; - - int match = sURLMatcher.match(url); - switch (match) { - case FEEDS: - ContentValues values = new ContentValues(initialValues); - values.put(SubscribedFeeds.Feeds._SYNC_DIRTY, 1); - rowID = db.insert(sFeedsTable, "feed", values); - if (rowID > 0) { - resultUri = Uri.parse( - "content://subscribedfeeds/feeds/" + rowID); - } - break; - - case DELETED_FEEDS: - if (!isTemporary()) { - throw new UnsupportedOperationException(); - } - rowID = db.insert(sDeletedFeedsTable, "_sync_id", - initialValues); - if (rowID > 0) { - resultUri = Uri.parse( - "content://subscribedfeeds/deleted_feeds/" + rowID); - } - break; - - default: - throw new UnsupportedOperationException( - "Cannot insert into URL: " + url); - } - - return resultUri; - } - - @Override - public int deleteInternal(Uri url, String userWhere, String[] whereArgs) { - final SQLiteDatabase db = getDatabase(); - String changedItemId; - - switch (sURLMatcher.match(url)) { - case FEEDS: - changedItemId = null; - break; - case FEED_ID: - changedItemId = url.getPathSegments().get(1); - break; - default: - throw new UnsupportedOperationException( - "Cannot delete that URL: " + url); - } - - String where = addIdToWhereClause(changedItemId, userWhere); - return db.delete(sFeedsTable, where, whereArgs); - } - - @Override - public int updateInternal(Uri url, ContentValues initialValues, - String userWhere, String[] whereArgs) { - final SQLiteDatabase db = getDatabase(); - ContentValues values = new ContentValues(initialValues); - values.put(SubscribedFeeds.Feeds._SYNC_DIRTY, 1); - - String changedItemId; - switch (sURLMatcher.match(url)) { - case FEEDS: - changedItemId = null; - break; - - case FEED_ID: - changedItemId = url.getPathSegments().get(1); - break; - - default: - throw new UnsupportedOperationException( - "Cannot update URL: " + url); - } - - String where = addIdToWhereClause(changedItemId, userWhere); - return db.update(sFeedsTable, values, where, whereArgs); - } - - private static String addIdToWhereClause(String id, String where) { - if (id != null) { - StringBuilder whereSb = new StringBuilder("_id="); - whereSb.append(id); - if (!TextUtils.isEmpty(where)) { - whereSb.append(" AND ("); - whereSb.append(where); - whereSb.append(')'); - } - return whereSb.toString(); - } else { - return where; - } - } - - private class FeedMerger extends AbstractTableMerger { - private ContentValues mValues = new ContentValues(); - FeedMerger() { - super(getDatabase(), sFeedsTable, sFeedsUrl, sDeletedFeedsTable, sDeletedFeedsUrl); - } - - @Override - protected void notifyChanges() { - getContext().getContentResolver().notifyChange( - sFeedsUrl, null /* data change observer */, - false /* do not sync to network */); - } - - @Override - public void insertRow(ContentProvider diffs, Cursor diffsCursor) { - final SQLiteDatabase db = getDatabase(); - // We don't ever want to add entries from the server, instead - // we want to tell the server to delete any entries we receive - // from the server that aren't already known by the client. - mValues.clear(); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_ID, mValues); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_ACCOUNT, mValues); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE, mValues); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_VERSION, mValues); - db.replace(mDeletedTable, SubscribedFeeds.Feeds._SYNC_ID, mValues); - } - - @Override - public void updateRow(long localPersonID, ContentProvider diffs, - Cursor diffsCursor) { - updateOrResolveRow(localPersonID, null, diffs, diffsCursor, false); - } - - @Override - public void resolveRow(long localPersonID, String syncID, - ContentProvider diffs, Cursor diffsCursor) { - updateOrResolveRow(localPersonID, syncID, diffs, diffsCursor, true); - } - - protected void updateOrResolveRow(long localPersonID, String syncID, - ContentProvider diffs, Cursor diffsCursor, boolean conflicts) { - mValues.clear(); - // only copy over the fields that the server owns - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_ID, mValues); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_TIME, mValues); - DatabaseUtils.cursorStringToContentValues(diffsCursor, - SubscribedFeeds.Feeds._SYNC_VERSION, mValues); - mValues.put(SubscribedFeeds.Feeds._SYNC_DIRTY, conflicts ? 1 : 0); - final SQLiteDatabase db = getDatabase(); - db.update(mTable, mValues, - SubscribedFeeds.Feeds._ID + '=' + localPersonID, null); - } - - @Override - public void deleteRow(Cursor localCursor) { - // Since the client is the authority we don't actually delete - // the row when the server says it has been deleted. Instead - // we break the association with the server by clearing out - // the id, time, and version, then we mark it dirty so that - // it will be synced back to the server. - long localPersonId = localCursor.getLong(localCursor.getColumnIndex( - SubscribedFeeds.Feeds._ID)); - mValues.clear(); - mValues.put(SubscribedFeeds.Feeds._SYNC_DIRTY, 1); - mValues.put(SubscribedFeeds.Feeds._SYNC_ID, (String) null); - mValues.put(SubscribedFeeds.Feeds._SYNC_TIME, (Long) null); - mValues.put(SubscribedFeeds.Feeds._SYNC_VERSION, (String) null); - final SQLiteDatabase db = getDatabase(); - db.update(mTable, mValues, SubscribedFeeds.Feeds._ID + '=' + localPersonId, null); - localCursor.moveToNext(); - } - } - - static { - Map<String, String> map; - - map = new HashMap<String, String>(); - ACCOUNTS_PROJECTION_MAP = map; - map.put(SubscribedFeeds.Accounts._COUNT, "COUNT(*) AS _count"); - map.put(SubscribedFeeds.Accounts._SYNC_ACCOUNT, SubscribedFeeds.Accounts._SYNC_ACCOUNT); - map.put(SubscribedFeeds.Accounts._SYNC_ACCOUNT_TYPE, - SubscribedFeeds.Accounts._SYNC_ACCOUNT_TYPE); - } -} diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java index 5a1619a..d59aead 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -16,6 +16,7 @@ package com.android.server.am; +import android.bluetooth.BluetoothHeadset; import android.content.Context; import android.os.Binder; import android.os.IBinder; @@ -23,7 +24,6 @@ import android.os.Parcel; import android.os.Process; import android.os.ServiceManager; import android.telephony.SignalStrength; -import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.app.IBatteryStats; @@ -263,9 +263,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub { public void noteBluetoothOn() { enforceCallingPermission(); + BluetoothHeadset headset = new BluetoothHeadset(mContext, null); synchronized (mStats) { mStats.noteBluetoothOnLocked(); - mStats.setBtHeadset(new android.bluetooth.BluetoothHeadset(mContext, null)); + mStats.setBtHeadset(headset); } } |