summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/android/configuration.h15
-rw-r--r--include/android/input.h9
-rw-r--r--include/android/keycodes.h10
-rw-r--r--include/android/multinetwork.h109
-rw-r--r--include/android/sensor.h17
-rw-r--r--include/android/trace.h55
-rw-r--r--include/binder/AppOpsManager.h31
-rw-r--r--include/binder/IAppOpsService.h2
-rw-r--r--include/binder/IBatteryStats.h12
-rw-r--r--include/binder/IInterface.h6
-rw-r--r--include/binder/IPCThreadState.h20
-rw-r--r--include/binder/IPermissionController.h14
-rw-r--r--include/binder/IProcessInfoService.h53
-rw-r--r--include/binder/Parcel.h44
-rw-r--r--include/binder/ProcessInfoService.h65
-rw-r--r--include/binder/ProcessState.h20
-rw-r--r--include/gui/BufferItem.h42
-rw-r--r--include/gui/BufferItemConsumer.h14
-rw-r--r--include/gui/BufferQueue.h11
-rw-r--r--include/gui/BufferQueueConsumer.h14
-rw-r--r--include/gui/BufferQueueCore.h54
-rw-r--r--include/gui/BufferQueueProducer.h20
-rw-r--r--include/gui/ConsumerBase.h47
-rw-r--r--include/gui/CpuConsumer.h21
-rw-r--r--include/gui/GLConsumer.h15
-rw-r--r--include/gui/GraphicBufferAlloc.h5
-rw-r--r--include/gui/IGraphicBufferAlloc.h8
-rw-r--r--include/gui/IGraphicBufferConsumer.h93
-rw-r--r--include/gui/IGraphicBufferProducer.h62
-rw-r--r--include/gui/ISensorServer.h7
-rw-r--r--include/gui/ISurfaceComposer.h3
-rw-r--r--include/gui/Sensor.h16
-rw-r--r--include/gui/SensorEventQueue.h5
-rw-r--r--include/gui/SensorManager.h68
-rw-r--r--include/gui/Surface.h73
-rw-r--r--include/gui/SurfaceComposerClient.h2
-rw-r--r--include/gui/SurfaceControl.h4
-rw-r--r--include/input/IInputFlinger.h52
-rw-r--r--include/input/Input.h33
-rw-r--r--include/input/InputDevice.h5
-rw-r--r--include/input/InputEventLabels.h9
-rw-r--r--include/input/InputTransport.h4
-rw-r--r--include/media/drm/DrmAPI.h76
-rw-r--r--include/media/hardware/CryptoAPI.h15
-rw-r--r--include/media/hardware/HardwareAPI.h83
-rw-r--r--include/media/hardware/MetadataBufferType.h41
-rw-r--r--include/media/openmax/OMX_AsString.h4
-rw-r--r--include/media/openmax/OMX_Core.h28
-rw-r--r--include/media/openmax/OMX_IVCommon.h1
-rw-r--r--include/media/openmax/OMX_IndexExt.h3
-rw-r--r--include/media/openmax/OMX_VideoExt.h13
-rw-r--r--include/private/gui/LayerState.h4
-rw-r--r--include/ui/Fence.h2
-rw-r--r--include/ui/FramebufferNativeWindow.h6
-rw-r--r--include/ui/GraphicBuffer.h58
-rw-r--r--include/ui/GraphicBufferAllocator.h41
-rw-r--r--include/ui/GraphicBufferMapper.h13
-rw-r--r--include/ui/PixelFormat.h9
-rw-r--r--include/ui/Rect.h19
-rw-r--r--include/ui/Region.h17
60 files changed, 1229 insertions, 373 deletions
diff --git a/include/android/configuration.h b/include/android/configuration.h
index be00066418..7573ccac33 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 a660761728..efbbb8558c 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 75d0ab69e6..de9e7354b5 100644
--- a/include/android/keycodes.h
+++ b/include/android/keycodes.h
@@ -302,7 +302,15 @@ enum {
AKEYCODE_TV_CONTENTS_MENU = 256,
AKEYCODE_TV_MEDIA_CONTEXT_MENU = 257,
AKEYCODE_TV_TIMER_PROGRAMMING = 258,
- AKEYCODE_HELP = 259
+ AKEYCODE_HELP = 259,
+ 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 0000000000..6c718c9037
--- /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 d58c4608c4..1be623221f 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 0000000000..e42e334102
--- /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 256cb949bb..042927c176 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 193e9cc0ec..cd81efa363 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 7ddac574b2..5f3818652b 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/IInterface.h b/include/binder/IInterface.h
index 5f9f69c042..4ce361380d 100644
--- a/include/binder/IInterface.h
+++ b/include/binder/IInterface.h
@@ -28,9 +28,9 @@ class IInterface : public virtual RefBase
{
public:
IInterface();
- sp<IBinder> asBinder();
- sp<const IBinder> asBinder() const;
-
+ static sp<IBinder> asBinder(const IInterface*);
+ static sp<IBinder> asBinder(const sp<IInterface>&);
+
protected:
virtual ~IInterface();
virtual IBinder* onAsBinder() = 0;
diff --git a/include/binder/IPCThreadState.h b/include/binder/IPCThreadState.h
index 6e0c01beac..1853cff235 100644
--- a/include/binder/IPCThreadState.h
+++ b/include/binder/IPCThreadState.h
@@ -22,7 +22,7 @@
#include <binder/ProcessState.h>
#include <utils/Vector.h>
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
typedef int uid_t;
#endif
@@ -39,8 +39,8 @@ public:
status_t clearLastError();
- int getCallingPid() const;
- int getCallingUid() const;
+ pid_t getCallingPid() const;
+ uid_t getCallingUid() const;
void setStrictModePolicy(int32_t policy);
int32_t getStrictModePolicy() const;
@@ -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 f9d371bd15..4e5fb34838 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 0000000000..dc62f457c7
--- /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 6a69761cf3..3ada1e9096 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);
@@ -94,7 +95,9 @@ public:
void* writeInplace(size_t len);
status_t writeUnpadded(const void* data, size_t len);
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);
@@ -128,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);
@@ -152,8 +157,12 @@ public:
const void* readInplace(size_t len) const;
int32_t readInt32() const;
status_t readInt32(int32_t *pArg) const;
+ uint32_t readUint32() const;
+ 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;
@@ -192,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;
@@ -274,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 {
@@ -324,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 {
@@ -331,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 0000000000..c5ead20676
--- /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 3bc978d9e9..f9edc2a691 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 01b6ff4b54..145efe6f60 100644
--- a/include/gui/BufferItem.h
+++ b/include/gui/BufferItem.h
@@ -20,9 +20,10 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <gui/IGraphicBufferConsumer.h>
-
#include <ui/Rect.h>
+#include <ui/Region.h>
+
+#include <system/graphics.h>
#include <utils/Flattenable.h>
#include <utils/StrongPointer.h>
@@ -45,7 +46,6 @@ class BufferItem : public Flattenable<BufferItem> {
enum { INVALID_BUFFER_SLOT = -1 };
BufferItem();
~BufferItem();
- operator IGraphicBufferConsumer::BufferItem() const;
static const char* scalingModeName(uint32_t scalingMode);
@@ -72,17 +72,39 @@ 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.
bool mIsAutoTimestamp;
- // mFrameNumber is the number of the queued frame for this slot.
- uint64_t mFrameNumber;
+ // mDataSpace is the current dataSpace value for this buffer slot. This gets
+ // set by queueBuffer each time this slot is queued. The meaning of the
+ // dataSpace is format-dependent.
+ android_dataspace mDataSpace;
- // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
- int mSlot;
+ // mFrameNumber is the number of the queued frame for this slot.
+ union {
+ uint64_t mFrameNumber;
+ struct {
+ uint32_t mFrameNumberLo;
+ uint32_t mFrameNumberHi;
+ };
+ };
+
+ union {
+ // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
+ int mSlot;
+
+ // mBuf is the former name for mSlot
+ int mBuf;
+ };
// mIsDroppable whether this buffer was queued with the
// property that it can be replaced by a new buffer for the purpose of
@@ -97,6 +119,10 @@ class BufferItem : public Flattenable<BufferItem> {
// Indicates this buffer must be transformed by the inverse transform of the screen
// it is displayed onto. This is applied after mTransform.
bool mTransformToDisplayInverse;
+
+ // Describes the portion of the surface that has been modified since the
+ // previous frame
+ Region mSurfaceDamage;
};
} // namespace android
diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h
index 5494ff1f30..56c7a3f463 100644
--- a/include/gui/BufferItemConsumer.h
+++ b/include/gui/BufferItemConsumer.h
@@ -42,8 +42,6 @@ class BufferItemConsumer: public ConsumerBase
public:
typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
- typedef BufferQueue::BufferItem BufferItem;
-
enum { DEFAULT_MAX_BUFFERS = -1 };
enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT };
enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE };
@@ -76,8 +74,8 @@ class BufferItemConsumer: public ConsumerBase
//
// If waitForFence is true, and the acquired BufferItem has a valid fence object,
// acquireBuffer will wait on the fence with no timeout before returning.
- status_t acquireBuffer(BufferItem *item, nsecs_t presentWhen,
- bool waitForFence = true);
+ status_t acquireBuffer(BufferItem* item, nsecs_t presentWhen,
+ bool waitForFence = true);
// Returns an acquired buffer to the queue, allowing it to be reused. Since
// only a fixed number of buffers may be acquired at a time, old buffers
@@ -88,14 +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(uint32_t defaultFormat);
};
} // namespace android
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 1188837456..09300a20c9 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_GUI_BUFFERQUEUE_H
#define ANDROID_GUI_BUFFERQUEUE_H
+#include <gui/BufferItem.h>
#include <gui/BufferQueueDefs.h>
#include <gui/IGraphicBufferConsumer.h>
#include <gui/IGraphicBufferProducer.h>
@@ -34,7 +35,7 @@ public:
// Attempts at runtime to increase the number of buffers past this will fail.
enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS };
// Used as a placeholder slot# when the value isn't pointing to an existing buffer.
- enum { INVALID_BUFFER_SLOT = IGraphicBufferConsumer::BufferItem::INVALID_BUFFER_SLOT };
+ enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT };
// Alias to <IGraphicBufferConsumer.h> -- please scope from there in future code!
enum {
NO_BUFFER_AVAILABLE = IGraphicBufferConsumer::NO_BUFFER_AVAILABLE,
@@ -47,7 +48,6 @@ public:
// for backward source compatibility
typedef ::android::ConsumerListener ConsumerListener;
- typedef IGraphicBufferConsumer::BufferItem BufferItem;
// ProxyConsumerListener is a ConsumerListener implementation that keeps a weak
// reference to the actual consumer object. It forwards all calls to that
@@ -62,9 +62,10 @@ public:
public:
ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
virtual ~ProxyConsumerListener();
- virtual void onFrameAvailable(const android::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 1912ed03da..cde302f8a6 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);
@@ -125,9 +125,15 @@ public:
// setDefaultBufferFormat allows the BufferQueue to create
// GraphicBuffers of a defaultFormat if no format is specified
- // in dequeueBuffer. Formats are enumerated in graphics.h; the
- // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
- virtual status_t setDefaultBufferFormat(uint32_t defaultFormat);
+ // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888.
+ virtual 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
+ virtual status_t setDefaultBufferDataSpace(
+ android_dataspace defaultDataSpace);
// setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
// These are merged with the bits passed to dequeueBuffer. The values are
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
index 1050e3b6ca..99134ea501 100644
--- a/include/gui/BufferQueueCore.h
+++ b/include/gui/BufferQueueCore.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_GUI_BUFFERQUEUECORE_H
#define ANDROID_GUI_BUFFERQUEUECORE_H
+#include <gui/BufferItem.h>
#include <gui/BufferQueueDefs.h>
#include <gui/BufferSlot.h>
@@ -29,11 +30,14 @@
#include <utils/Trace.h>
#include <utils/Vector.h>
-#define BQ_LOGV(x, ...) ALOGV("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define BQ_LOGD(x, ...) ALOGD("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define BQ_LOGI(x, ...) ALOGI("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define BQ_LOGW(x, ...) ALOGW("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
-#define BQ_LOGE(x, ...) ALOGE("[%s] "x, mConsumerName.string(), ##__VA_ARGS__)
+#include <list>
+#include <set>
+
+#define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGI(x, ...) ALOGI("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGW(x, ...) ALOGW("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
+#define BQ_LOGE(x, ...) ALOGE("[%s] " x, mConsumerName.string(), ##__VA_ARGS__)
#define ATRACE_BUFFER_INDEX(index) \
if (ATRACE_ENABLED()) { \
@@ -45,7 +49,6 @@
namespace android {
-class BufferItem;
class IConsumerListener;
class IGraphicBufferAlloc;
class IProducerListener;
@@ -58,7 +61,7 @@ class BufferQueueCore : public virtual RefBase {
public:
// Used as a placeholder slot number when the value isn't pointing to an
// existing buffer.
- enum { INVALID_BUFFER_SLOT = -1 }; // TODO: Extract from IGBC::BufferItem
+ enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT };
// We reserve two slots in order to guarantee that the producer and
// consumer can run asynchronously.
@@ -123,6 +126,10 @@ private:
// waitWhileAllocatingLocked blocks until mIsAllocating is false.
void waitWhileAllocatingLocked() const;
+ // validateConsistencyLocked ensures that the free lists are in sync with
+ // the information stored in mSlots
+ void validateConsistencyLocked() const;
+
// mAllocator is the connection to SurfaceFlinger that is used to allocate
// new GraphicBuffer objects.
sp<IGraphicBufferAlloc> mAllocator;
@@ -177,6 +184,14 @@ private:
// mQueue is a FIFO of queued buffers used in synchronous mode.
Fifo mQueue;
+ // mFreeSlots contains all of the slots which are FREE and do not currently
+ // have a buffer attached
+ std::set<int> mFreeSlots;
+
+ // mFreeBuffers contains all of the slots which are FREE and currently have
+ // a buffer attached
+ std::list<int> mFreeBuffers;
+
// mOverrideMaxBufferCount is the limit on the number of buffers that will
// be allocated at one time. This value is set by the producer by calling
// setBufferCount. The default is 0, which means that the producer doesn't
@@ -199,15 +214,20 @@ private:
// mDefaultBufferFormat can be set so it will override the buffer format
// when it isn't specified in dequeueBuffer.
- uint32_t mDefaultBufferFormat;
+ PixelFormat mDefaultBufferFormat;
// mDefaultWidth holds the default width of allocated buffers. It is used
// in dequeueBuffer if a width and height of 0 are specified.
- int mDefaultWidth;
+ uint32_t mDefaultWidth;
// mDefaultHeight holds the default height of allocated buffers. It is used
// in dequeueBuffer if a width and height of 0 are specified.
- int mDefaultHeight;
+ uint32_t mDefaultHeight;
+
+ // mDefaultBufferDataSpace holds the default dataSpace of queued buffers.
+ // It is used in queueBuffer if a dataspace of 0 (HAL_DATASPACE_UNKNOWN)
+ // is specified.
+ android_dataspace mDefaultBufferDataSpace;
// mDefaultMaxBufferCount is the default limit on the number of buffers that
// will be allocated at one time. This default limit is set by the consumer.
@@ -246,6 +266,20 @@ private:
// mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating
// becomes false.
mutable Condition mIsAllocatingCondition;
+
+ // 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 ed1056a59d..9754a89eac 100644
--- a/include/gui/BufferQueueProducer.h
+++ b/include/gui/BufferQueueProducer.h
@@ -73,9 +73,7 @@ public:
// updateTexImage() is called. If width and height are both zero, the
// default values specified by setDefaultBufferSize() are used instead.
//
- // The pixel formats are enumerated in graphics.h, e.g.
- // HAL_PIXEL_FORMAT_RGBA_8888. If the format is 0, the default format
- // will be used.
+ // If the format is 0, the default format will be used.
//
// The usage argument specifies gralloc buffer usage flags. The values
// are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These
@@ -93,8 +91,9 @@ public:
//
// In both cases, the producer will need to call requestBuffer to get a
// GraphicBuffer handle for the returned slot.
- virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, bool async,
- uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
+ virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence,
+ bool async, uint32_t width, uint32_t height, PixelFormat format,
+ uint32_t usage);
// See IGraphicBufferProducer::detachBuffer
virtual status_t detachBuffer(int slot);
@@ -171,7 +170,16 @@ public:
// See IGraphicBufferProducer::allocateBuffers
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
- uint32_t format, uint32_t usage);
+ PixelFormat format, uint32_t usage);
+
+ // 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
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index f7ab5ac59b..9307a26fb3 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);
@@ -76,6 +73,18 @@ public:
// when a new frame becomes available.
void setFrameAvailableListener(const wp<FrameAvailableListener>& listener);
+ // 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&);
@@ -101,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
@@ -153,8 +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(IGraphicBufferConsumer::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 4c6822a096..3b07a31750 100644
--- a/include/gui/CpuConsumer.h
+++ b/include/gui/CpuConsumer.h
@@ -53,6 +53,7 @@ class CpuConsumer : public ConsumerBase
uint32_t transform;
uint32_t scalingMode;
int64_t timestamp;
+ android_dataspace dataSpace;
uint64_t frameNumber;
// this is the same as format, except for formats that are compatible with
// a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter
@@ -71,7 +72,7 @@ class CpuConsumer : public ConsumerBase
// Create a new CPU consumer. The maxLockedBuffers parameter specifies
// how many buffers can be locked for user access at the same time.
CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
- uint32_t maxLockedBuffers, bool controlledByApp = false);
+ size_t maxLockedBuffers, bool controlledByApp = false);
virtual ~CpuConsumer();
@@ -79,18 +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. Formats are
- // enumerated in graphics.h; the initial default is
- // HAL_PIXEL_FORMAT_RGBA_8888.
- status_t setDefaultBufferFormat(uint32_t defaultFormat);
-
// 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
@@ -110,9 +99,9 @@ class CpuConsumer : public ConsumerBase
private:
// Maximum number of buffers that can be locked at a time
- uint32_t mMaxLockedBuffers;
+ size_t mMaxLockedBuffers;
- status_t releaseAcquiredBufferLocked(int lockedIdx);
+ status_t releaseAcquiredBufferLocked(size_t lockedIdx);
virtual void freeBufferLocked(int slotIndex);
@@ -133,7 +122,7 @@ class CpuConsumer : public ConsumerBase
Vector<AcquiredBuffer> mAcquiredBuffers;
// Count of currently locked buffers
- uint32_t mCurrentLockedBuffers;
+ size_t mCurrentLockedBuffers;
};
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h
index f91fe46d93..c35c7be064 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -150,7 +150,7 @@ public:
//
// The frame number is an incrementing counter set to 0 at the creation of
// the BufferQueue associated with this consumer.
- int64_t getFrameNumber();
+ uint64_t getFrameNumber();
// setDefaultBufferSize is used to set the size of buffers returned by
// requestBuffers when a with and height of zero is requested.
@@ -197,7 +197,8 @@ public:
// These functions call the corresponding BufferQueue implementation
// so the refactoring can proceed smoothly
- status_t setDefaultBufferFormat(uint32_t defaultFormat);
+ status_t setDefaultBufferFormat(PixelFormat defaultFormat);
+ status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace);
status_t setConsumerUsageBits(uint32_t usage);
status_t setTransformHint(uint32_t hint);
@@ -240,8 +241,8 @@ protected:
// acquireBufferLocked overrides the ConsumerBase method to update the
// mEglSlots array in addition to the ConsumerBase behavior.
- virtual status_t acquireBufferLocked(BufferQueue::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.
@@ -254,12 +255,12 @@ protected:
return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence);
}
- static bool isExternalFormat(uint32_t format);
+ static bool isExternalFormat(PixelFormat format);
// This releases the buffer in the slot referenced by mCurrentTexture,
// then updates state to refer to the BufferItem, which must be a
// newly-acquired buffer.
- status_t updateAndReleaseLocked(const BufferQueue::BufferItem& item);
+ status_t updateAndReleaseLocked(const BufferItem& item);
// Binds mTexName and the current buffer to mTexTarget. Uses
// mCurrentTexture if it's set, mCurrentTextureImage if not. If the
@@ -391,7 +392,7 @@ private:
// mCurrentFrameNumber is the frame counter for the current texture.
// It gets set each time updateTexImage is called.
- int64_t mCurrentFrameNumber;
+ uint64_t mCurrentFrameNumber;
uint32_t mDefaultWidth, mDefaultHeight;
diff --git a/include/gui/GraphicBufferAlloc.h b/include/gui/GraphicBufferAlloc.h
index b08750c2fb..69fe51ef93 100644
--- a/include/gui/GraphicBufferAlloc.h
+++ b/include/gui/GraphicBufferAlloc.h
@@ -33,8 +33,9 @@ class GraphicBufferAlloc : public BnGraphicBufferAlloc {
public:
GraphicBufferAlloc();
virtual ~GraphicBufferAlloc();
- virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
- PixelFormat format, uint32_t usage, status_t* error);
+ virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
+ uint32_t height, PixelFormat format, uint32_t usage,
+ status_t* error);
};
diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h
index cee41d9341..f3c46ec2ed 100644
--- a/include/gui/IGraphicBufferAlloc.h
+++ b/include/gui/IGraphicBufferAlloc.h
@@ -45,10 +45,10 @@ public:
class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc>
{
public:
- virtual status_t onTransact( uint32_t code,
- const Parcel& data,
- Parcel* reply,
- uint32_t flags = 0);
+ virtual status_t onTransact(uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 15f51fe8c0..60ec9cc0e9 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -25,6 +25,7 @@
#include <utils/Timers.h>
#include <binder/IInterface.h>
+#include <ui/PixelFormat.h>
#include <ui/Rect.h>
#include <EGL/egl.h>
@@ -33,6 +34,7 @@
namespace android {
// ----------------------------------------------------------------------------
+class BufferItem;
class Fence;
class GraphicBuffer;
class IConsumerListener;
@@ -41,71 +43,6 @@ class NativeHandle;
class IGraphicBufferConsumer : public IInterface {
public:
-
- // public facing structure for BufferSlot
- class BufferItem : public Flattenable<BufferItem> {
- friend class Flattenable<BufferItem>;
- size_t getPodSize() const;
- size_t getFlattenedSize() const;
- size_t getFdCount() const;
- status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
- status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
-
- public:
- // The default value of mBuf, used to indicate this doesn't correspond to a slot.
- enum { INVALID_BUFFER_SLOT = -1 };
- BufferItem();
-
- // mGraphicBuffer points to the buffer allocated for this slot, or is NULL
- // if the buffer in this slot has been acquired in the past (see
- // BufferSlot.mAcquireCalled).
- sp<GraphicBuffer> mGraphicBuffer;
-
- // mFence is a fence that will signal when the buffer is idle.
- sp<Fence> mFence;
-
- // mCrop is the current crop rectangle for this buffer slot.
- Rect mCrop;
-
- // mTransform is the current transform flags for this buffer slot.
- // refer to NATIVE_WINDOW_TRANSFORM_* in <window.h>
- uint32_t mTransform;
-
- // mScalingMode is the current scaling mode for this buffer slot.
- // refer to NATIVE_WINDOW_SCALING_* in <window.h>
- uint32_t mScalingMode;
-
- // mTimestamp is the current timestamp for this buffer slot. This gets
- // 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;
-
- // mIsAutoTimestamp indicates whether mTimestamp was generated
- // automatically when the buffer was queued.
- bool mIsAutoTimestamp;
-
- // mFrameNumber is the number of the queued frame for this slot.
- uint64_t mFrameNumber;
-
- // mBuf is the slot index of this buffer (default INVALID_BUFFER_SLOT).
- int mBuf;
-
- // mIsDroppable whether this buffer was queued with the
- // property that it can be replaced by a new buffer for the purpose of
- // making sure dequeueBuffer() won't block.
- // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
- // was queued.
- bool mIsDroppable;
-
- // Indicates whether this buffer has been seen by a consumer yet
- bool mAcquireCalled;
-
- // Indicates this buffer must be transformed by the inverse transform of the screen
- // it is displayed onto. This is applied after mTransform.
- bool mTransformToDisplayInverse;
- };
-
enum {
// Returned by releaseBuffer, after which the consumer must
// free any references to the just-released buffer that it might have.
@@ -132,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
@@ -141,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
@@ -166,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
@@ -280,11 +225,19 @@ public:
// setDefaultBufferFormat allows the BufferQueue to create
// GraphicBuffers of a defaultFormat if no format is specified
- // in dequeueBuffer. Formats are enumerated in graphics.h; the
- // initial default is HAL_PIXEL_FORMAT_RGBA_8888.
+ // in dequeueBuffer.
+ // The initial default is PIXEL_FORMAT_RGBA_8888.
+ //
+ // Return of a value other than NO_ERROR means an unknown error has occurred.
+ virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0;
+
+ // setDefaultBufferDataSpace is a request to the producer to provide buffers
+ // of the indicated dataSpace. The producer may ignore this request.
+ // The initial default is HAL_DATASPACE_UNKNOWN.
//
// Return of a value other than NO_ERROR means an unknown error has occurred.
- virtual status_t setDefaultBufferFormat(uint32_t defaultFormat) = 0;
+ virtual status_t setDefaultBufferDataSpace(
+ android_dataspace defaultDataSpace) = 0;
// setConsumerUsageBits will turn on additional usage bits for dequeueBuffer.
// These are merged with the bits passed to dequeueBuffer. The values are
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 4e9e810701..9530de1aa8 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -28,6 +28,7 @@
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
#include <ui/Rect.h>
+#include <ui/Region.h>
namespace android {
// ----------------------------------------------------------------------------
@@ -134,9 +135,7 @@ public:
// updateTexImage() is called. If width and height are both zero, the
// default values specified by setDefaultBufferSize() are used instead.
//
- // The pixel formats are enumerated in <graphics.h>, e.g.
- // HAL_PIXEL_FORMAT_RGBA_8888. If the format is 0, the default format
- // will be used.
+ // If the format is 0, the default format will be used.
//
// The usage argument specifies gralloc buffer usage flags. The values
// are enumerated in <gralloc.h>, e.g. GRALLOC_USAGE_HW_RENDER. These
@@ -167,7 +166,7 @@ public:
// All other negative values are an unknown error returned downstream
// from the graphics allocator (typically errno).
virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
- uint32_t w, uint32_t h, uint32_t format, uint32_t usage) = 0;
+ uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 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
@@ -219,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
@@ -267,6 +267,7 @@ public:
inline QueueBufferInput(const Parcel& parcel);
// timestamp - a monotonically increasing value in nanoseconds
// isAutoTimestamp - if the timestamp was synthesized at queue time
+ // dataSpace - description of the contents, interpretation depends on format
// crop - a crop rectangle that's used as a hint to the consumer
// scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
// transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
@@ -276,17 +277,21 @@ public:
// sticky - the sticky transform set in Surface (only used by the LEGACY
// camera mode).
inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
- const Rect& crop, int scalingMode, uint32_t transform, bool async,
- const sp<Fence>& fence, uint32_t sticky = 0)
- : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), crop(crop),
- scalingMode(scalingMode), transform(transform), stickyTransform(sticky),
- async(async), fence(fence) { }
+ android_dataspace dataSpace, const Rect& crop, int scalingMode,
+ uint32_t transform, bool async, const sp<Fence>& fence,
+ uint32_t sticky = 0)
+ : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
+ dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
+ transform(transform), stickyTransform(sticky),
+ async(async), fence(fence), surfaceDamage() { }
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
- Rect* outCrop, int* outScalingMode, uint32_t* outTransform,
- bool* outAsync, sp<Fence>* outFence,
+ android_dataspace* outDataSpace,
+ Rect* outCrop, int* outScalingMode,
+ uint32_t* outTransform, bool* outAsync, sp<Fence>* outFence,
uint32_t* outStickyTransform = NULL) const {
*outTimestamp = timestamp;
*outIsAutoTimestamp = bool(isAutoTimestamp);
+ *outDataSpace = dataSpace;
*outCrop = crop;
*outScalingMode = scalingMode;
*outTransform = transform;
@@ -303,15 +308,20 @@ public:
status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
+ const Region& getSurfaceDamage() const { return surfaceDamage; }
+ void setSurfaceDamage(const Region& damage) { surfaceDamage = damage; }
+
private:
int64_t timestamp;
int isAutoTimestamp;
+ android_dataspace dataSpace;
Rect crop;
int scalingMode;
uint32_t transform;
uint32_t stickyTransform;
int async;
sp<Fence> fence;
+ Region surfaceDamage;
};
// QueueBufferOutput must be a POD structure
@@ -448,7 +458,31 @@ public:
// dequeueBuffer. If there are already the maximum number of buffers
// allocated, this function has no effect.
virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
- uint32_t format, uint32_t usage) = 0;
+ PixelFormat format, uint32_t usage) = 0;
+
+ // Sets whether dequeueBuffer is allowed to allocate new buffers.
+ //
+ // Normally dequeueBuffer does not discriminate between free slots which
+ // already have an allocated buffer and those which do not, and will
+ // allocate a new buffer if the slot doesn't have a buffer or if the slot's
+ // buffer doesn't match the requested size, format, or usage. This method
+ // allows the producer to restrict the eligible slots to those which already
+ // have an allocated buffer of the correct size, format, and usage. If no
+ // 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 9c8afc5a08..3dca2a3739 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/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
index 51717a412e..8c3d49e64e 100644
--- a/include/gui/ISurfaceComposer.h
+++ b/include/gui/ISurfaceComposer.h
@@ -28,7 +28,6 @@
#include <binder/IInterface.h>
#include <ui/FrameStats.h>
-#include <ui/PixelFormat.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposerClient.h>
@@ -39,7 +38,7 @@ namespace android {
class ComposerState;
class DisplayState;
struct DisplayInfo;
-class DisplayStatInfo;
+struct DisplayStatInfo;
class IDisplayEventConnection;
class IMemoryHeap;
class Rect;
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h
index 28a08e2238..8142be6352 100644
--- a/include/gui/Sensor.h
+++ b/include/gui/Sensor.h
@@ -67,12 +67,14 @@ public:
int32_t getMinDelay() const;
nsecs_t getMinDelayNs() const;
int32_t getVersion() const;
- int32_t getFifoReservedEventCount() const;
- int32_t getFifoMaxEventCount() const;
+ uint32_t getFifoReservedEventCount() const;
+ uint32_t getFifoMaxEventCount() const;
const String8& getStringType() const;
const String8& getRequiredPermission() const;
+ bool isRequiredPermissionRuntime() const;
+ int32_t getRequiredAppOp() const;
int32_t getMaxDelay() const;
- int32_t getFlags() const;
+ uint32_t getFlags() const;
bool isWakeUpSensor() const;
int32_t getReportingMode() const;
@@ -93,12 +95,14 @@ private:
float mPower;
int32_t mMinDelay;
int32_t mVersion;
- int32_t mFifoReservedEventCount;
- int32_t mFifoMaxEventCount;
+ uint32_t mFifoReservedEventCount;
+ uint32_t mFifoMaxEventCount;
String8 mStringType;
String8 mRequiredPermission;
+ bool mRequiredPermissionRuntime = false;
+ int32_t mRequiredAppOp;
int32_t mMaxDelay;
- int32_t mFlags;
+ uint32_t mFlags;
static void flattenString8(void*& buffer, size_t& size, const String8& string8);
static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8);
};
diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h
index 02b3d385bc..e5b9fc5984 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 3176462db6..37960673cc 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 f2cf018a9f..72f1067076 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();
@@ -146,6 +154,8 @@ private:
int dispatchLock(va_list args);
int dispatchUnlockAndPost(va_list args);
int dispatchSetSidebandStream(va_list args);
+ int dispatchSetBuffersDataSpace(va_list args);
+ int dispatchSetSurfaceDamage(va_list args);
protected:
virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
@@ -160,20 +170,27 @@ protected:
virtual int connect(int api);
virtual int disconnect(int api);
virtual int setBufferCount(int bufferCount);
- virtual int setBuffersDimensions(int w, int h);
- virtual int setBuffersUserDimensions(int w, int h);
- virtual int setBuffersFormat(int format);
+ virtual int setBuffersDimensions(uint32_t width, uint32_t height);
+ virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
+ virtual int setBuffersFormat(PixelFormat format);
virtual int setScalingMode(int mode);
- virtual int setBuffersTransform(int transform);
- virtual int setBuffersStickyTransform(int transform);
+ virtual int setBuffersTransform(uint32_t transform);
+ virtual int setBuffersStickyTransform(uint32_t transform);
virtual int setBuffersTimestamp(int64_t timestamp);
+ virtual int setBuffersDataSpace(android_dataspace dataSpace);
virtual int setCrop(Rect const* rect);
virtual int setUsage(uint32_t reqUsage);
+ virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects);
public:
virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
virtual int unlockAndPost();
+ virtual int connect(int api, const sp<IProducerListener>& listener);
+ virtual int detachNextBuffer(sp<GraphicBuffer>* outBuffer,
+ sp<Fence>* outFence);
+ virtual int attachBuffer(ANativeWindowBuffer*);
+
protected:
enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
@@ -211,7 +228,7 @@ private:
// mReqFormat is the buffer pixel format that will be requested at the next
// deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888.
- uint32_t mReqFormat;
+ PixelFormat mReqFormat;
// mReqUsage is the set of buffer usage flags that will be requested
// at the next deuque operation. It is initialized to 0.
@@ -222,6 +239,11 @@ private:
// a timestamp is auto-generated when queueBuffer is called.
int64_t mTimestamp;
+ // mDataSpace is the buffer dataSpace that will be used for the next buffer
+ // queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which
+ // means that the buffer contains some type of color data.
+ android_dataspace mDataSpace;
+
// mCrop is the crop rectangle that will be used for the next buffer
// that gets queued. It is set by calling setCrop.
Rect mCrop;
@@ -240,23 +262,23 @@ private:
// from being set by the compositor.
uint32_t mStickyTransform;
- // mDefaultWidth is default width of the buffers, regardless of the
- // native_window_set_buffers_dimensions call.
- uint32_t mDefaultWidth;
+ // mDefaultWidth is default width of the buffers, regardless of the
+ // native_window_set_buffers_dimensions call.
+ uint32_t mDefaultWidth;
- // mDefaultHeight is default height of the buffers, regardless of the
- // native_window_set_buffers_dimensions call.
- uint32_t mDefaultHeight;
+ // mDefaultHeight is default height of the buffers, regardless of the
+ // native_window_set_buffers_dimensions call.
+ uint32_t mDefaultHeight;
- // mUserWidth, if non-zero, is an application-specified override
- // of mDefaultWidth. This is lower priority than the width set by
- // native_window_set_buffers_dimensions.
- uint32_t mUserWidth;
+ // mUserWidth, if non-zero, is an application-specified override
+ // of mDefaultWidth. This is lower priority than the width set by
+ // native_window_set_buffers_dimensions.
+ uint32_t mUserWidth;
- // mUserHeight, if non-zero, is an application-specified override
- // of mDefaultHeight. This is lower priority than the height set
- // by native_window_set_buffers_dimensions.
- uint32_t mUserHeight;
+ // mUserHeight, if non-zero, is an application-specified override
+ // of mDefaultHeight. This is lower priority than the height set
+ // by native_window_set_buffers_dimensions.
+ uint32_t mUserHeight;
// mTransformHint is the transform probably applied to buffers of this
// window. this is only a hint, actual transform may differ.
@@ -284,8 +306,17 @@ private:
sp<GraphicBuffer> mPostedBuffer;
bool mConnectedToCpu;
- // must be accessed from lock/unlock thread only
+ // When a CPU producer is attached, this reflects the region that the
+ // producer wished to update as well as whether the Surface was able to copy
+ // the previous buffer back to allow a partial update.
+ //
+ // 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/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index 4cbfc09951..37d953e18e 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -127,7 +127,7 @@ public:
status_t show(const sp<IBinder>& id);
status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent);
- status_t setLayer(const sp<IBinder>& id, int32_t layer);
+ status_t setLayer(const sp<IBinder>& id, uint32_t layer);
status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f);
status_t setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy);
status_t setPosition(const sp<IBinder>& id, float x, float y);
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index 84fb9f999a..9f62f7c726 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -57,8 +57,8 @@ public:
// release surface data from java
void clear();
- status_t setLayerStack(int32_t layerStack);
- status_t setLayer(int32_t layer);
+ status_t setLayerStack(uint32_t layerStack);
+ status_t setLayer(uint32_t layer);
status_t setPosition(float x, float y);
status_t setSize(uint32_t w, uint32_t h);
status_t hide();
diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h
new file mode 100644
index 0000000000..629310ff2f
--- /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 09419c9a61..82fc6599a7 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -45,6 +45,19 @@ enum {
};
enum {
+
+ /**
+ * This flag indicates that the window that received this motion event is partly
+ * or wholly obscured by another visible window above it. This flag is set to true
+ * even if the event did not directly pass through the obscured area.
+ * A security sensitive application can check this flag to identify situations in which
+ * a malicious application may have covered up part of its content for the purpose
+ * of misleading the user or hijacking touches. An appropriate response might be
+ * to drop the suspect touches or to take additional precautions to confirm the user's
+ * actual intent.
+ */
+ AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2,
+
/* Motion event is inconsistent with previously sent motion events. */
AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
};
@@ -155,10 +168,22 @@ enum {
* NOTE: If you want a flag to be able to set in a keylayout file, then you must add it to
* InputEventLabels.h as well. */
+ // Indicates that the event should wake the device.
POLICY_FLAG_WAKE = 0x00000001,
+
+ // Indicates that the key is virtual, such as a capacitive button, and should
+ // generate haptic feedback. Virtual keys may be suppressed for some time
+ // after a recent touch to prevent accidental activation of virtual keys adjacent
+ // to the touch screen during an edge swipe.
POLICY_FLAG_VIRTUAL = 0x00000002,
+
+ // Indicates that the key is the special function modifier.
POLICY_FLAG_FUNCTION = 0x00000004,
+ // Indicates that the key represents a special gesture that has been detected by
+ // the touch firmware or driver. Causes touch events from the same device to be canceled.
+ POLICY_FLAG_GESTURE = 0x00000008,
+
POLICY_FLAG_RAW_MASK = 0x0000ffff,
/* These flags are set by the input dispatcher. */
@@ -373,6 +398,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; }
@@ -526,6 +557,7 @@ public:
int32_t deviceId,
int32_t source,
int32_t action,
+ int32_t actionButton,
int32_t flags,
int32_t edgeFlags,
int32_t metaState,
@@ -578,6 +610,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 adf9fb9170..1ea69d352d 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 df50237cd2..a7a93297f8 100644
--- a/include/input/InputEventLabels.h
+++ b/include/input/InputEventLabels.h
@@ -299,6 +299,14 @@ static const InputEventLabel KEYCODES[] = {
DEFINE_KEYCODE(TV_MEDIA_CONTEXT_MENU),
DEFINE_KEYCODE(TV_TIMER_PROGRAMMING),
DEFINE_KEYCODE(HELP),
+ 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 }
};
@@ -376,6 +384,7 @@ static const InputEventLabel LEDS[] = {
static const InputEventLabel FLAGS[] = {
DEFINE_FLAG(VIRTUAL),
DEFINE_FLAG(FUNCTION),
+ DEFINE_FLAG(GESTURE),
{ NULL, 0 }
};
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index e7e383b48a..f31bceabd7 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 49939fda9b..272881b9f5 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 c800825a36..3e3257f956 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 d5f42befe6..1008c22d73 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 5876c40f60..b765203956 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 0f177a1267..ae8430d856 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 12f2b3baff..f746a69d2a 100644
--- a/include/media/openmax/OMX_Core.h
+++ b/include/media/openmax/OMX_Core.h
@@ -503,12 +503,28 @@ 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 or reached EOS
+ * 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.
+ *
+ * When the component reached EOS, it must signal an EOS timestamp using the same mechanism.
+ * This is in addition to the timestamp of the last rendered frame, and should follow that
+ * frame.
+ */
+ 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 a5b9d18764..f9b6f4b0fd 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 ea3d0dadbc..25bea1f9cc 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 3c97e14a7c..3971bc5cc3 100644
--- a/include/media/openmax/OMX_VideoExt.h
+++ b/include/media/openmax/OMX_VideoExt.h
@@ -203,6 +203,19 @@ typedef struct OMX_VIDEO_SLICESEGMENTSTYPE {
OMX_BOOL bEnableLoopFilterAcrossSlices;
} OMX_VIDEO_SLICESEGMENTSTYPE;
+/** Structure to return timestamps of rendered output frames as well as EOS
+ * 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
+ // Use INT64_MAX for nMediaTimeUs to signal that the EOS
+ // has been reached. In this case, nSystemTimeNs MUST be
+ // the system time when the last frame was rendered.
+ // This MUST be done in addition to returning (and
+ // following) the render information for the last frame.
+} OMX_VIDEO_RENDEREVENTTYPE;
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index 2fa6ff9d92..cbe87330ed 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/Fence.h b/include/ui/Fence.h
index 20466b616e..b431bd52aa 100644
--- a/include/ui/Fence.h
+++ b/include/ui/Fence.h
@@ -65,7 +65,7 @@ public:
// before the fence signals then -ETIME is returned. A timeout of
// TIMEOUT_NEVER may be used to indicate that the call should wait
// indefinitely for the fence to signal.
- status_t wait(unsigned int timeout);
+ status_t wait(int timeout);
// waitForever is a convenience function for waiting forever for a fence to
// signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h
index 5cd8101d30..6b66d5f66b 100644
--- a/include/ui/FramebufferNativeWindow.h
+++ b/include/ui/FramebufferNativeWindow.h
@@ -14,11 +14,13 @@
* limitations under the License.
*/
+#ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP
+#warning "FramebufferNativeWindow is deprecated"
+#endif
+
#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H
-#warning "FramebufferNativeWindow is deprecated"
-
#include <stdint.h>
#include <sys/types.h>
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 7630faa762..3da720ff37 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -49,7 +49,7 @@ public:
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
-
+
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
@@ -72,11 +72,13 @@ public:
GraphicBuffer();
// creates w * h buffer
- GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+ GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+ uint32_t inUsage);
// create a buffer from an existing handle
- GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
- uint32_t stride, native_handle_t* handle, bool keepOwnership);
+ GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+ uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle,
+ bool keepOwnership);
// create a buffer from an existing ANativeWindowBuffer
GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
@@ -84,26 +86,39 @@ public:
// return status
status_t initCheck() const;
- uint32_t getWidth() const { return width; }
- uint32_t getHeight() const { return height; }
- uint32_t getStride() const { return stride; }
- uint32_t getUsage() const { return usage; }
+ uint32_t getWidth() const { return static_cast<uint32_t>(width); }
+ uint32_t getHeight() const { return static_cast<uint32_t>(height); }
+ uint32_t getStride() const { return static_cast<uint32_t>(stride); }
+ uint32_t getUsage() const { return static_cast<uint32_t>(usage); }
PixelFormat getPixelFormat() const { return format; }
Rect getBounds() const { return Rect(width, height); }
uint64_t getId() const { return mId; }
- status_t reallocate(uint32_t w, uint32_t h, PixelFormat f, uint32_t usage);
+ 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);
- status_t lock(uint32_t usage, void** vaddr);
- status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
+ bool needsReallocation(uint32_t inWidth, uint32_t inHeight,
+ PixelFormat inFormat, uint32_t inUsage);
+
+ status_t lock(uint32_t inUsage, void** vaddr);
+ status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr);
// For HAL_PIXEL_FORMAT_YCbCr_420_888
- status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr);
- status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr);
+ status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr);
+ status_t lockYCbCr(uint32_t inUsage, const Rect& rect,
+ android_ycbcr *ycbcr);
status_t unlock();
- status_t lockAsync(uint32_t usage, void** vaddr, int fenceFd);
- status_t lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd);
- status_t lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd);
- status_t lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd);
+ status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd);
+ status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr,
+ int fenceFd);
+ status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr,
+ int fenceFd);
+ status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
+ android_ycbcr *ycbcr, int fenceFd);
status_t unlockAsync(int *fenceFd);
ANativeWindowBuffer* getNativeBuffer() const;
@@ -143,8 +158,8 @@ private:
GraphicBuffer& operator = (const GraphicBuffer& rhs);
const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
- status_t initSize(uint32_t w, uint32_t h, PixelFormat format,
- uint32_t usage);
+ status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
+ uint32_t inUsage);
void free_handle();
@@ -156,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
diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h
index dffa788f46..5443f09a10 100644
--- a/include/ui/GraphicBufferAllocator.h
+++ b/include/ui/GraphicBufferAllocator.h
@@ -1,17 +1,17 @@
-/*
+/*
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
@@ -45,14 +45,14 @@ public:
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
-
+
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK,
-
+
USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
-
+
USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE,
USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER,
USAGE_HW_2D = GRALLOC_USAGE_HW_2D,
@@ -60,10 +60,9 @@ public:
};
static inline GraphicBufferAllocator& get() { return getInstance(); }
-
- status_t alloc(uint32_t w, uint32_t h, PixelFormat format, int usage,
- buffer_handle_t* handle, int32_t* stride);
+ status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
+ buffer_handle_t* handle, uint32_t* stride);
status_t free(buffer_handle_t handle);
@@ -72,21 +71,21 @@ public:
private:
struct alloc_rec_t {
- uint32_t w;
- uint32_t h;
- uint32_t s;
+ uint32_t width;
+ uint32_t height;
+ uint32_t stride;
PixelFormat format;
uint32_t usage;
size_t size;
};
-
+
static Mutex sLock;
static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList;
-
+
friend class Singleton<GraphicBufferAllocator>;
GraphicBufferAllocator();
~GraphicBufferAllocator();
-
+
alloc_device_t *mAllocDev;
};
diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h
index 98fff0ef31..6099548aaf 100644
--- a/include/ui/GraphicBufferMapper.h
+++ b/include/ui/GraphicBufferMapper.h
@@ -41,23 +41,24 @@ public:
status_t registerBuffer(buffer_handle_t handle);
status_t unregisterBuffer(buffer_handle_t handle);
-
+
status_t lock(buffer_handle_t handle,
- int usage, const Rect& bounds, void** vaddr);
+ uint32_t usage, const Rect& bounds, void** vaddr);
status_t lockYCbCr(buffer_handle_t handle,
- int usage, const Rect& bounds, android_ycbcr *ycbcr);
+ uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
status_t unlock(buffer_handle_t handle);
status_t lockAsync(buffer_handle_t handle,
- int usage, const Rect& bounds, void** vaddr, int fenceFd);
+ uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
status_t lockAsyncYCbCr(buffer_handle_t handle,
- int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd);
+ uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
+ int fenceFd);
status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
-
+
// dumps information about the mapping of this handle
void dump(buffer_handle_t handle);
diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h
index 7e469453fd..f26fecb8b1 100644
--- a/include/ui/PixelFormat.h
+++ b/include/ui/PixelFormat.h
@@ -25,9 +25,6 @@
#ifndef UI_PIXELFORMAT_H
#define UI_PIXELFORMAT_H
-#include <stdint.h>
-#include <sys/types.h>
-#include <utils/Errors.h>
#include <hardware/hardware.h>
namespace android {
@@ -63,14 +60,12 @@ enum {
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB
PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB
- PIXEL_FORMAT_sRGB_A_8888 = HAL_PIXEL_FORMAT_sRGB_A_8888, // 4x8-bit sRGB + A
- PIXEL_FORMAT_sRGB_X_8888 = HAL_PIXEL_FORMAT_sRGB_X_8888, // 4x8-bit sRGB, no A
};
typedef int32_t PixelFormat;
-ssize_t bytesPerPixel(PixelFormat format);
-ssize_t bitsPerPixel(PixelFormat format);
+uint32_t bytesPerPixel(PixelFormat format);
+uint32_t bitsPerPixel(PixelFormat format);
}; // namespace android
diff --git a/include/ui/Rect.h b/include/ui/Rect.h
index 31e28d27f7..3886f93142 100644
--- a/include/ui/Rect.h
+++ b/include/ui/Rect.h
@@ -18,6 +18,7 @@
#define ANDROID_UI_RECT
#include <utils/Flattenable.h>
+#include <utils/Log.h>
#include <utils/TypeHelpers.h>
#include <ui/Point.h>
@@ -30,6 +31,8 @@ class Rect : public ARect, public LightFlattenablePod<Rect>
public:
typedef ARect::value_type value_type;
+ static const Rect INVALID_RECT;
+
// we don't provide copy-ctor and operator= on purpose
// because we want the compiler generated versions
@@ -43,6 +46,22 @@ public:
bottom = h;
}
+ inline Rect(uint32_t w, uint32_t h) {
+ if (w > INT32_MAX) {
+ ALOG(LOG_WARN, "Rect",
+ "Width %u too large for Rect class, clamping", w);
+ w = INT32_MAX;
+ }
+ if (h > INT32_MAX) {
+ ALOG(LOG_WARN, "Rect",
+ "Height %u too large for Rect class, clamping", h);
+ h = INT32_MAX;
+ }
+ left = top = 0;
+ right = w;
+ bottom = h;
+ }
+
inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) {
left = l;
top = t;
diff --git a/include/ui/Region.h b/include/ui/Region.h
index 0d1c68c951..2a1491837d 100644
--- a/include/ui/Region.h
+++ b/include/ui/Region.h
@@ -35,6 +35,8 @@ class String8;
class Region : public LightFlattenable<Region>
{
public:
+ static const Region INVALID_REGION;
+
Region();
Region(const Region& rhs);
explicit Region(const Rect& rhs);
@@ -55,11 +57,12 @@ public:
// the region becomes its bounds
Region& makeBoundsSelf();
-
+
void clear();
void set(const Rect& r);
+ void set(int32_t w, int32_t h);
void set(uint32_t w, uint32_t h);
-
+
Region& orSelf(const Rect& rhs);
Region& xorSelf(const Rect& rhs);
Region& andSelf(const Rect& rhs);
@@ -110,14 +113,14 @@ public:
inline Region& operator -= (const Region& rhs);
inline Region& operator += (const Point& pt);
-
+
// returns true if the regions share the same underlying storage
bool isTriviallyEqual(const Region& region) const;
/* various ways to access the rectangle list */
-
+
// STL-like iterators
typedef Rect const* const_iterator;
const_iterator begin() const;
@@ -133,7 +136,7 @@ public:
SharedBuffer const* getSharedBuffer(size_t* count) const;
/* no user serviceable parts here... */
-
+
// add a rectangle to the internal list. This rectangle must
// be sorted in Y and X and must not make the region invalid.
void addRectUnchecked(int l, int t, int r, int b);
@@ -149,7 +152,7 @@ public:
private:
class rasterizer;
friend class rasterizer;
-
+
Region& operationSelf(const Rect& r, int op);
Region& operationSelf(const Region& r, int op);
Region& operationSelf(const Region& r, int dx, int dy, int op);
@@ -172,7 +175,7 @@ private:
static bool validate(const Region& reg,
const char* name, bool silent = false);
-
+
// mStorage is a (manually) sorted array of Rects describing the region
// with an extra Rect as the last element which is set to the
// bounds of the region. However, if the region is