diff options
Diffstat (limited to 'include')
47 files changed, 899 insertions, 169 deletions
diff --git a/include/android/configuration.h b/include/android/configuration.h index be00066..7573cca 100644 --- a/include/android/configuration.h +++ b/include/android/configuration.h @@ -78,6 +78,10 @@ enum { ACONFIGURATION_SCREENLONG_NO = 0x1, ACONFIGURATION_SCREENLONG_YES = 0x2, + ACONFIGURATION_SCREENROUND_ANY = 0x00, + ACONFIGURATION_SCREENROUND_NO = 0x1, + ACONFIGURATION_SCREENROUND_YES = 0x2, + ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00, ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01, ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02, @@ -115,6 +119,7 @@ enum { ACONFIGURATION_UI_MODE = 0x1000, ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000, ACONFIGURATION_LAYOUTDIR = 0x4000, + ACONFIGURATION_SCREEN_ROUND = 0x8000, ACONFIGURATION_MNC_ZERO = 0xffff, }; @@ -288,6 +293,16 @@ int32_t AConfiguration_getScreenLong(AConfiguration* config); void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong); /** + * Return the current ACONFIGURATION_SCREENROUND_* set in the configuration. + */ +int32_t AConfiguration_getScreenRound(AConfiguration* config); + +/** + * Set the current screen round in the configuration. + */ +void AConfiguration_setScreenRound(AConfiguration* config, int32_t screenRound); + +/** * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration. */ int32_t AConfiguration_getUiModeType(AConfiguration* config); diff --git a/include/android/input.h b/include/android/input.h index a660761..efbbb85 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -305,6 +305,12 @@ enum { /* The pointer is not down but has exited the boundaries of a window or view. */ AMOTION_EVENT_ACTION_HOVER_EXIT = 10, + + /* One or more buttons have been pressed. */ + AMOTION_EVENT_ACTION_BUTTON_PRESS = 11, + + /* One or more buttons have been released. */ + AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12, }; /* @@ -405,6 +411,8 @@ enum { AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, AMOTION_EVENT_BUTTON_BACK = 1 << 3, AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, + AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5, + AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6, }; /* @@ -445,6 +453,7 @@ enum { AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, + AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS, AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, diff --git a/include/android/keycodes.h b/include/android/keycodes.h index 268d092..de9e735 100644 --- a/include/android/keycodes.h +++ b/include/android/keycodes.h @@ -303,15 +303,14 @@ enum { AKEYCODE_TV_MEDIA_CONTEXT_MENU = 257, AKEYCODE_TV_TIMER_PROGRAMMING = 258, AKEYCODE_HELP = 259, - /** Primary stem key for Wear - * Main power/reset button on watch. */ - AKEYCODE_STEM_PRIMARY = 264, - /** Generic stem key 1 for Wear */ - AKEYCODE_STEM_1 = 265, - /** Generic stem key 2 for Wear */ - AKEYCODE_STEM_2 = 266, - /** Generic stem key 3 for Wear */ - AKEYCODE_STEM_3 = 267 + AKEYCODE_NAVIGATE_PREVIOUS = 260, + AKEYCODE_NAVIGATE_NEXT = 261, + AKEYCODE_NAVIGATE_IN = 262, + AKEYCODE_NAVIGATE_OUT = 263, + AKEYCODE_MEDIA_SKIP_FORWARD = 272, + AKEYCODE_MEDIA_SKIP_BACKWARD = 273, + AKEYCODE_MEDIA_STEP_FORWARD = 274, + AKEYCODE_MEDIA_STEP_BACKWARD = 275 // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h new file mode 100644 index 0000000..6c718c9 --- /dev/null +++ b/include/android/multinetwork.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 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 ANDROID_MULTINETWORK_H +#define ANDROID_MULTINETWORK_H + +#include <netdb.h> +#include <stdlib.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/** + * The corresponding C type for android.net.Network#getNetworkHandle() return + * values. The Java signed long value can be safely cast to a net_handle_t: + * + * [C] ((net_handle_t) java_long_network_handle) + * [C++] static_cast<net_handle_t>(java_long_network_handle) + * + * as appropriate. + */ +typedef uint64_t net_handle_t; + +/** + * The value NETWORK_UNSPECIFIED indicates no specific network. + * + * For some functions (documented below), a previous binding may be cleared + * by an invocation with NETWORK_UNSPECIFIED. + * + * Depending on the context it may indicate an error. It is expressly + * not used to indicate some notion of the "current default network". + */ +#define NETWORK_UNSPECIFIED ((net_handle_t)0) + + +/** + * All functions below that return an int return 0 on success or -1 + * on failure with an appropriate errno value set. + */ + + +/** + * Set the network to be used by the given socket file descriptor. + * + * To clear a previous socket binding invoke with NETWORK_UNSPECIFIED. + * + * This is the equivalent of: + * + * [ android.net.Network#bindSocket() ] + * https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket) + */ +int android_setsocknetwork(net_handle_t network, int fd); + + +/** + * Binds the current process to |network|. All sockets created in the future + * (and not explicitly bound via android_setsocknetwork()) will be bound to + * |network|. All host name resolutions will be limited to |network| as well. + * Note that if the network identified by |network| ever disconnects, all + * sockets created in this way will cease to work and all host name + * resolutions will fail. This is by design so an application doesn't + * accidentally use sockets it thinks are still bound to a particular network. + * + * To clear a previous process binding invoke with NETWORK_UNSPECIFIED. + * + * This is the equivalent of: + * + * [ android.net.ConnectivityManager#setProcessDefaultNetwork() ] + * https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network) + */ +int android_setprocnetwork(net_handle_t network); + + +/** + * Perform hostname resolution via the DNS servers associated with |network|. + * + * All arguments (apart from |network|) are used identically as those passed + * to getaddrinfo(3). Return and error values are identical to those of + * getaddrinfo(3), and in particular gai_strerror(3) can be used as expected. + * Similar to getaddrinfo(3): + * - |hints| may be NULL (in which case man page documented defaults apply) + * - either |node| or |service| may be NULL, but not both + * - |res| must not be NULL + * + * This is the equivalent of: + * + * [ android.net.Network#getAllByName() ] + * https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String) + */ +int android_getaddrinfofornetwork(net_handle_t network, + const char *node, const char *service, + const struct addrinfo *hints, struct addrinfo **res); + +__END_DECLS + +#endif // ANDROID_MULTINETWORK_H diff --git a/include/android/sensor.h b/include/android/sensor.h index d58c460..1be6232 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -193,15 +193,28 @@ typedef ASensorRef const* ASensorList; /*****************************************************************************/ /* - * Get a reference to the sensor manager. ASensorManager is a singleton. + * Get a reference to the sensor manager. ASensorManager is a singleton + * per package as different packages may have access to different sensors. + * + * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead. * * Example: * * ASensorManager* sensorManager = ASensorManager_getInstance(); * */ -ASensorManager* ASensorManager_getInstance(); +__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance(); +/* + * Get a reference to the sensor manager. ASensorManager is a singleton + * per package as different packages may have access to different sensors. + * + * Example: + * + * ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz"); + * + */ +ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName); /* * Returns the list of available sensors. diff --git a/include/android/trace.h b/include/android/trace.h new file mode 100644 index 0000000..e42e334 --- /dev/null +++ b/include/android/trace.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 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 ANDROID_NATIVE_TRACE_H +#define ANDROID_NATIVE_TRACE_H + +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary + * when tracing is enabled. + */ +bool ATrace_isEnabled(); + +/** + * Writes a tracing message to indicate that the given section of code has begun. This call must be + * followed by a corresponding call to endSection() on the same thread. + * + * Note: At this time the vertical bar character '|' and newline character '\n' are used internally + * by the tracing mechanism. If sectionName contains these characters they will be replaced with a + * space character in the trace. + */ +void ATrace_beginSection(const char* sectionName); + +/** + * Writes a tracing message to indicate that a given section of code has ended. This call must be + * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method + * will mark the end of the most recently begun section of code, so care must be taken to ensure + * that beginSection / endSection pairs are properly nested and called from the same thread. + */ +void ATrace_endSection(); + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_NATIVE_TRACE_H diff --git a/include/binder/AppOpsManager.h b/include/binder/AppOpsManager.h index 256cb94..042927c 100644 --- a/include/binder/AppOpsManager.h +++ b/include/binder/AppOpsManager.h @@ -63,7 +63,35 @@ public: OP_ACCESS_NOTIFICATIONS = 25, OP_CAMERA = 26, OP_RECORD_AUDIO = 27, - OP_PLAY_AUDIO = 28 + OP_PLAY_AUDIO = 28, + OP_READ_CLIPBOARD = 29, + OP_WRITE_CLIPBOARD = 30, + OP_TAKE_MEDIA_BUTTONS = 31, + OP_TAKE_AUDIO_FOCUS = 32, + OP_AUDIO_MASTER_VOLUME = 33, + OP_AUDIO_VOICE_VOLUME = 34, + OP_AUDIO_RING_VOLUME = 35, + OP_AUDIO_MEDIA_VOLUME = 36, + OP_AUDIO_ALARM_VOLUME = 37, + OP_AUDIO_NOTIFICATION_VOLUME = 38, + OP_AUDIO_BLUETOOTH_VOLUME = 39, + OP_WAKE_LOCK = 40, + OP_MONITOR_LOCATION = 41, + OP_MONITOR_HIGH_POWER_LOCATION = 42, + OP_GET_USAGE_STATS = 43, + OP_MUTE_MICROPHONE = 44, + OP_TOAST_WINDOW = 45, + OP_PROJECT_MEDIA = 46, + OP_ACTIVATE_VPN = 47, + OP_WRITE_WALLPAPER = 48, + OP_ASSIST_STRUCTURE = 49, + OP_ASSIST_SCREENSHOT = 50, + OP_READ_PHONE_STATE = 51, + OP_ADD_VOICEMAIL = 52, + OP_USE_SIP = 53, + OP_PROCESS_OUTGOING_CALLS = 54, + OP_USE_FINGERPRINT = 55, + OP_BODY_SENSORS = 56 }; AppOpsManager(); @@ -75,6 +103,7 @@ public: void startWatchingMode(int32_t op, const String16& packageName, const sp<IAppOpsCallback>& callback); void stopWatchingMode(const sp<IAppOpsCallback>& callback); + int32_t permissionToOpCode(const String16& permission); private: Mutex mLock; diff --git a/include/binder/IAppOpsService.h b/include/binder/IAppOpsService.h index 193e9cc..cd81efa 100644 --- a/include/binder/IAppOpsService.h +++ b/include/binder/IAppOpsService.h @@ -40,6 +40,7 @@ public: const sp<IAppOpsCallback>& callback) = 0; virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0; virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0; + virtual int32_t permissionToOpCode(const String16& permission) = 0; enum { CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, @@ -49,6 +50,7 @@ public: START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, + PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, }; enum { diff --git a/include/binder/IBatteryStats.h b/include/binder/IBatteryStats.h index 7ddac57..5f38186 100644 --- a/include/binder/IBatteryStats.h +++ b/include/binder/IBatteryStats.h @@ -36,6 +36,12 @@ public: virtual void noteStopAudio(int uid) = 0; virtual void noteResetVideo() = 0; virtual void noteResetAudio() = 0; + virtual void noteFlashlightOn(int uid) = 0; + virtual void noteFlashlightOff(int uid) = 0; + virtual void noteStartCamera(int uid) = 0; + virtual void noteStopCamera(int uid) = 0; + virtual void noteResetCamera() = 0; + virtual void noteResetFlashlight() = 0; enum { NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, @@ -46,6 +52,12 @@ public: NOTE_STOP_AUDIO_TRANSACTION, NOTE_RESET_VIDEO_TRANSACTION, NOTE_RESET_AUDIO_TRANSACTION, + NOTE_FLASHLIGHT_ON_TRANSACTION, + NOTE_FLASHLIGHT_OFF_TRANSACTION, + NOTE_START_CAMERA_TRANSACTION, + NOTE_STOP_CAMERA_TRANSACTION, + NOTE_RESET_CAMERA_TRANSACTION, + NOTE_RESET_FLASHLIGHT_TRANSACTION }; }; diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h index 60c2242..1853cff 100644 --- a/include/binder/IPCThreadState.h +++ b/include/binder/IPCThreadState.h @@ -76,14 +76,18 @@ public: BpBinder* proxy); static void shutdown(); - + // Call this to disable switching threads to background scheduling when // receiving incoming IPC calls. This is specifically here for the // Android system process, since it expects to have background apps calling // in to it but doesn't want to acquire locks in its services while in // the background. static void disableBackgroundScheduling(bool disable); - + + // Call blocks until the number of executing binder threads is less than + // the maximum number of binder threads threads allowed for this process. + void blockUntilThreadAvailable(); + private: IPCThreadState(); ~IPCThreadState(); @@ -101,9 +105,9 @@ private: status_t getAndExecuteCommand(); status_t executeCommand(int32_t command); void processPendingDerefs(); - + void clearCaller(); - + static void threadDestructor(void *st); static void freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize, @@ -114,7 +118,7 @@ private: const pid_t mMyThreadId; Vector<BBinder*> mPendingStrongDerefs; Vector<RefBase::weakref_type*> mPendingWeakDerefs; - + Parcel mIn; Parcel mOut; status_t mLastError; diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h index f9d371b..4e5fb34 100644 --- a/include/binder/IPermissionController.h +++ b/include/binder/IPermissionController.h @@ -19,6 +19,7 @@ #define ANDROID_IPERMISSION_CONTROLLER_H #include <binder/IInterface.h> +#include <stdlib.h> namespace android { @@ -29,11 +30,16 @@ class IPermissionController : public IInterface public: DECLARE_META_INTERFACE(PermissionController); - virtual bool checkPermission(const String16& permission, - int32_t pid, int32_t uid) = 0; - + virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0; + + virtual void getPackagesForUid(const uid_t uid, Vector<String16> &packages) = 0; + + virtual bool isRuntimePermission(const String16& permission) = 0; + enum { - CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, + GET_PACKAGES_FOR_UID_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 1, + IS_RUNTIME_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 2 }; }; diff --git a/include/binder/IProcessInfoService.h b/include/binder/IProcessInfoService.h new file mode 100644 index 0000000..dc62f45 --- /dev/null +++ b/include/binder/IProcessInfoService.h @@ -0,0 +1,53 @@ +/* + * Copyright 2015 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 ANDROID_I_PROCESS_INFO_SERVICE_H +#define ANDROID_I_PROCESS_INFO_SERVICE_H + +#include <binder/IInterface.h> + +namespace android { + +// ---------------------------------------------------------------------- + +class IProcessInfoService : public IInterface { +public: + DECLARE_META_INTERFACE(ProcessInfoService); + + virtual status_t getProcessStatesFromPids( size_t length, + /*in*/ int32_t* pids, + /*out*/ int32_t* states) = 0; + + enum { + GET_PROCESS_STATES_FROM_PIDS = IBinder::FIRST_CALL_TRANSACTION, + }; +}; + +// ---------------------------------------------------------------------- + +class BnProcessInfoService : public BnInterface<IProcessInfoService> { +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +// ---------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_I_PROCESS_INFO_SERVICE_H diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index a52e044..3ada1e9 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -60,6 +60,7 @@ public: status_t appendFrom(const Parcel *parcel, size_t start, size_t len); + bool allowFds() const; bool pushAllowFds(bool allowFds); void restoreAllowFds(bool lastValue); @@ -96,6 +97,7 @@ public: status_t writeInt32(int32_t val); status_t writeUint32(uint32_t val); status_t writeInt64(int64_t val); + status_t writeUint64(uint64_t val); status_t writeFloat(float val); status_t writeDouble(double val); status_t writeCString(const char* str); @@ -129,16 +131,18 @@ public: // will be closed once the parcel is destroyed. status_t writeDupFileDescriptor(int fd); - // Writes a raw fd and optional comm channel fd to the parcel as a ParcelFileDescriptor. - // A dup's of the fds are made, which will be closed once the parcel is destroyed. - // Null values are passed as -1. - status_t writeParcelFileDescriptor(int fd, int commChannel = -1); - // Writes a blob to the parcel. // If the blob is small, then it is stored in-place, otherwise it is - // transferred by way of an anonymous shared memory region. + // transferred by way of an anonymous shared memory region. Prefer sending + // immutable blobs if possible since they may be subsequently transferred between + // processes without further copying whereas mutable blobs always need to be copied. // The caller should call release() on the blob after writing its contents. - status_t writeBlob(size_t len, WritableBlob* outBlob); + status_t writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob); + + // Write an existing immutable blob file descriptor to the parcel. + // This allows the client to send the same blob to multiple processes + // as long as it keeps a dup of the blob file descriptor handy for later. + status_t writeDupImmutableBlobFileDescriptor(int fd); status_t writeObject(const flat_binder_object& val, bool nullMetaData); @@ -157,6 +161,8 @@ public: status_t readUint32(uint32_t *pArg) const; int64_t readInt64() const; status_t readInt64(int64_t *pArg) const; + uint64_t readUint64() const; + status_t readUint64(uint64_t *pArg) const; float readFloat() const; status_t readFloat(float *pArg) const; double readDouble() const; @@ -195,11 +201,6 @@ public: // in the parcel, which you do not own -- use dup() to get your own copy. int readFileDescriptor() const; - // Reads a ParcelFileDescriptor from the parcel. Returns the raw fd as - // the result, and the optional comm channel fd in outCommChannel. - // Null values are returned as -1. - int readParcelFileDescriptor(int& outCommChannel) const; - // Reads a blob from the parcel. // The caller should call release() on the blob after reading its contents. status_t readBlob(size_t len, ReadableBlob* outBlob) const; @@ -277,16 +278,19 @@ private: Blob(); ~Blob(); + void clear(); void release(); inline size_t size() const { return mSize; } + inline int fd() const { return mFd; }; + inline bool isMutable() const { return mMutable; } protected: - void init(bool mapped, void* data, size_t size); - void clear(); + void init(int fd, void* data, size_t size, bool isMutable); - bool mMapped; + int mFd; // owned by parcel so not closed when released void* mData; size_t mSize; + bool mMutable; }; class FlattenableHelperInterface { @@ -327,6 +331,7 @@ public: friend class Parcel; public: inline const void* data() const { return mData; } + inline void* mutableData() { return isMutable() ? mData : NULL; } }; class WritableBlob : public Blob { @@ -334,6 +339,12 @@ public: public: inline void* data() { return mData; } }; + +private: + size_t mBlobAshmemSize; + +public: + size_t getBlobAshmemSize() const; }; // --------------------------------------------------------------------------- diff --git a/include/binder/ProcessInfoService.h b/include/binder/ProcessInfoService.h new file mode 100644 index 0000000..c5ead20 --- /dev/null +++ b/include/binder/ProcessInfoService.h @@ -0,0 +1,65 @@ +/* + * Copyright 2015 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 ANDROID_PROCESS_INFO_SERVICE_H +#define ANDROID_PROCESS_INFO_SERVICE_H + +#include <binder/IProcessInfoService.h> +#include <utils/Errors.h> +#include <utils/Singleton.h> +#include <sys/types.h> + +namespace android { + +// ---------------------------------------------------------------------- + +class ProcessInfoService : public Singleton<ProcessInfoService> { + + friend class Singleton<ProcessInfoService>; + sp<IProcessInfoService> mProcessInfoService; + Mutex mProcessInfoLock; + + ProcessInfoService(); + + status_t getProcessStatesImpl(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states); + void updateBinderLocked(); + + static const int BINDER_ATTEMPT_LIMIT = 5; + +public: + + /** + * For each PID in the given "pids" input array, write the current process state + * for that process into the "states" output array, or + * ActivityManager.PROCESS_STATE_NONEXISTENT * to indicate that no process with the given PID + * exists. + * + * Returns NO_ERROR if this operation was successful, or a negative error code otherwise. + */ + static status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids, + /*out*/ int32_t* states) { + return ProcessInfoService::getInstance().getProcessStatesImpl(length, /*in*/ pids, + /*out*/ states); + } + +}; + +// ---------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_PROCESS_INFO_SERVICE_H + diff --git a/include/binder/ProcessState.h b/include/binder/ProcessState.h index 3bc978d..f9edc2a 100644 --- a/include/binder/ProcessState.h +++ b/include/binder/ProcessState.h @@ -24,6 +24,8 @@ #include <utils/threads.h> +#include <pthread.h> + // --------------------------------------------------------------------------- namespace android { @@ -71,25 +73,33 @@ private: ProcessState(const ProcessState& o); ProcessState& operator=(const ProcessState& o); String8 makeBinderThreadName(); - + struct handle_entry { IBinder* binder; RefBase::weakref_type* refs; }; - + handle_entry* lookupHandleLocked(int32_t handle); int mDriverFD; void* mVMStart; - + + // Protects thread count variable below. + pthread_mutex_t mThreadCountLock; + pthread_cond_t mThreadCountDecrement; + // Number of binder threads current executing a command. + size_t mExecutingThreadsCount; + // Maximum number for binder threads allowed for this process. + size_t mMaxThreads; + mutable Mutex mLock; // protects everything below. - + Vector<handle_entry>mHandleToObject; bool mManagesContexts; context_check_func mBinderContextCheckFunc; void* mBinderContextUserData; - + KeyedVector<String16, sp<IBinder> > mContexts; diff --git a/include/gui/BufferItem.h b/include/gui/BufferItem.h index 000ef0e..145efe6 100644 --- a/include/gui/BufferItem.h +++ b/include/gui/BufferItem.h @@ -72,7 +72,13 @@ class BufferItem : public Flattenable<BufferItem> { // to set by queueBuffer each time this slot is queued. This value // is guaranteed to be monotonically increasing for each newly // acquired buffer. - int64_t mTimestamp; + union { + int64_t mTimestamp; + struct { + uint32_t mTimestampLo; + uint32_t mTimestampHi; + }; + }; // mIsAutoTimestamp indicates whether mTimestamp was generated // automatically when the buffer was queued. @@ -84,7 +90,13 @@ class BufferItem : public Flattenable<BufferItem> { android_dataspace mDataSpace; // mFrameNumber is the number of the queued frame for this slot. - uint64_t mFrameNumber; + union { + uint64_t mFrameNumber; + struct { + uint32_t mFrameNumberLo; + uint32_t mFrameNumberHi; + }; + }; union { // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT). diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h index 930fabf..56c7a3f 100644 --- a/include/gui/BufferItemConsumer.h +++ b/include/gui/BufferItemConsumer.h @@ -86,21 +86,6 @@ class BufferItemConsumer: public ConsumerBase status_t releaseBuffer(const BufferItem &item, const sp<Fence>& releaseFence = Fence::NO_FENCE); - // setDefaultBufferSize is used to set the size of buffers returned by - // requestBuffers when a with and height of zero is requested. - status_t setDefaultBufferSize(uint32_t w, uint32_t h); - - // setDefaultBufferFormat allows the BufferQueue to create - // GraphicBuffers of a defaultFormat if no format is specified - // in dequeueBuffer - status_t setDefaultBufferFormat(PixelFormat defaultFormat); - - // setDefaultBufferDataSpace allows the BufferQueue to create - // GraphicBuffers of a defaultDataSpace if no data space is specified - // in queueBuffer. - // The initial default is HAL_DATASPACE_UNKNOWN - status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); - }; } // namespace android diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 721b218..09300a2 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -62,9 +62,10 @@ public: public: ProxyConsumerListener(const wp<ConsumerListener>& consumerListener); virtual ~ProxyConsumerListener(); - virtual void onFrameAvailable(const BufferItem& item); - virtual void onBuffersReleased(); - virtual void onSidebandStreamChanged(); + virtual void onFrameAvailable(const BufferItem& item) override; + virtual void onFrameReplaced(const BufferItem& item) override; + virtual void onBuffersReleased() override; + virtual void onSidebandStreamChanged() override; private: // mConsumerListener is a weak reference to the IConsumerListener. This is // the raison d'etre of ProxyConsumerListener. diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h index 9c91fc7..cde302f 100644 --- a/include/gui/BufferQueueConsumer.h +++ b/include/gui/BufferQueueConsumer.h @@ -47,7 +47,7 @@ public: // returned. The presentation time is in nanoseconds, and the time base // is CLOCK_MONOTONIC. virtual status_t acquireBuffer(BufferItem* outBuffer, - nsecs_t expectedPresent); + nsecs_t expectedPresent, uint64_t maxFrameNumber = 0) override; // See IGraphicBufferConsumer::detachBuffer virtual status_t detachBuffer(int slot); diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h index 9a43516..99134ea 100644 --- a/include/gui/BufferQueueCore.h +++ b/include/gui/BufferQueueCore.h @@ -270,6 +270,16 @@ private: // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // new buffers bool mAllowAllocation; + + // mBufferAge tracks the age of the contents of the most recently dequeued + // buffer as the number of frames that have elapsed since it was last queued + uint64_t mBufferAge; + + // mGenerationNumber stores the current generation number of the attached + // producer. Any attempt to attach a buffer with a different generation + // number will fail. + uint32_t mGenerationNumber; + }; // class BufferQueueCore } // namespace android diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h index ed660fb..9754a89 100644 --- a/include/gui/BufferQueueProducer.h +++ b/include/gui/BufferQueueProducer.h @@ -175,6 +175,12 @@ public: // See IGraphicBufferProducer::allowAllocation virtual status_t allowAllocation(bool allow); + // See IGraphicBufferProducer::setGenerationNumber + virtual status_t setGenerationNumber(uint32_t generationNumber); + + // See IGraphicBufferProducer::getConsumerName + virtual String8 getConsumerName() const override; + private: // This is required by the IBinder::DeathRecipient interface virtual void binderDied(const wp<IBinder>& who); diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index d56fa89..9307a26 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -38,15 +38,9 @@ class ConsumerBase : public virtual RefBase, protected ConsumerListener { public: struct FrameAvailableListener : public virtual RefBase { - // onFrameAvailable() is called each time an additional frame becomes - // available for consumption. This means that frames that are queued - // while in asynchronous mode only trigger the callback if no previous - // frames are pending. Frames queued while in synchronous mode always - // trigger the callback. - // - // This is called without any lock held and can be called concurrently - // by multiple threads. + // See IConsumerListener::onFrame{Available,Replaced} virtual void onFrameAvailable(const BufferItem& item) = 0; + virtual void onFrameReplaced(const BufferItem& /* item */) {} }; virtual ~ConsumerBase(); @@ -62,6 +56,9 @@ public: // or by OpenGL ES as a texture) then those buffer will remain allocated. void abandon(); + // Returns true if the ConsumerBase is in the 'abandoned' state + bool isAbandoned(); + // set the name of the ConsumerBase that will be used to identify it in // log messages. void setName(const String8& name); @@ -79,6 +76,15 @@ public: // See IGraphicBufferConsumer::detachBuffer status_t detachBuffer(int slot); + // See IGraphicBufferConsumer::setDefaultBufferSize + status_t setDefaultBufferSize(uint32_t width, uint32_t height); + + // See IGraphicBufferConsumer::setDefaultBufferFormat + status_t setDefaultBufferFormat(PixelFormat defaultFormat); + + // See IGraphicBufferConsumer::setDefaultBufferDataSpace + status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); + private: ConsumerBase(const ConsumerBase&); void operator=(const ConsumerBase&); @@ -104,14 +110,16 @@ protected: // Implementation of the IConsumerListener interface. These // calls are used to notify the ConsumerBase of asynchronous events in the - // BufferQueue. The onFrameAvailable and onBuffersReleased methods should - // not need to be overridden by derived classes, but if they are overridden - // the ConsumerBase implementation must be called from the derived class. - // The ConsumerBase version of onSidebandStreamChanged does nothing and can - // be overriden by derived classes if they want the notification. - virtual void onFrameAvailable(const BufferItem& item); - virtual void onBuffersReleased(); - virtual void onSidebandStreamChanged(); + // BufferQueue. The onFrameAvailable, onFrameReplaced, and + // onBuffersReleased methods should not need to be overridden by derived + // classes, but if they are overridden the ConsumerBase implementation must + // be called from the derived class. The ConsumerBase version of + // onSidebandStreamChanged does nothing and can be overriden by derived + // classes if they want the notification. + virtual void onFrameAvailable(const BufferItem& item) override; + virtual void onFrameReplaced(const BufferItem& item) override; + virtual void onBuffersReleased() override; + virtual void onSidebandStreamChanged() override; // freeBufferLocked frees up the given buffer slot. If the slot has been // initialized this will release the reference to the GraphicBuffer in that @@ -156,7 +164,8 @@ protected: // initialization that must take place the first time a buffer is assigned // to a slot. If it is overridden the derived class's implementation must // call ConsumerBase::acquireBufferLocked. - virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen); + virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen, + uint64_t maxFrameNumber = 0); // releaseBufferLocked relinquishes control over a buffer, returning that // control to the BufferQueue. diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h index c99ab29..3b07a31 100644 --- a/include/gui/CpuConsumer.h +++ b/include/gui/CpuConsumer.h @@ -80,23 +80,6 @@ class CpuConsumer : public ConsumerBase // log messages. void setName(const String8& name); - // setDefaultBufferSize is used to set the size of buffers returned by - // requestBuffers when a width and height of zero is requested. - // A call to setDefaultBufferSize() may trigger requestBuffers() to - // be called from the client. Default size is 1x1. - status_t setDefaultBufferSize(uint32_t width, uint32_t height); - - // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers - // of a defaultFormat if no format is specified by producer. - // The initial default is PIXEL_FORMAT_RGBA_8888. - status_t setDefaultBufferFormat(PixelFormat defaultFormat); - - // setDefaultBufferDataSpace allows the BufferQueue to create - // GraphicBuffers of a defaultDataSpace if no data space is specified - // in queueBuffer. - // The initial default is HAL_DATASPACE_UNKNOWN - status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); - // Gets the next graphics buffer from the producer and locks it for CPU use, // filling out the passed-in locked buffer structure with the native pointer // and metadata. Returns BAD_VALUE if no new buffer is available, and diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h index 4912580..c35c7be 100644 --- a/include/gui/GLConsumer.h +++ b/include/gui/GLConsumer.h @@ -241,7 +241,8 @@ protected: // acquireBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase behavior. - virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen); + virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen, + uint64_t maxFrameNumber = 0) override; // releaseBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase. diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h index 8f31b55..60ec9cc 100644 --- a/include/gui/IGraphicBufferConsumer.h +++ b/include/gui/IGraphicBufferConsumer.h @@ -69,6 +69,12 @@ public: // returned. The presentation time is in nanoseconds, and the time base // is CLOCK_MONOTONIC. // + // If maxFrameNumber is non-zero, it indicates that acquireBuffer should + // only return a buffer with a frame number less than or equal to + // maxFrameNumber. If no such frame is available (such as when a buffer has + // been replaced but the consumer has not received the onFrameReplaced + // callback), then PRESENT_LATER will be returned. + // // Return of NO_ERROR means the operation completed as normal. // // Return of a positive value means the operation could not be completed @@ -78,7 +84,8 @@ public: // // Return of a negative value means an error has occurred: // * INVALID_OPERATION - too many buffers have been acquired - virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen) = 0; + virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen, + uint64_t maxFrameNumber = 0) = 0; // detachBuffer attempts to remove all ownership of the buffer in the given // slot from the buffer queue. If this call succeeds, the slot will be @@ -103,7 +110,8 @@ public: // will be deallocated as stale. // // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - outSlot or buffer were NULL + // * BAD_VALUE - outSlot or buffer were NULL, or the generation number of + // the buffer did not match the buffer queue. // * INVALID_OPERATION - cannot attach the buffer because it would cause too // many buffers to be acquired. // * NO_MEMORY - no free slots available diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h index 5c50b2b..9530de1 100644 --- a/include/gui/IGraphicBufferProducer.h +++ b/include/gui/IGraphicBufferProducer.h @@ -218,8 +218,9 @@ public: // // Return of a negative value means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - outSlot or buffer were NULL or invalid combination of - // async mode and buffer count override. + // * BAD_VALUE - outSlot or buffer were NULL, invalid combination of + // async mode and buffer count override, or the generation + // number of the buffer did not match the buffer queue. // * INVALID_OPERATION - cannot attach the buffer because it would cause // too many buffers to be dequeued, either because // the producer already has a single buffer dequeued @@ -470,6 +471,18 @@ public: // eligible slot is available, dequeueBuffer will block or return an error // as usual. virtual status_t allowAllocation(bool allow) = 0; + + // Sets the current generation number of the BufferQueue. + // + // This generation number will be inserted into any buffers allocated by the + // BufferQueue, and any attempts to attach a buffer with a different + // generation number will fail. Buffers already in the queue are not + // affected and will retain their current generation number. The generation + // number defaults to 0. + virtual status_t setGenerationNumber(uint32_t generationNumber) = 0; + + // Returns the name of the connected consumer. + virtual String8 getConsumerName() const = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h index 9c8afc5..3dca2a3 100644 --- a/include/gui/ISensorServer.h +++ b/include/gui/ISensorServer.h @@ -30,14 +30,17 @@ namespace android { class Sensor; class ISensorEventConnection; +class String8; class ISensorServer : public IInterface { public: DECLARE_META_INTERFACE(SensorServer); - virtual Vector<Sensor> getSensorList() = 0; - virtual sp<ISensorEventConnection> createSensorEventConnection() = 0; + virtual Vector<Sensor> getSensorList(const String16& opPackageName) = 0; + virtual sp<ISensorEventConnection> createSensorEventConnection(const String8& packageName, + int mode, const String16& opPackageName) = 0; + virtual int32_t isDataInjectionEnabled() = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h index 27a215e..8142be6 100644 --- a/include/gui/Sensor.h +++ b/include/gui/Sensor.h @@ -71,6 +71,8 @@ public: uint32_t getFifoMaxEventCount() const; const String8& getStringType() const; const String8& getRequiredPermission() const; + bool isRequiredPermissionRuntime() const; + int32_t getRequiredAppOp() const; int32_t getMaxDelay() const; uint32_t getFlags() const; bool isWakeUpSensor() const; @@ -97,6 +99,8 @@ private: uint32_t mFifoMaxEventCount; String8 mStringType; String8 mRequiredPermission; + bool mRequiredPermissionRuntime = false; + int32_t mRequiredAppOp; int32_t mMaxDelay; uint32_t mFlags; static void flattenString8(void*& buffer, size_t& size, const String8& string8); diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h index 02b3d38..e5b9fc5 100644 --- a/include/gui/SensorEventQueue.h +++ b/include/gui/SensorEventQueue.h @@ -23,6 +23,7 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> +#include <utils/String16.h> #include <gui/BitTube.h> @@ -52,7 +53,7 @@ public: enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 }; - SensorEventQueue(const sp<ISensorEventConnection>& connection); + SensorEventQueue(const sp<ISensorEventConnection>& connection); virtual ~SensorEventQueue(); virtual void onFirstRef(); @@ -77,6 +78,8 @@ public: status_t flush() const; // Send an ack for every wake_up sensor event that is set to WAKE_UP_SENSOR_EVENT_NEEDS_ACK. void sendAck(const ASensorEvent* events, int count); + + status_t injectSensorEvent(const ASensorEvent& event); private: sp<Looper> getLooper() const; sp<ISensorEventConnection> mSensorEventConnection; diff --git a/include/gui/SensorManager.h b/include/gui/SensorManager.h index 3176462..3796067 100644 --- a/include/gui/SensorManager.h +++ b/include/gui/SensorManager.h @@ -17,15 +17,20 @@ #ifndef ANDROID_GUI_SENSOR_MANAGER_H #define ANDROID_GUI_SENSOR_MANAGER_H +#include <map> + #include <stdint.h> #include <sys/types.h> #include <binder/IBinder.h> +#include <binder/IPCThreadState.h> +#include <binder/IServiceManager.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Singleton.h> #include <utils/Vector.h> +#include <utils/String8.h> #include <gui/SensorEventQueue.h> @@ -40,20 +45,69 @@ namespace android { class ISensorServer; class Sensor; class SensorEventQueue; - // ---------------------------------------------------------------------------- class SensorManager : - public ASensorManager, - public Singleton<SensorManager> + public ASensorManager { public: - SensorManager(); + static SensorManager& getInstanceForPackage(const String16& packageName) { + Mutex::Autolock _l(sLock); + + SensorManager* sensorManager; + std::map<String16, SensorManager*>::iterator iterator = + sPackageInstances.find(packageName); + + if (iterator != sPackageInstances.end()) { + sensorManager = iterator->second; + } else { + String16 opPackageName = packageName; + + // It is possible that the calling code has no access to the package name. + // In this case we will get the packages for the calling UID and pick the + // first one for attributing the app op. This will work correctly for + // runtime permissions as for legacy apps we will toggle the app op for + // all packages in the UID. The caveat is that the operation may be attributed + // to the wrong package and stats based on app ops may be slightly off. + if (opPackageName.size() <= 0) { + sp<IBinder> binder = defaultServiceManager()->getService(String16("permission")); + if (binder != 0) { + const uid_t uid = IPCThreadState::self()->getCallingUid(); + Vector<String16> packages; + interface_cast<IPermissionController>(binder)->getPackagesForUid(uid, packages); + if (!packages.isEmpty()) { + opPackageName = packages[0]; + } else { + ALOGE("No packages for calling UID"); + } + } else { + ALOGE("Cannot get permission service"); + } + } + + sensorManager = new SensorManager(opPackageName); + + // If we had no package name, we looked it up from the UID and the sensor + // manager instance we created should also be mapped to the empty package + // name, to avoid looking up the packages for a UID and get the same result. + if (packageName.size() <= 0) { + sPackageInstances.insert(std::make_pair(String16(), sensorManager)); + } + + // Stash the per package sensor manager. + sPackageInstances.insert(std::make_pair(opPackageName, sensorManager)); + } + + return *sensorManager; + } + + SensorManager(const String16& opPackageName); ~SensorManager(); ssize_t getSensorList(Sensor const* const** list) const; Sensor const* getDefaultSensor(int type); - sp<SensorEventQueue> createEventQueue(); + sp<SensorEventQueue> createEventQueue(String8 packageName = String8(""), int mode = 0); + bool isDataInjectionEnabled(); private: // DeathRecipient interface @@ -62,11 +116,15 @@ private: status_t assertStateLocked() const; private: + static Mutex sLock; + static std::map<String16, SensorManager*> sPackageInstances; + mutable Mutex mLock; mutable sp<ISensorServer> mSensorServer; mutable Sensor const** mSensorList; mutable Vector<Sensor> mSensors; mutable sp<IBinder::DeathRecipient> mDeathObserver; + const String16 mOpPackageName; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/Surface.h b/include/gui/Surface.h index a9f78cf..72f1067 100644 --- a/include/gui/Surface.h +++ b/include/gui/Surface.h @@ -101,6 +101,14 @@ public: */ void allocateBuffers(); + /* Sets the generation number on the IGraphicBufferProducer and updates the + * generation number on any buffers attached to the Surface after this call. + * See IGBP::setGenerationNumber for more information. */ + status_t setGenerationNumber(uint32_t generationNumber); + + // See IGraphicBufferProducer::getConsumerName + String8 getConsumerName() const; + protected: virtual ~Surface(); @@ -179,7 +187,7 @@ public: virtual int unlockAndPost(); virtual int connect(int api, const sp<IProducerListener>& listener); - virtual int detachNextBuffer(ANativeWindowBuffer** outBuffer, + virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence); virtual int attachBuffer(ANativeWindowBuffer*); @@ -305,6 +313,10 @@ private: // When a non-CPU producer is attached, this reflects the surface damage // (the change since the previous frame) passed in by the producer. Region mDirtyRegion; + + // Stores the current generation number. See setGenerationNumber and + // IGraphicBufferProducer::setGenerationNumber for more information. + uint32_t mGenerationNumber; }; }; // namespace android diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h new file mode 100644 index 0000000..629310f --- /dev/null +++ b/include/input/IInputFlinger.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2013 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 _LIBINPUT_IINPUT_FLINGER_H +#define _LIBINPUT_IINPUT_FLINGER_H + +#include <stdint.h> +#include <sys/types.h> + +#include <binder/IInterface.h> + +namespace android { + +/* + * This class defines the Binder IPC interface for accessing various + * InputFlinger features. + */ +class IInputFlinger : public IInterface { +public: + DECLARE_META_INTERFACE(InputFlinger); +}; + + +/** + * Binder implementation. + */ +class BnInputFlinger : public BnInterface<IInputFlinger> { +public: + enum { + DO_SOMETHING_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, + }; + + virtual status_t onTransact(uint32_t code, const Parcel& data, + Parcel* reply, uint32_t flags = 0); +}; + +} // namespace android + +#endif // _LIBINPUT_IINPUT_FLINGER_H diff --git a/include/input/Input.h b/include/input/Input.h index b067a6b..92b3d36 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -384,6 +384,12 @@ public: inline int32_t getButtonState() const { return mButtonState; } + inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; } + + inline int32_t getActionButton() const { return mActionButton; } + + inline void setActionButton(int32_t button) { mActionButton = button; } + inline float getXOffset() const { return mXOffset; } inline float getYOffset() const { return mYOffset; } @@ -537,6 +543,7 @@ public: int32_t deviceId, int32_t source, int32_t action, + int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState, @@ -589,6 +596,7 @@ public: protected: int32_t mAction; + int32_t mActionButton; int32_t mFlags; int32_t mEdgeFlags; int32_t mMetaState; diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index adf9fb9..1ea69d3 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -73,7 +73,8 @@ public: }; void initialize(int32_t id, int32_t generation, int32_t controllerNumber, - const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal); + const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal, + bool hasMic); inline int32_t getId() const { return mId; } inline int32_t getControllerNumber() const { return mControllerNumber; } @@ -84,6 +85,7 @@ public: return mAlias.isEmpty() ? mIdentifier.name : mAlias; } inline bool isExternal() const { return mIsExternal; } + inline bool hasMic() const { return mHasMic; } inline uint32_t getSources() const { return mSources; } const MotionRange* getMotionRange(int32_t axis, uint32_t source) const; @@ -121,6 +123,7 @@ private: InputDeviceIdentifier mIdentifier; String8 mAlias; bool mIsExternal; + bool mHasMic; uint32_t mSources; int32_t mKeyboardType; sp<KeyCharacterMap> mKeyCharacterMap; diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h index 8a339f7..a7a9329 100644 --- a/include/input/InputEventLabels.h +++ b/include/input/InputEventLabels.h @@ -299,10 +299,14 @@ static const InputEventLabel KEYCODES[] = { DEFINE_KEYCODE(TV_MEDIA_CONTEXT_MENU), DEFINE_KEYCODE(TV_TIMER_PROGRAMMING), DEFINE_KEYCODE(HELP), - DEFINE_KEYCODE(STEM_PRIMARY), - DEFINE_KEYCODE(STEM_1), - DEFINE_KEYCODE(STEM_2), - DEFINE_KEYCODE(STEM_3), + DEFINE_KEYCODE(NAVIGATE_PREVIOUS), + DEFINE_KEYCODE(NAVIGATE_NEXT), + DEFINE_KEYCODE(NAVIGATE_IN), + DEFINE_KEYCODE(NAVIGATE_OUT), + DEFINE_KEYCODE(MEDIA_SKIP_FORWARD), + DEFINE_KEYCODE(MEDIA_SKIP_BACKWARD), + DEFINE_KEYCODE(MEDIA_STEP_FORWARD), + DEFINE_KEYCODE(MEDIA_STEP_BACKWARD), { NULL, 0 } }; diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h index e7e383b..f31bcea 100644 --- a/include/input/InputTransport.h +++ b/include/input/InputTransport.h @@ -84,6 +84,7 @@ struct InputMessage { int32_t deviceId; int32_t source; int32_t action; + int32_t actionButton; int32_t flags; int32_t metaState; int32_t buttonState; @@ -95,7 +96,7 @@ struct InputMessage { float yPrecision; uint32_t pointerCount; // Note that PointerCoords requires 8 byte alignment. - struct Pointer{ + struct Pointer { PointerProperties properties; PointerCoords coords; } pointers[MAX_POINTERS]; @@ -232,6 +233,7 @@ public: int32_t deviceId, int32_t source, int32_t action, + int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState, diff --git a/include/media/drm/DrmAPI.h b/include/media/drm/DrmAPI.h index 49939fd..272881b 100644 --- a/include/media/drm/DrmAPI.h +++ b/include/media/drm/DrmAPI.h @@ -80,7 +80,10 @@ namespace android { kDrmPluginEventProvisionRequired = 1, kDrmPluginEventKeyNeeded, kDrmPluginEventKeyExpired, - kDrmPluginEventVendorDefined + kDrmPluginEventVendorDefined, + kDrmPluginEventSessionReclaimed, + kDrmPluginEventExpirationUpdate, + kDrmPluginEventKeysChange, }; // Drm keys can be for offline content or for online streaming. @@ -93,6 +96,33 @@ namespace android { kKeyType_Release }; + // Enumerate KeyRequestTypes to allow an app to determine the + // type of a key request returned from getKeyRequest. + enum KeyRequestType { + kKeyRequestType_Unknown, + kKeyRequestType_Initial, + kKeyRequestType_Renewal, + kKeyRequestType_Release + }; + + // Enumerate KeyStatusTypes which indicate the state of a key + enum KeyStatusType + { + kKeyStatusType_Usable, + kKeyStatusType_Expired, + kKeyStatusType_OutputNotAllowed, + kKeyStatusType_StatusPending, + kKeyStatusType_InternalError + }; + + // Used by sendKeysChange to report the usability status of each + // key to the app. + struct KeyStatus + { + Vector<uint8_t> mKeyId; + KeyStatusType mType; + }; + DrmPlugin() {} virtual ~DrmPlugin() {} @@ -135,7 +165,8 @@ namespace android { Vector<uint8_t> const &initData, String8 const &mimeType, KeyType keyType, KeyedVector<String8, String8> const &optionalParameters, - Vector<uint8_t> &request, String8 &defaultUrl) = 0; + Vector<uint8_t> &request, String8 &defaultUrl, + KeyRequestType *keyRequestType) = 0; // // After a key response is received by the app, it is provided to the @@ -315,11 +346,18 @@ namespace android { } protected: - // Plugins call sendEvent to deliver events to the java app + // Plugins call these methods to deliver events to the java app void sendEvent(EventType eventType, int extra, Vector<uint8_t> const *sessionId, Vector<uint8_t> const *data); + void sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS); + + void sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey); + private: Mutex mEventLock; sp<DrmPluginListener> mListener; @@ -331,14 +369,20 @@ namespace android { { public: virtual void sendEvent(DrmPlugin::EventType eventType, int extra, - Vector<uint8_t> const *sesionId, + Vector<uint8_t> const *sessionId, Vector<uint8_t> const *data) = 0; + + virtual void sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS) = 0; + + virtual void sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey) = 0; }; inline void DrmPlugin::sendEvent(EventType eventType, int extra, Vector<uint8_t> const *sessionId, Vector<uint8_t> const *data) { - mEventLock.lock(); sp<DrmPluginListener> listener = mListener; mEventLock.unlock(); @@ -348,6 +392,28 @@ namespace android { } } + inline void DrmPlugin::sendExpirationUpdate(Vector<uint8_t> const *sessionId, + int64_t expiryTimeInMS) { + mEventLock.lock(); + sp<DrmPluginListener> listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendExpirationUpdate(sessionId, expiryTimeInMS); + } + } + + inline void DrmPlugin::sendKeysChange(Vector<uint8_t> const *sessionId, + Vector<DrmPlugin::KeyStatus> const *keyStatusList, + bool hasNewUsableKey) { + mEventLock.lock(); + sp<DrmPluginListener> listener = mListener; + mEventLock.unlock(); + + if (listener != NULL) { + listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); + } + } } // namespace android #endif // DRM_API_H_ diff --git a/include/media/hardware/CryptoAPI.h b/include/media/hardware/CryptoAPI.h index c800825..3e3257f 100644 --- a/include/media/hardware/CryptoAPI.h +++ b/include/media/hardware/CryptoAPI.h @@ -14,7 +14,9 @@ * limitations under the License. */ +#include <media/stagefright/MediaErrors.h> #include <utils/Errors.h> +#include <utils/Vector.h> #ifndef CRYPTO_API_H_ @@ -68,7 +70,18 @@ struct CryptoPlugin { // the resolution of the video being decrypted. The media player should // call this method when the resolution is determined and any time it // is subsequently changed. - virtual void notifyResolution(uint32_t width, uint32_t height) {} + + virtual void notifyResolution(uint32_t /* width */, uint32_t /* height */) {} + + // A MediaDrm session may be associated with a MediaCrypto session. The + // associated MediaDrm session is used to load decryption keys + // into the crypto/drm plugin. The keys are then referenced by key-id + // in the 'key' parameter to the decrypt() method. + // Should return NO_ERROR on success, ERROR_DRM_SESSION_NOT_OPENED if + // the session is not opened and a code from MediaErrors.h otherwise. + virtual status_t setMediaDrmSession(const Vector<uint8_t> & /*sessionId */) { + return ERROR_UNSUPPORTED; + } // If the error returned falls into the range // ERROR_DRM_VENDOR_MIN..ERROR_DRM_VENDOR_MAX, errorDetailMsg should be diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h index d5f42be..1008c22 100644 --- a/include/media/hardware/HardwareAPI.h +++ b/include/media/hardware/HardwareAPI.h @@ -52,9 +52,9 @@ struct EnableAndroidNativeBuffersParams { OMX_BOOL enable; }; -// A pointer to this struct is passed to OMX_SetParameter() when the extension -// index "OMX.google.android.index.storeMetaDataInBuffers" -// is given. +// A pointer to this struct is passed to OMX_SetParameter() when the extension index +// "OMX.google.android.index.storeMetaDataInBuffers" or +// "OMX.google.android.index.storeANWBufferInMetadata" is given. // // When meta data is stored in the video buffers passed between OMX clients // and OMX components, interpretation of the buffer data is up to the @@ -62,19 +62,33 @@ struct EnableAndroidNativeBuffersParams { // some information helpful for the receiver to locate the actual data. // The buffer receiver thus needs to know how to interpret what is stored // in these buffers, with mechanisms pre-determined externally. How to -// interpret the meta data is outside of the scope of this method. +// interpret the meta data is outside of the scope of this parameter. +// +// Currently, this is used to pass meta data from video source (camera component, for instance) to +// video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output +// buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE. +// +// If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and +// the output buffers contain either real YUV frame data, or are themselves native handles as +// directed by enable/use-android-native-buffer parameter settings. +// In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension +// index, the component should not assume that the client is not using metadata mode for the port. // -// Currently, this is specifically used to pass meta data from video source -// (camera component, for instance) to video encoder to avoid memcpying of -// input video frame data. To do this, bStoreMetaData is set to OMX_TRUE. -// If bStoreMetaData is set to false, real YUV frame data will be stored -// in the buffers. In addition, if no OMX_SetParameter() call is made -// with the corresponding extension index, real YUV data is stored -// in the buffers. +// If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata" +// extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata +// layout as defined below. Each buffer will be accompanied by a fence. The fence must signal +// before the buffer can be used (e.g. read from or written into). When returning such buffer to +// the client, component must provide a new fence that must signal before the returned buffer can +// be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close +// it when fence has signaled. The client will own and close the returned fence file descriptor. // -// For video decoder output port, the metadata buffer layout is defined below. +// If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers" +// extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata +// (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed +// as "CameraSource", the layout of which is vendor dependent. // -// Metadata buffers are registered with the component using UseBuffer calls. +// Metadata buffers are registered with the component using UseBuffer calls, or can be allocated +// by the component for encoder-metadata-output buffers. struct StoreMetaDataInBuffersParams { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; @@ -84,9 +98,26 @@ struct StoreMetaDataInBuffersParams { // Meta data buffer layout used to transport output frames to the decoder for // dynamic buffer handling. -struct VideoDecoderOutputMetaData { - MetadataBufferType eType; - buffer_handle_t pHandle; +struct VideoGrallocMetadata { + MetadataBufferType eType; // must be kMetadataBufferTypeGrallocSource +#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS + OMX_PTR pHandle; +#else + buffer_handle_t pHandle; +#endif +}; + +// Legacy name for VideoGrallocMetadata struct. +struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {}; + +struct VideoNativeMetadata { + MetadataBufferType eType; // must be kMetadataBufferTypeANWBuffer +#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS + OMX_PTR pBuffer; +#else + struct ANativeWindowBuffer* pBuffer; +#endif + int nFenceFd; // -1 if unused }; // A pointer to this struct is passed to OMX_SetParameter() when the extension @@ -173,17 +204,17 @@ struct MediaImage { }; Type mType; - size_t mNumPlanes; // number of planes - size_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) - size_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) - size_t mBitDepth; // useable bit depth + uint32_t mNumPlanes; // number of planes + uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) + uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) + uint32_t mBitDepth; // useable bit depth struct PlaneInfo { - size_t mOffset; // offset of first pixel of the plane in bytes - // from buffer offset - size_t mColInc; // column increment in bytes - size_t mRowInc; // row increment in bytes - size_t mHorizSubsampling; // subsampling compared to the largest plane - size_t mVertSubsampling; // subsampling compared to the largest plane + uint32_t mOffset; // offset of first pixel of the plane in bytes + // from buffer offset + uint32_t mColInc; // column increment in bytes + uint32_t mRowInc; // row increment in bytes + uint32_t mHorizSubsampling; // subsampling compared to the largest plane + uint32_t mVertSubsampling; // subsampling compared to the largest plane }; PlaneInfo mPlane[MAX_NUM_PLANES]; }; diff --git a/include/media/hardware/MetadataBufferType.h b/include/media/hardware/MetadataBufferType.h index 5876c40..b765203 100644 --- a/include/media/hardware/MetadataBufferType.h +++ b/include/media/hardware/MetadataBufferType.h @@ -77,28 +77,43 @@ typedef enum { * GRalloc buffer. The encoder needs to interpret this GRalloc handle * and encode the frames. * -------------------------------------------------------------- - * | kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) | + * | kMetadataBufferTypeGrallocSource | buffer_handle_t buffer | * -------------------------------------------------------------- + * + * See the VideoGrallocMetadata structure. */ kMetadataBufferTypeGrallocSource = 1, /* * kMetadataBufferTypeGraphicBuffer is used to indicate that * the payload of the metadata buffers can be interpreted as - * a GraphicBuffer. It is only to be used by software encoders. - * In this case, the metadata that the encoder receives - * will have a byte stream that consists of two parts: + * an ANativeWindowBuffer, and that a fence is provided. + * + * In this case, the metadata will have a byte stream that consists of three parts: * 1. First, there is an integer indicating that the metadata - * contains a GraphicBuffer (kMetadataBufferTypeGraphicBuffer) - * 2. This is followed by the pointer to the GraphicBuffer that - * is to be encoded. Encoder must not create a sp<> from this - * graphic buffer, or free it, as it does not actually own this - * buffer. - * -------------------------------------------------------------- - * | kMetadataBufferTypeGraphicBuffer | sizeof(GraphicBuffer *) | - * -------------------------------------------------------------- + * contains an ANativeWindowBuffer (kMetadataBufferTypeANWBuffer) + * 2. This is followed by the pointer to the ANativeWindowBuffer. + * Codec must not free this buffer as it does not actually own this buffer. + * 3. Finally, there is an integer containing a fence file descriptor. + * The codec must wait on the fence before encoding or decoding into this + * buffer. When the buffer is returned, codec must replace this file descriptor + * with a new fence, that will be waited on before the buffer is replaced + * (encoder) or read (decoder). + * --------------------------------- + * | kMetadataBufferTypeANWBuffer | + * --------------------------------- + * | ANativeWindowBuffer *buffer | + * --------------------------------- + * | int fenceFd | + * --------------------------------- + * + * See the VideoNativeMetadata structure. */ - kMetadataBufferTypeGraphicBuffer = 2, + kMetadataBufferTypeANWBuffer = 2, + + /* This value is used by framework, but is never used inside a metadata buffer */ + kMetadataBufferTypeInvalid = -1, + // Add more here... diff --git a/include/media/openmax/OMX_AsString.h b/include/media/openmax/OMX_AsString.h index 0f177a1..ae8430d 100644 --- a/include/media/openmax/OMX_AsString.h +++ b/include/media/openmax/OMX_AsString.h @@ -287,6 +287,7 @@ inline static const char *asString(OMX_EVENTTYPE i, const char *def = "??") { // case OMX_EventComponentResumed: return "ComponentResumed"; // case OMX_EventDynamicResourcesAvailable: return "DynamicResourcesAvailable"; // case OMX_EventPortFormatDetected: return "PortFormatDetected"; + case OMX_EventOutputRendered: return "OutputRendered"; default: return def; } } @@ -521,6 +522,9 @@ inline static const char *asString(OMX_INDEXEXTTYPE i, const char *def = "??") { case OMX_IndexParamVideoHevc: return "ParamVideoHevc"; // case OMX_IndexParamSliceSegments: return "ParamSliceSegments"; case OMX_IndexConfigAutoFramerateConversion: return "ConfigAutoFramerateConversion"; + case OMX_IndexConfigPriority: return "ConfigPriority"; + case OMX_IndexConfigOperatingRate: return "ConfigOperatingRate"; + case OMX_IndexParamConsumerUsageBits: return "ParamConsumerUsageBits"; default: return asString((OMX_INDEXTYPE)i, def); } } diff --git a/include/media/openmax/OMX_Core.h b/include/media/openmax/OMX_Core.h index 12f2b3b..521c223 100644 --- a/include/media/openmax/OMX_Core.h +++ b/include/media/openmax/OMX_Core.h @@ -503,12 +503,24 @@ typedef enum OMX_EVENTTYPE OMX_EventResourcesAcquired, /**< component has been granted resources and is automatically starting the state change from OMX_StateWaitForResources to OMX_StateIdle. */ - OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ - OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ - OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ - OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_EventMax = 0x7FFFFFFF + OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ + OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ + OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ + OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + + /** Event when tunneled decoder has rendered an output + * nData1 must contain the number of timestamps returned + * pEventData must point to an array of the OMX_VIDEO_RENDEREVENTTYPE structs containing the + * render-timestamps of each frame. Component may batch rendered timestamps using this event, + * but must signal the event no more than 40ms after the first frame in the batch. The frames + * must be ordered by system timestamp inside and across batches. + * + * If component is doing frame-rate conversion, it must signal the render time of each + * converted frame, and must interpolate media timestamps for in-between frames. + */ + OMX_EventOutputRendered = 0x7F000001, + OMX_EventMax = 0x7FFFFFFF } OMX_EVENTTYPE; typedef struct OMX_CALLBACKTYPE diff --git a/include/media/openmax/OMX_IVCommon.h b/include/media/openmax/OMX_IVCommon.h index a5b9d18..f9b6f4b 100644 --- a/include/media/openmax/OMX_IVCommon.h +++ b/include/media/openmax/OMX_IVCommon.h @@ -157,6 +157,7 @@ typedef enum OMX_COLOR_FORMATTYPE { * an acceptable range once that is done. * */ OMX_COLOR_FormatAndroidOpaque = 0x7F000789, + OMX_COLOR_Format32BitRGBA8888 = 0x7F00A000, /** Flexible 8-bit YUV format. Codec should report this format * as being supported if it supports any YUV420 packed planar * or semiplanar formats. When port is set to use this format, diff --git a/include/media/openmax/OMX_IndexExt.h b/include/media/openmax/OMX_IndexExt.h index ea3d0da..25bea1f 100644 --- a/include/media/openmax/OMX_IndexExt.h +++ b/include/media/openmax/OMX_IndexExt.h @@ -83,6 +83,9 @@ typedef enum OMX_INDEXEXTTYPE { /* Other configurations */ OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000, OMX_IndexConfigAutoFramerateConversion, /**< reference: OMX_CONFIG_BOOLEANTYPE */ + OMX_IndexConfigPriority, /**< reference: OMX_PARAM_U32TYPE */ + OMX_IndexConfigOperatingRate, /**< reference: OMX_PARAM_U32TYPE in Q16 format for video and in Hz for audio */ + OMX_IndexParamConsumerUsageBits, /**< reference: OMX_PARAM_U32TYPE */ /* Time configurations */ OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000, diff --git a/include/media/openmax/OMX_VideoExt.h b/include/media/openmax/OMX_VideoExt.h index 3c97e14..34c0405 100644 --- a/include/media/openmax/OMX_VideoExt.h +++ b/include/media/openmax/OMX_VideoExt.h @@ -203,6 +203,12 @@ typedef struct OMX_VIDEO_SLICESEGMENTSTYPE { OMX_BOOL bEnableLoopFilterAcrossSlices; } OMX_VIDEO_SLICESEGMENTSTYPE; +/** Structure to return timestamps of rendered output frames for tunneled components */ +typedef struct OMX_VIDEO_RENDEREVENTTYPE { + OMX_S64 nMediaTimeUs; // timestamp of rendered video frame + OMX_S64 nSystemTimeNs; // system monotonic time at the time frame was rendered +} OMX_VIDEO_RENDEREVENTTYPE; + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h index 2fa6ff9..cbe8733 100644 --- a/include/private/gui/LayerState.h +++ b/include/private/gui/LayerState.h @@ -39,6 +39,7 @@ struct layer_state_t { enum { eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java eLayerOpaque = 0x02, // SURFACE_OPAQUE + eLayerSecure = 0x80, // SECURE }; enum { @@ -48,10 +49,9 @@ struct layer_state_t { eAlphaChanged = 0x00000008, eMatrixChanged = 0x00000010, eTransparentRegionChanged = 0x00000020, - eVisibilityChanged = 0x00000040, + eFlagsChanged = 0x00000040, eLayerStackChanged = 0x00000080, eCropChanged = 0x00000100, - eOpacityChanged = 0x00000200, }; layer_state_t() diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index f91d192..3da720f 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -94,6 +94,11 @@ public: Rect getBounds() const { return Rect(width, height); } uint64_t getId() const { return mId; } + uint32_t getGenerationNumber() const { return mGenerationNumber; } + void setGenerationNumber(uint32_t generation) { + mGenerationNumber = generation; + } + status_t reallocate(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage); @@ -166,6 +171,11 @@ private: sp<ANativeWindowBuffer> mWrappedBuffer; uint64_t mId; + + // Stores the generation number of this buffer. If this number does not + // match the BufferQueue's internal generation number (set through + // IGBP::setGenerationNumber), attempts to attach the buffer will fail. + uint32_t mGenerationNumber; }; }; // namespace android |