Skip to content

Commit 5357214

Browse files
author
Android Build Coastguard Worker
committed
Snap for 12702769 from 7ff68ce to 25Q1-release
Change-Id: I679d733c824aa5117b02aa47039623f5de5b9f80
2 parents affe981 + 7ff68ce commit 5357214

26 files changed

Lines changed: 873 additions & 203 deletions

File tree

include/android/display_luts.h

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
* Copyright (C) 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* @addtogroup NativeActivity Native Activity
19+
* @{
20+
*/
21+
22+
/**
23+
* @file display_luts.h
24+
*/
25+
#pragma once
26+
27+
#include <inttypes.h>
28+
29+
__BEGIN_DECLS
30+
31+
/**
32+
* The dimension of the lut
33+
*/
34+
enum ADisplayLuts_Dimension : int32_t {
35+
ADISPLAYLUTS_ONE_DIMENSION = 1,
36+
ADISPLAYLUTS_THREE_DIMENSION = 3,
37+
};
38+
typedef enum ADisplayLuts_Dimension ADisplayLuts_Dimension;
39+
40+
/**
41+
* The sampling key used by the lut
42+
*/
43+
enum ADisplayLuts_SamplingKey : int32_t {
44+
ADISPLAYLUTS_SAMPLINGKEY_RGB = 0,
45+
ADISPLAYLUTS_SAMPLINGKEY_MAX_RGB = 1,
46+
};
47+
typedef enum ADisplayLuts_SamplingKey ADisplayLuts_SamplingKey;
48+
49+
/**
50+
* Used to get and set display luts entry
51+
*/
52+
typedef struct ADisplayLutsEntry ADisplayLutsEntry;
53+
54+
/**
55+
* Used to get and set display luts
56+
*/
57+
typedef struct ADisplayLuts ADisplayLuts;
58+
59+
/**
60+
* Creates a \a ADisplayLutsEntry entry.
61+
*
62+
* You are responsible for mamanging the memory of the returned object.
63+
* Always call \a ADisplayLutsEntry_destroy to release it after use.
64+
*
65+
* Functions like \a ADisplayLuts_set create their own copies of entries,
66+
* therefore they don't take the ownership of the instance created by
67+
* \a ADisplayLutsEntry_create.
68+
*
69+
* @param buffer The lut raw buffer. The function creates a copy of it and does not need to
70+
* outlive the life of the ADisplayLutsEntry.
71+
* @param length The length of lut raw buffer
72+
* @param dimension The dimension of the lut. see \a ADisplayLuts_Dimension
73+
* @param key The sampling key used by the lut. see \a ADisplayLuts_SamplingKey
74+
* @return a new \a ADisplayLutsEntry instance.
75+
*/
76+
ADisplayLutsEntry* _Nonnull ADisplayLutsEntry_createEntry(float* _Nonnull buffer,
77+
int32_t length, int32_t dimension, int32_t key) __INTRODUCED_IN(36);
78+
79+
/**
80+
* Destroy the \a ADisplayLutsEntry instance.
81+
*
82+
* @param entry The entry to be destroyed
83+
*/
84+
void ADisplayLutsEntry_destroy(ADisplayLutsEntry* _Nullable entry) __INTRODUCED_IN(36);
85+
86+
/**
87+
* Gets the dimension of the entry.
88+
*
89+
* The function is only valid for the lifetime of the `entry`.
90+
*
91+
* @param entry The entry to query
92+
* @return the dimension of the lut
93+
*/
94+
ADisplayLuts_Dimension ADisplayLutsEntry_getDimension(const ADisplayLutsEntry* _Nonnull entry)
95+
__INTRODUCED_IN(36);
96+
97+
/**
98+
* Gets the size for each dimension of the entry.
99+
*
100+
* The function is only valid for the lifetime of the `entry`.
101+
*
102+
* @param entry The entry to query
103+
* @return the size of each dimension of the lut
104+
*/
105+
int32_t ADisplayLutsEntry_getSize(const ADisplayLutsEntry* _Nonnull entry)
106+
__INTRODUCED_IN(36);
107+
108+
/**
109+
* Gets the sampling key used by the entry.
110+
*
111+
* The function is only valid for the lifetime of the `entry`.
112+
*
113+
* @param entry The entry to query
114+
* @return the sampling key used by the lut
115+
*/
116+
ADisplayLuts_SamplingKey ADisplayLutsEntry_getSamplingKey(const ADisplayLutsEntry* _Nonnull entry)
117+
__INTRODUCED_IN(36);
118+
119+
/**
120+
* Gets the lut buffer of the entry.
121+
*
122+
* The function is only valid for the lifetime of the `entry`.
123+
*
124+
* @param entry The entry to query
125+
* @return a pointer to the raw lut buffer
126+
*/
127+
const float* _Nonnull ADisplayLutsEntry_getBuffer(const ADisplayLutsEntry* _Nonnull entry)
128+
__INTRODUCED_IN(36);
129+
130+
/**
131+
* Creates a \a ADisplayLuts instance.
132+
*
133+
* You are responsible for mamanging the memory of the returned object.
134+
* Always call \a ADisplayLuts_destroy to release it after use. E.g., after calling
135+
* the function \a ASurfaceTransaction_setLuts.
136+
*
137+
* @return a new \a ADisplayLuts instance
138+
*/
139+
ADisplayLuts* _Nonnull ADisplayLuts_create() __INTRODUCED_IN(36);
140+
141+
/**
142+
* Sets Luts in order to be applied.
143+
*
144+
* The function accepts a single 1D Lut, or a single 3D Lut or both 1D and 3D Lut in order.
145+
* And the function will replace any previously set lut(s).
146+
* If you want to clear the previously set lut(s), set `entries` to be nullptr,
147+
* and `numEntries` will be internally ignored.
148+
*
149+
* @param luts the pointer of the \a ADisplayLuts instance
150+
* @param entries the pointer of the array of lut entries to be applied
151+
* @param numEntries the number of lut entries. The value should be either 1 or 2.
152+
*/
153+
void ADisplayLuts_setEntries(ADisplayLuts* _Nonnull luts,
154+
ADisplayLutsEntry* _Nullable *_Nullable entries, int32_t numEntries) __INTRODUCED_IN(36);
155+
156+
/**
157+
* Deletes the \a ADisplayLuts instance.
158+
*
159+
* @param luts The luts to be destroyed
160+
*/
161+
void ADisplayLuts_destroy(ADisplayLuts* _Nullable luts) __INTRODUCED_IN(36);
162+
163+
__END_DECLS
164+
165+
/** @} */

include/android/looper.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,23 @@ enum {
9090
ALOOPER_POLL_WAKE = -1,
9191

9292
/**
93-
* Result from ALooper_pollOnce() and ALooper_pollAll():
94-
* One or more callbacks were executed.
93+
* Result from ALooper_pollOnce():
94+
* One or more callbacks were executed. The poll may also have been
95+
* explicitly woken by ALooper_wake().
9596
*/
9697
ALOOPER_POLL_CALLBACK = -2,
9798

9899
/**
99100
* Result from ALooper_pollOnce() and ALooper_pollAll():
100-
* The timeout expired.
101+
* The timeout expired. The poll may also have been explicitly woken by
102+
* ALooper_wake().
101103
*/
102104
ALOOPER_POLL_TIMEOUT = -3,
103105

104106
/**
105107
* Result from ALooper_pollOnce() and ALooper_pollAll():
106-
* An error occurred.
108+
* An error occurred. The poll may also have been explicitly woken by
109+
* ALooper_wake(()).
107110
*/
108111
ALOOPER_POLL_ERROR = -4,
109112
};
@@ -182,10 +185,13 @@ typedef int (*ALooper_callbackFunc)(int fd, int events, void* data);
182185
* If the timeout is zero, returns immediately without blocking.
183186
* If the timeout is negative, waits indefinitely until an event appears.
184187
*
188+
* **All return values may also imply ALOOPER_POLL_WAKE.** If you call this in a
189+
* loop, you must treat all return values as if they also indicated
190+
* ALOOPER_POLL_WAKE.
191+
*
185192
* Returns ALOOPER_POLL_WAKE if the poll was awoken using ALooper_wake() before
186193
* the timeout expired and no callbacks were invoked and no other file
187-
* descriptors were ready. **All return values may also imply
188-
* ALOOPER_POLL_WAKE.**
194+
* descriptors were ready.
189195
*
190196
* Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked. The poll
191197
* may also have been explicitly woken by ALooper_wake.
@@ -214,9 +220,9 @@ int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outDa
214220
* data has been consumed or a file descriptor is available with no callback.
215221
* This function will never return ALOOPER_POLL_CALLBACK.
216222
*
217-
* This API cannot be used safely, but a safe alternative exists (see below). As
218-
* such, new builds will not be able to call this API and must migrate to the
219-
* safe API. Binary compatibility is preserved to support already-compiled apps.
223+
* This API will not reliably respond to ALooper_wake. As such, this API is
224+
* hidden and callers should migrate to ALooper_pollOnce. Binary compatibility
225+
* is preserved to support already-compiled apps.
220226
*
221227
* \bug ALooper_pollAll will not wake in response to ALooper_wake calls if it
222228
* also handles another event at the same time.
@@ -235,6 +241,8 @@ int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outDat
235241
*
236242
* This method can be called on any thread.
237243
* This method returns immediately.
244+
*
245+
* \bug ALooper_pollAll will not reliably wake in response to ALooper_wake.
238246
*/
239247
void ALooper_wake(ALooper* looper);
240248

include/android/surface_control.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <sys/cdefs.h>
3030

31+
#include <android/display_luts.h>
3132
#include <android/choreographer.h>
3233
#include <android/data_space.h>
3334
#include <android/hardware_buffer.h>
@@ -712,6 +713,23 @@ void ASurfaceTransaction_setDesiredHdrHeadroom(ASurfaceTransaction* _Nonnull tra
712713
float desiredHeadroom)
713714
__INTRODUCED_IN(__ANDROID_API_V__);
714715

716+
/**
717+
* Sets the Lut(s) to be applied for the layer.
718+
*
719+
* The function makes a deep copy of the provided `luts`.
720+
* Any modifications made to the `luts` object after calling this function
721+
* will not affect the Lut(s) applied to the layer.
722+
*
723+
* @param surface_control The layer where Lut(s) is being applied
724+
* @param luts The Lut(s) to be applied
725+
*
726+
* Available since API level 36.
727+
*/
728+
void ASurfaceTransaction_setLuts(ASurfaceTransaction* _Nonnull transaction,
729+
ASurfaceControl* _Nonnull surface_control,
730+
const struct ADisplayLuts* _Nullable luts)
731+
__INTRODUCED_IN(36);
732+
715733
/**
716734
* Same as ASurfaceTransaction_setFrameRateWithChangeStrategy(transaction, surface_control,
717735
* frameRate, compatibility, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS).

include/input/InputDevice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ enum class InputDeviceSensorType : int32_t {
111111
};
112112

113113
enum class InputDeviceSensorAccuracy : int32_t {
114-
ACCURACY_NONE = 0,
115-
ACCURACY_LOW = 1,
116-
ACCURACY_MEDIUM = 2,
117-
ACCURACY_HIGH = 3,
114+
NONE = 0,
115+
LOW = 1,
116+
MEDIUM = 2,
117+
HIGH = 3,
118118

119-
ftl_last = ACCURACY_HIGH,
119+
ftl_last = HIGH,
120120
};
121121

122122
enum class InputDeviceSensorReportingMode : int32_t {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (C) 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <stdint.h>
20+
#include <vector>
21+
#include <utils/RefBase.h>
22+
23+
using namespace android;
24+
25+
__BEGIN_DECLS
26+
27+
struct ADisplayLutsEntry_buffer {
28+
std::vector<float> data;
29+
};
30+
31+
struct ADisplayLutsEntry_properties {
32+
int32_t dimension;
33+
int32_t size;
34+
int32_t samplingKey;
35+
};
36+
37+
struct ADisplayLutsEntry: public RefBase {
38+
struct ADisplayLutsEntry_buffer buffer;
39+
struct ADisplayLutsEntry_properties properties;
40+
ADisplayLutsEntry() {}
41+
42+
// copy constructor
43+
ADisplayLutsEntry(const ADisplayLutsEntry& other) :
44+
buffer(other.buffer),
45+
properties(other.properties) {}
46+
47+
// copy operator
48+
ADisplayLutsEntry& operator=(const ADisplayLutsEntry& other) {
49+
if (this != &other) { // Protect against self-assignment
50+
buffer = other.buffer;
51+
properties = other.properties;
52+
}
53+
return *this;
54+
}
55+
};
56+
57+
struct ADisplayLuts: public RefBase {
58+
int32_t totalBufferSize;
59+
std::vector<int32_t> offsets;
60+
std::vector<sp<ADisplayLutsEntry>> entries;
61+
62+
ADisplayLuts() : totalBufferSize(0) {}
63+
};
64+
65+
__END_DECLS

libs/binder/include/binder/Parcel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class Parcel {
178178
LIBBINDER_EXPORTED status_t writeUint64(uint64_t val);
179179
LIBBINDER_EXPORTED status_t writeFloat(float val);
180180
LIBBINDER_EXPORTED status_t writeDouble(double val);
181-
LIBBINDER_EXPORTED status_t writeCString(const char* str);
181+
LIBBINDER_EXPORTED status_t writeCString(const char* str)
182+
__attribute__((deprecated("use AIDL, writeString* instead")));
182183
LIBBINDER_EXPORTED status_t writeString8(const String8& str);
183184
LIBBINDER_EXPORTED status_t writeString8(const char* str, size_t len);
184185
LIBBINDER_EXPORTED status_t writeString16(const String16& str);
@@ -434,7 +435,8 @@ class Parcel {
434435
LIBBINDER_EXPORTED status_t readUtf8FromUtf16(std::unique_ptr<std::string>* str) const
435436
__attribute__((deprecated("use std::optional version instead")));
436437

437-
LIBBINDER_EXPORTED const char* readCString() const;
438+
LIBBINDER_EXPORTED const char* readCString() const
439+
__attribute__((deprecated("use AIDL, use readString*")));
438440
LIBBINDER_EXPORTED String8 readString8() const;
439441
LIBBINDER_EXPORTED status_t readString8(String8* pArg) const;
440442
LIBBINDER_EXPORTED const char* readString8Inplace(size_t* outLen) const;

libs/binder/rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub use service::{get_interface, get_service};
126126
#[cfg(not(any(trusty, android_ndk)))]
127127
pub use state::{ProcessState, ThreadState};
128128
#[cfg(not(any(android_vendor, android_vndk, android_ndk)))]
129-
pub use system_only::{delegate_accessor, Accessor, ConnectionInfo};
129+
pub use system_only::{delegate_accessor, Accessor, AccessorProvider, ConnectionInfo};
130130

131131
/// Binder result containing a [`Status`] on error.
132132
pub type Result<T> = std::result::Result<T, Status>;

0 commit comments

Comments
 (0)