summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:25:49 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:25:49 +0000
commit6e3cba486c6d8be1c397d9bedbf5a3839ed4a5ba (patch)
treece69c96d1da077ad8275e63bb7de0f77c94f6c69
parentfdfd24f35c8750f18479f5a78369b094ba6da2ba (diff)
parent0a298ae489baef216cd379152ea078f6b55fb8cd (diff)
downloadlibhardware-6e3cba486c6d8be1c397d9bedbf5a3839ed4a5ba.tar.gz
Snap for 6439596 from 0a298ae489baef216cd379152ea078f6b55fb8cd to qt-aml-tzdata-releaseandroid-mainline-10.0.0_r11
Change-Id: Ib2351e74c00ec7440d1395864aebaa03b4e4f92b
-rw-r--r--modules/audio_remote_submix/Android.bp7
-rw-r--r--modules/audio_remote_submix/audio_hw.cpp14
-rw-r--r--modules/gralloc/framebuffer.cpp19
-rw-r--r--modules/gralloc/gr.h2
-rw-r--r--modules/gralloc/gralloc.cpp10
-rw-r--r--modules/input/evdev/InputDevice.cpp21
-rw-r--r--modules/input/evdev/InputDevice.h3
-rw-r--r--modules/sensors/OWNERS2
-rw-r--r--modules/sensors/dynamic_sensor/Android.bp2
-rw-r--r--tests/input/evdev/InputDevice_test.cpp31
-rw-r--r--tests/keymaster/keymaster_test.cpp64
11 files changed, 122 insertions, 53 deletions
diff --git a/modules/audio_remote_submix/Android.bp b/modules/audio_remote_submix/Android.bp
index 95234380..c7d018c0 100644
--- a/modules/audio_remote_submix/Android.bp
+++ b/modules/audio_remote_submix/Android.bp
@@ -17,13 +17,16 @@ cc_library_shared {
relative_install_path: "hw",
vendor: true,
srcs: ["audio_hw.cpp"],
+ include_dirs: [
+ "system/media/audio_utils/include",
+ ],
shared_libs: [
"liblog",
"libcutils",
- "libmedia_helper",
- "libnbaio_mono",
"libutils",
+ "libnbaio_mono",
],
+ static_libs: ["libmedia_helper"],
cflags: ["-Wno-unused-parameter"],
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index f7786938..833c12bb 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -472,7 +472,7 @@ static void submix_audio_device_release_pipe_l(struct submix_audio_device * cons
rsxadev->routes[route_idx].rsxSource.clear();
}
memset(rsxadev->routes[route_idx].address, 0, AUDIO_DEVICE_MAX_ADDRESS_LEN);
-#if ENABLE_RESAMPLING
+#ifdef ENABLE_RESAMPLING
memset(rsxadev->routes[route_idx].resampler_buffer, 0,
sizeof(int16_t) * DEFAULT_PIPE_SIZE_IN_FRAMES);
#endif
@@ -499,9 +499,7 @@ static void submix_audio_device_destroy_pipe_l(struct submix_audio_device * cons
}
ALOGV("submix_audio_device_destroy_pipe_l(): input ref_count %d", in->ref_count);
#else
- route_idx = in->route_handle;
- ALOG_ASSERT(rsxadev->routes[route_idx].input == in);
- rsxadev->routes[route_idx].input = NULL;
+ rsxadev->input = NULL;
shut_down = true;
#endif // ENABLE_LEGACY_INPUT_OPEN
if (shut_down) {
@@ -1625,9 +1623,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
if (!in) {
in = (struct submix_stream_in *)calloc(1, sizeof(struct submix_stream_in));
if (!in) return -ENOMEM;
-#if ENABLE_LEGACY_INPUT_OPEN
in->ref_count = 1;
-#endif
// Initialize the function pointer tables (v-tables).
in->stream.common.get_sample_rate = in_get_sample_rate;
@@ -1718,16 +1714,10 @@ static int adev_dump(const audio_hw_device_t *device, int fd)
int n = snprintf(msg, sizeof(msg), "\nReroute submix audio module:\n");
write(fd, &msg, n);
for (int i=0 ; i < MAX_ROUTES ; i++) {
-#if ENABLE_RESAMPLING
n = snprintf(msg, sizeof(msg), " route[%d] rate in=%d out=%d, addr=[%s]\n", i,
rsxadev->routes[i].config.input_sample_rate,
rsxadev->routes[i].config.output_sample_rate,
rsxadev->routes[i].address);
-#else
- n = snprintf(msg, sizeof(msg), " route[%d], rate=%d addr=[%s]\n", i,
- rsxadev->routes[i].config.common.sample_rate,
- rsxadev->routes[i].address);
-#endif
write(fd, &msg, n);
}
return 0;
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index b2ec3e44..c1717115 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -117,7 +117,7 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
/*****************************************************************************/
-int mapFrameBufferLocked(struct private_module_t* module, int format)
+int mapFrameBufferLocked(struct private_module_t* module)
{
// already initialized...
if (module->framebuffer) {
@@ -161,20 +161,6 @@ int mapFrameBufferLocked(struct private_module_t* module, int format)
*/
info.yres_virtual = info.yres * NUM_BUFFERS;
- switch (format) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- info.bits_per_pixel = 32;
- info.red.offset = 0;
- info.red.length = 8;
- info.green.offset = 8;
- info.green.length = 8;
- info.blue.offset = 16;
- info.blue.length = 8;
- break;
- default:
- ALOGW("unknown format: %d", format);
- break;
- }
uint32_t flags = PAGE_FLIP;
#if USE_PAN_DISPLAY
@@ -294,8 +280,7 @@ int mapFrameBufferLocked(struct private_module_t* module, int format)
static int mapFrameBuffer(struct private_module_t* module)
{
pthread_mutex_lock(&module->lock);
- // Request RGBA8888 because the platform assumes support for RGBA8888.
- int err = mapFrameBufferLocked(module, HAL_PIXEL_FORMAT_RGBA_8888);
+ int err = mapFrameBufferLocked(module);
pthread_mutex_unlock(&module->lock);
return err;
}
diff --git a/modules/gralloc/gr.h b/modules/gralloc/gr.h
index 14fe6a05..ac7e9670 100644
--- a/modules/gralloc/gr.h
+++ b/modules/gralloc/gr.h
@@ -36,7 +36,7 @@ inline size_t roundUpToPageSize(size_t x) {
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}
-int mapFrameBufferLocked(struct private_module_t* module, int format);
+int mapFrameBufferLocked(struct private_module_t* module);
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd);
int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd);
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp
index 87bda975..07bbfbac 100644
--- a/modules/gralloc/gralloc.cpp
+++ b/modules/gralloc/gralloc.cpp
@@ -101,7 +101,7 @@ struct private_module_t HAL_MODULE_INFO_SYM = {
/*****************************************************************************/
static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
- size_t size, int format, int usage, buffer_handle_t* pHandle)
+ size_t size, int usage, buffer_handle_t* pHandle)
{
private_module_t* m = reinterpret_cast<private_module_t*>(
dev->common.module);
@@ -110,7 +110,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
if (m->framebuffer == NULL) {
// initialize the framebuffer, the framebuffer is mapped once
// and forever.
- int err = mapFrameBufferLocked(m, format);
+ int err = mapFrameBufferLocked(m);
if (err < 0) {
return err;
}
@@ -154,12 +154,12 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev,
}
static int gralloc_alloc_framebuffer(alloc_device_t* dev,
- size_t size, int format, int usage, buffer_handle_t* pHandle)
+ size_t size, int usage, buffer_handle_t* pHandle)
{
private_module_t* m = reinterpret_cast<private_module_t*>(
dev->common.module);
pthread_mutex_lock(&m->lock);
- int err = gralloc_alloc_framebuffer_locked(dev, size, format, usage, pHandle);
+ int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle);
pthread_mutex_unlock(&m->lock);
return err;
}
@@ -236,7 +236,7 @@ static int gralloc_alloc(alloc_device_t* dev,
int err;
if (usage & GRALLOC_USAGE_HW_FB) {
- err = gralloc_alloc_framebuffer(dev, size, format, usage, pHandle);
+ err = gralloc_alloc_framebuffer(dev, size, usage, pHandle);
} else {
err = gralloc_alloc_buffer(dev, size, usage, pHandle);
}
diff --git a/modules/input/evdev/InputDevice.cpp b/modules/input/evdev/InputDevice.cpp
index a1bce643..3b72f1fb 100644
--- a/modules/input/evdev/InputDevice.cpp
+++ b/modules/input/evdev/InputDevice.cpp
@@ -37,6 +37,8 @@
#include "MouseInputMapper.h"
#include "SwitchInputMapper.h"
+#define MSC_ANDROID_TIME_SEC 0x6
+#define MSC_ANDROID_TIME_USEC 0x7
namespace android {
@@ -238,6 +240,25 @@ void EvdevDevice::processInput(InputEvent& event, nsecs_t currentTime) {
event.value);
#endif
+ if (event.type == EV_MSC) {
+ if (event.code == MSC_ANDROID_TIME_SEC) {
+ mOverrideSec = event.value;
+ } else if (event.code == MSC_ANDROID_TIME_USEC) {
+ mOverrideUsec = event.value;
+ }
+ return;
+ }
+
+ if (mOverrideSec || mOverrideUsec) {
+ event.when = s2ns(mOverrideSec) + us2ns(mOverrideUsec);
+ ALOGV("applied override time %d.%06d", mOverrideSec, mOverrideUsec);
+
+ if (event.type == EV_SYN && event.code == SYN_REPORT) {
+ mOverrideSec = 0;
+ mOverrideUsec = 0;
+ }
+ }
+
// Bug 7291243: Add a guard in case the kernel generates timestamps
// that appear to be far into the future because they were generated
// using the wrong clock source.
diff --git a/modules/input/evdev/InputDevice.h b/modules/input/evdev/InputDevice.h
index a1e9e98c..68927780 100644
--- a/modules/input/evdev/InputDevice.h
+++ b/modules/input/evdev/InputDevice.h
@@ -72,6 +72,9 @@ private:
InputDeviceHandle* mDeviceHandle = nullptr;
std::vector<std::unique_ptr<InputMapper>> mMappers;
uint32_t mClasses = 0;
+
+ int32_t mOverrideSec = 0;
+ int32_t mOverrideUsec = 0;
};
/* Input device classes. */
diff --git a/modules/sensors/OWNERS b/modules/sensors/OWNERS
index 90c23303..81099e89 100644
--- a/modules/sensors/OWNERS
+++ b/modules/sensors/OWNERS
@@ -1,3 +1,3 @@
arthuri@google.com
bduddie@google.com
-stange@google.com
+bstack@google.com
diff --git a/modules/sensors/dynamic_sensor/Android.bp b/modules/sensors/dynamic_sensor/Android.bp
index 214d97cf..489cdf4c 100644
--- a/modules/sensors/dynamic_sensor/Android.bp
+++ b/modules/sensors/dynamic_sensor/Android.bp
@@ -22,6 +22,8 @@ cc_defaults {
"-Wall",
"-Werror",
"-Wextra",
+ // Allow implicit fallthroughs in HidRawSensor.cpp until they are fixed.
+ "-Wno-error=implicit-fallthrough",
],
export_include_dirs: ["."],
diff --git a/tests/input/evdev/InputDevice_test.cpp b/tests/input/evdev/InputDevice_test.cpp
index 8f8a94b4..bd574910 100644
--- a/tests/input/evdev/InputDevice_test.cpp
+++ b/tests/input/evdev/InputDevice_test.cpp
@@ -31,6 +31,8 @@
// # of milliseconds to allow for timing measurements
#define TIMING_TOLERANCE_MS 25
+#define MSC_ANDROID_TIME_SEC 0x6
+#define MSC_ANDROID_TIME_USEC 0x7
using ::testing::_;
using ::testing::NiceMock;
@@ -64,6 +66,35 @@ protected:
NiceMock<MockInputDeviceDefinition> mDeviceDef;
};
+TEST_F(EvdevDeviceTest, testOverrideTime) {
+ auto node = std::make_shared<MockInputDeviceNode>();
+ auto device = std::make_unique<EvdevDevice>(&mHost, node);
+ ASSERT_TRUE(device != nullptr);
+
+ // Send two timestamp override events before an input event.
+ nsecs_t when = 2ULL;
+ InputEvent msc1 = { when, EV_MSC, MSC_ANDROID_TIME_SEC, 1 };
+ InputEvent msc2 = { when, EV_MSC, MSC_ANDROID_TIME_USEC, 900000 };
+
+ // Send a key down and syn. Should get the overridden timestamp.
+ InputEvent keyDown = { when, EV_KEY, KEY_HOME, 1 };
+ InputEvent syn = { when, EV_SYN, SYN_REPORT, 0 };
+
+ // Send a key up, which should be at the reported timestamp.
+ InputEvent keyUp = { when, EV_KEY, KEY_HOME, 0 };
+
+ device->processInput(msc1, when);
+ device->processInput(msc2, when);
+ device->processInput(keyDown, when);
+ device->processInput(syn, when);
+ device->processInput(keyUp, when);
+
+ nsecs_t expectedWhen = s2ns(1) + us2ns(900000);
+ EXPECT_EQ(expectedWhen, keyDown.when);
+ EXPECT_EQ(expectedWhen, syn.when);
+ EXPECT_EQ(when, keyUp.when);
+}
+
TEST_F(EvdevDeviceTest, testWrongClockCorrection) {
auto node = std::make_shared<MockInputDeviceNode>();
auto device = std::make_unique<EvdevDevice>(&mHost, node);
diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp
index 562c8ed3..e6b41c7a 100644
--- a/tests/keymaster/keymaster_test.cpp
+++ b/tests/keymaster/keymaster_test.cpp
@@ -29,7 +29,6 @@
#include <openssl/bn.h>
#include <openssl/evp.h>
-#include <openssl/pkcs8.h>
#include <openssl/x509.h>
#define LOG_TAG "keymaster_test"
@@ -159,6 +158,41 @@ private:
size_t mDataSize;
};
+struct BIGNUM_Delete {
+ void operator()(BIGNUM* p) const {
+ BN_free(p);
+ }
+};
+typedef std::unique_ptr<BIGNUM, BIGNUM_Delete> Unique_BIGNUM;
+
+struct EVP_PKEY_Delete {
+ void operator()(EVP_PKEY* p) const {
+ EVP_PKEY_free(p);
+ }
+};
+typedef std::unique_ptr<EVP_PKEY, EVP_PKEY_Delete> Unique_EVP_PKEY;
+
+struct PKCS8_PRIV_KEY_INFO_Delete {
+ void operator()(PKCS8_PRIV_KEY_INFO* p) const {
+ PKCS8_PRIV_KEY_INFO_free(p);
+ }
+};
+typedef std::unique_ptr<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_Delete> Unique_PKCS8_PRIV_KEY_INFO;
+
+struct RSA_Delete {
+ void operator()(RSA* p) const {
+ RSA_free(p);
+ }
+};
+typedef std::unique_ptr<RSA, RSA_Delete> Unique_RSA;
+
+struct EC_KEY_Delete {
+ void operator()(EC_KEY* p) const {
+ EC_KEY_free(p);
+ }
+};
+typedef std::unique_ptr<EC_KEY, EC_KEY_Delete> Unique_EC_KEY;
+
/*
* DER-encoded PKCS#8 format RSA key. Generated using:
@@ -383,13 +417,13 @@ TEST_P(KeymasterGenerateRSATest, GenerateKeyPair_RSA_Success) {
<< "X509 data should be allocated";
const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
- bssl::UniquePtr<EVP_PKEY> actual(d2i_PUBKEY(NULL, &tmp,
+ Unique_EVP_PKEY actual(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
static_cast<long>(x509_blob.length())));
ASSERT_EQ(EVP_PKEY_RSA, EVP_PKEY_type(actual.get()->type))
<< "Generated key type should be of type RSA";
- bssl::UniquePtr<RSA> rsa(EVP_PKEY_get1_RSA(actual.get()));
+ Unique_RSA rsa(EVP_PKEY_get1_RSA(actual.get()));
ASSERT_FALSE(rsa.get() == NULL)
<< "Should be able to extract RSA key from EVP_PKEY";
@@ -430,13 +464,13 @@ TEST_P(KeymasterGenerateECTest, GenerateKeyPair_EC_Success) {
<< "X509 data should be allocated";
const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
- bssl::UniquePtr<EVP_PKEY> actual(d2i_PUBKEY(NULL, &tmp,
+ Unique_EVP_PKEY actual(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
static_cast<long>(x509_blob.length())));
ASSERT_EQ(EVP_PKEY_EC, EVP_PKEY_type(actual.get()->type))
<< "Generated key type should be of type EC";
- bssl::UniquePtr<EC_KEY> ecKey(EVP_PKEY_get1_EC_KEY(actual.get()));
+ Unique_EC_KEY ecKey(EVP_PKEY_get1_EC_KEY(actual.get()));
ASSERT_FALSE(ecKey.get() == NULL)
<< "Should be able to extract EC key from EVP_PKEY";
@@ -497,18 +531,18 @@ TEST_F(KeymasterTest, ImportKeyPair_RSA_Success) {
UniqueBlob x509_blob(x509_data, x509_data_length);
const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
- bssl::UniquePtr<EVP_PKEY> actual(d2i_PUBKEY(NULL, &tmp,
+ Unique_EVP_PKEY actual(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
static_cast<long>(x509_blob.length())));
ASSERT_EQ(EVP_PKEY_type(actual.get()->type), EVP_PKEY_RSA)
<< "Generated key type should be of type RSA";
const unsigned char *expectedTmp = static_cast<const unsigned char*>(TEST_RSA_KEY_1);
- bssl::UniquePtr<PKCS8_PRIV_KEY_INFO> expectedPkcs8(
- d2i_PKCS8_PRIV_KEY_INFO(NULL, &expectedTmp,
+ Unique_PKCS8_PRIV_KEY_INFO expectedPkcs8(
+ d2i_PKCS8_PRIV_KEY_INFO((PKCS8_PRIV_KEY_INFO**) NULL, &expectedTmp,
sizeof(TEST_RSA_KEY_1)));
- bssl::UniquePtr<EVP_PKEY> expected(EVP_PKCS82PKEY(expectedPkcs8.get()));
+ Unique_EVP_PKEY expected(EVP_PKCS82PKEY(expectedPkcs8.get()));
ASSERT_EQ(1, EVP_PKEY_cmp(expected.get(), actual.get()))
<< "Expected and actual keys should match";
@@ -533,18 +567,18 @@ TEST_F(KeymasterTest, ImportKeyPair_EC_Success) {
UniqueBlob x509_blob(x509_data, x509_data_length);
const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
- bssl::UniquePtr<EVP_PKEY> actual(d2i_PUBKEY(NULL, &tmp,
+ Unique_EVP_PKEY actual(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
static_cast<long>(x509_blob.length())));
ASSERT_EQ(EVP_PKEY_type(actual.get()->type), EVP_PKEY_EC)
<< "Generated key type should be of type EC";
const unsigned char *expectedTmp = static_cast<const unsigned char*>(TEST_EC_KEY_1);
- bssl::UniquePtr<PKCS8_PRIV_KEY_INFO> expectedPkcs8(
- d2i_PKCS8_PRIV_KEY_INFO(NULL, &expectedTmp,
+ Unique_PKCS8_PRIV_KEY_INFO expectedPkcs8(
+ d2i_PKCS8_PRIV_KEY_INFO((PKCS8_PRIV_KEY_INFO**) NULL, &expectedTmp,
sizeof(TEST_EC_KEY_1)));
- bssl::UniquePtr<EVP_PKEY> expected(EVP_PKCS82PKEY(expectedPkcs8.get()));
+ Unique_EVP_PKEY expected(EVP_PKCS82PKEY(expectedPkcs8.get()));
ASSERT_EQ(1, EVP_PKEY_cmp(expected.get(), actual.get()))
<< "Expected and actual keys should match";
@@ -891,10 +925,10 @@ TEST_F(KeymasterTest, SignData_EC_Success) {
UniqueBlob x509_blob(x509_data, x509_data_length);
const unsigned char *tmp = static_cast<const unsigned char*>(x509_blob.get());
- bssl::UniquePtr<EVP_PKEY> expected(d2i_PUBKEY(NULL, &tmp,
+ Unique_EVP_PKEY expected(d2i_PUBKEY((EVP_PKEY**) NULL, &tmp,
static_cast<long>(x509_blob.length())));
- bssl::UniquePtr<EC_KEY> ecKey(EVP_PKEY_get1_EC_KEY(expected.get()));
+ Unique_EC_KEY ecKey(EVP_PKEY_get1_EC_KEY(expected.get()));
ASSERT_EQ(1, ECDSA_verify(0, testData.get(), testData.length(), sig_blob.get(), sig_blob.length(), ecKey.get()))
<< "Signature should verify";