Android 6.0.1 release 3

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iEYEABECAAYFAlZmBAkACgkQ6K0/gZqxDnhgbQCdFLtubCHWtlKUuIEKAVwzv2M3
 2jMAoI4UhN3nLb2Nf6BizcMSF3xo1pKO
 =NS5T
 -----END PGP SIGNATURE-----

Merge tag 'android-6.0.1_r3' of https://android.googlesource.com/platform/frameworks/native into cm-13.0

Android 6.0.1 release 3

Change-Id: I437aaf148d440a8144afe1454948980fc3b40cca
This commit is contained in:
Steve Kondik 2015-12-07 17:07:16 -08:00
commit 4951bcc16e
16 changed files with 249 additions and 80 deletions

View File

@ -340,13 +340,13 @@ public:
inline void* data() { return mData; } inline void* data() { return mData; }
}; };
#ifndef DISABLE_ASHMEM_TRACKING
private: private:
size_t mBlobAshmemSize; size_t mOpenAshmemSize;
#endif
public: public:
// TODO: Remove once ABI can be changed.
size_t getBlobAshmemSize() const; size_t getBlobAshmemSize() const;
size_t getOpenAshmemSize() const;
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -28,6 +28,7 @@
#include <utils/String8.h> #include <utils/String8.h>
#include <utils/Timers.h> #include <utils/Timers.h>
#include <utils/Vector.h> #include <utils/Vector.h>
#include <stdint.h>
/* /*
* Additional private constants not defined in ndk/ui/input.h. * Additional private constants not defined in ndk/ui/input.h.
@ -110,6 +111,11 @@ enum {
*/ */
#define MAX_POINTERS 16 #define MAX_POINTERS 16
/*
* Maximum number of samples supported per motion event.
*/
#define MAX_SAMPLES UINT16_MAX
/* /*
* Maximum pointer id value supported in a motion event. * Maximum pointer id value supported in a motion event.
* Smallest pointer id is 0. * Smallest pointer id is 0.

View File

@ -124,6 +124,11 @@ public:
* the mapping in some way. */ * the mapping in some way. */
status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const; status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const;
/* Tries to find a replacement key code for a given key code and meta state
* in character map. */
void tryRemapKey(int32_t scanCode, int32_t metaState,
int32_t* outKeyCode, int32_t* outMetaState) const;
#if HAVE_ANDROID_OS #if HAVE_ANDROID_OS
/* Reads a key map from a parcel. */ /* Reads a key map from a parcel. */
static sp<KeyCharacterMap> readFromParcel(Parcel* parcel); static sp<KeyCharacterMap> readFromParcel(Parcel* parcel);
@ -151,6 +156,9 @@ private:
/* The fallback keycode if the key is not handled. */ /* The fallback keycode if the key is not handled. */
int32_t fallbackKeyCode; int32_t fallbackKeyCode;
/* The replacement keycode if the key has to be replaced outright. */
int32_t replacementKeyCode;
}; };
struct Key { struct Key {

View File

@ -87,6 +87,13 @@ extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentif
*/ */
extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState); extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
/**
* Normalizes the meta state such that if either the left or right modifier
* meta state bits are set then the result will also include the universal
* bit for that modifier.
*/
extern int32_t normalizeMetaState(int32_t oldMetaState);
/** /**
* Returns true if a key is a meta key like ALT or CAPS_LOCK. * Returns true if a key is a meta key like ALT or CAPS_LOCK.
*/ */

View File

@ -96,7 +96,7 @@ enum {
}; };
void acquire_object(const sp<ProcessState>& proc, void acquire_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who) const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
{ {
switch (obj.type) { switch (obj.type) {
case BINDER_TYPE_BINDER: case BINDER_TYPE_BINDER:
@ -123,8 +123,15 @@ void acquire_object(const sp<ProcessState>& proc,
return; return;
} }
case BINDER_TYPE_FD: { case BINDER_TYPE_FD: {
// intentionally blank -- nothing to do to acquire this, but we do if (obj.cookie != 0) {
// recognize it as a legitimate object type. if (outAshmemSize != NULL) {
// If we own an ashmem fd, keep track of how much memory it refers to.
int size = ashmem_get_size_region(obj.handle);
if (size > 0) {
*outAshmemSize += size;
}
}
}
return; return;
} }
} }
@ -132,8 +139,14 @@ void acquire_object(const sp<ProcessState>& proc,
ALOGD("Invalid object type 0x%08x", obj.type); ALOGD("Invalid object type 0x%08x", obj.type);
} }
void release_object(const sp<ProcessState>& proc, void acquire_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who) const flat_binder_object& obj, const void* who)
{
acquire_object(proc, obj, who, NULL);
}
static void release_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
{ {
switch (obj.type) { switch (obj.type) {
case BINDER_TYPE_BINDER: case BINDER_TYPE_BINDER:
@ -160,7 +173,16 @@ void release_object(const sp<ProcessState>& proc,
return; return;
} }
case BINDER_TYPE_FD: { case BINDER_TYPE_FD: {
if (obj.cookie != 0) close(obj.handle); if (outAshmemSize != NULL) {
if (obj.cookie != 0) {
int size = ashmem_get_size_region(obj.handle);
if (size > 0) {
*outAshmemSize -= size;
}
close(obj.handle);
}
}
return; return;
} }
} }
@ -168,6 +190,12 @@ void release_object(const sp<ProcessState>& proc,
ALOGE("Invalid object type 0x%08x", obj.type); ALOGE("Invalid object type 0x%08x", obj.type);
} }
void release_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who)
{
release_object(proc, obj, who, NULL);
}
inline static status_t finish_flatten_binder( inline static status_t finish_flatten_binder(
const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out) const sp<IBinder>& /*binder*/, const flat_binder_object& flat, Parcel* out)
{ {
@ -504,7 +532,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
flat_binder_object* flat flat_binder_object* flat
= reinterpret_cast<flat_binder_object*>(mData + off); = reinterpret_cast<flat_binder_object*>(mData + off);
acquire_object(proc, *flat, this); acquire_object(proc, *flat, this, &mOpenAshmemSize);
if (flat->type == BINDER_TYPE_FD) { if (flat->type == BINDER_TYPE_FD) {
// If this is a file descriptor, we need to dup it so the // If this is a file descriptor, we need to dup it so the
@ -922,9 +950,7 @@ status_t Parcel::writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob)
ALOGV("writeBlob: write to ashmem"); ALOGV("writeBlob: write to ashmem");
int fd = ashmem_create_region("Parcel Blob", len); int fd = ashmem_create_region("Parcel Blob", len);
if (fd < 0) return NO_MEMORY; if (fd < 0) return NO_MEMORY;
#ifndef DISABLE_ASHMEM_TRACKING
mBlobAshmemSize += len;
#endif
int result = ashmem_set_prot_region(fd, PROT_READ | PROT_WRITE); int result = ashmem_set_prot_region(fd, PROT_READ | PROT_WRITE);
if (result < 0) { if (result < 0) {
status = result; status = result;
@ -1026,7 +1052,7 @@ restart_write:
// Need to write meta-data? // Need to write meta-data?
if (nullMetaData || val.binder != 0) { if (nullMetaData || val.binder != 0) {
mObjects[mObjectsSize] = mDataPos; mObjects[mObjectsSize] = mDataPos;
acquire_object(ProcessState::self(), val, this); acquire_object(ProcessState::self(), val, this, &mOpenAshmemSize);
mObjectsSize++; mObjectsSize++;
} }
@ -1609,7 +1635,7 @@ void Parcel::releaseObjects()
i--; i--;
const flat_binder_object* flat const flat_binder_object* flat
= reinterpret_cast<flat_binder_object*>(data+objects[i]); = reinterpret_cast<flat_binder_object*>(data+objects[i]);
release_object(proc, *flat, this); release_object(proc, *flat, this, &mOpenAshmemSize);
} }
} }
@ -1623,7 +1649,7 @@ void Parcel::acquireObjects()
i--; i--;
const flat_binder_object* flat const flat_binder_object* flat
= reinterpret_cast<flat_binder_object*>(data+objects[i]); = reinterpret_cast<flat_binder_object*>(data+objects[i]);
acquire_object(proc, *flat, this); acquire_object(proc, *flat, this, &mOpenAshmemSize);
} }
} }
@ -1805,7 +1831,7 @@ status_t Parcel::continueWrite(size_t desired)
// will need to rescan because we may have lopped off the only FDs // will need to rescan because we may have lopped off the only FDs
mFdsKnown = false; mFdsKnown = false;
} }
release_object(proc, *flat, this); release_object(proc, *flat, this, &mOpenAshmemSize);
} }
binder_size_t* objects = binder_size_t* objects =
(binder_size_t*)realloc(mObjects, objectsSize*sizeof(binder_size_t)); (binder_size_t*)realloc(mObjects, objectsSize*sizeof(binder_size_t));
@ -1890,9 +1916,7 @@ void Parcel::initState()
mFdsKnown = true; mFdsKnown = true;
mAllowFds = true; mAllowFds = true;
mOwner = NULL; mOwner = NULL;
#ifndef DISABLE_ASHMEM_TRACKING mOpenAshmemSize = 0;
mBlobAshmemSize = 0;
#endif
} }
void Parcel::scanForFds() const void Parcel::scanForFds() const
@ -1912,11 +1936,15 @@ void Parcel::scanForFds() const
size_t Parcel::getBlobAshmemSize() const size_t Parcel::getBlobAshmemSize() const
{ {
#ifndef DISABLE_ASHMEM_TRACKING // This used to return the size of all blobs that were written to ashmem, now we're returning
return mBlobAshmemSize; // the ashmem currently referenced by this Parcel, which should be equivalent.
#else // TODO: Remove method once ABI can be changed.
return 0; return mOpenAshmemSize;
#endif }
size_t Parcel::getOpenAshmemSize() const
{
return mOpenAshmemSize;
} }
// --- Parcel::Blob --- // --- Parcel::Blob ---

View File

@ -245,6 +245,11 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
break; break;
} }
// Set DATA_INJECTION flag here. Defined in HAL 1_4.
if (halVersion >= SENSORS_DEVICE_API_VERSION_1_4) {
mFlags |= (hwSensor->flags & DATA_INJECTION_MASK);
}
// For the newer HALs log errors if reporting mask flags are set incorrectly. // For the newer HALs log errors if reporting mask flags are set incorrectly.
if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) { if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
// Wake-up flag is set here. // Wake-up flag is set here.

View File

@ -424,7 +424,8 @@ void MotionEvent::transform(const float matrix[9]) {
status_t MotionEvent::readFromParcel(Parcel* parcel) { status_t MotionEvent::readFromParcel(Parcel* parcel) {
size_t pointerCount = parcel->readInt32(); size_t pointerCount = parcel->readInt32();
size_t sampleCount = parcel->readInt32(); size_t sampleCount = parcel->readInt32();
if (pointerCount == 0 || pointerCount > MAX_POINTERS || sampleCount == 0) { if (pointerCount == 0 || pointerCount > MAX_POINTERS ||
sampleCount == 0 || sampleCount > MAX_SAMPLES) {
return BAD_VALUE; return BAD_VALUE;
} }

View File

@ -332,33 +332,75 @@ status_t KeyCharacterMap::mapKey(int32_t scanCode, int32_t usageCode, int32_t* o
if (usageCode) { if (usageCode) {
ssize_t index = mKeysByUsageCode.indexOfKey(usageCode); ssize_t index = mKeysByUsageCode.indexOfKey(usageCode);
if (index >= 0) { if (index >= 0) {
#if DEBUG_MAPPING
ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
scanCode, usageCode, *outKeyCode);
#endif
*outKeyCode = mKeysByUsageCode.valueAt(index); *outKeyCode = mKeysByUsageCode.valueAt(index);
#if DEBUG_MAPPING
ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
scanCode, usageCode, *outKeyCode);
#endif
return OK; return OK;
} }
} }
if (scanCode) { if (scanCode) {
ssize_t index = mKeysByScanCode.indexOfKey(scanCode); ssize_t index = mKeysByScanCode.indexOfKey(scanCode);
if (index >= 0) { if (index >= 0) {
#if DEBUG_MAPPING
ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
scanCode, usageCode, *outKeyCode);
#endif
*outKeyCode = mKeysByScanCode.valueAt(index); *outKeyCode = mKeysByScanCode.valueAt(index);
#if DEBUG_MAPPING
ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d.",
scanCode, usageCode, *outKeyCode);
#endif
return OK; return OK;
} }
} }
#if DEBUG_MAPPING #if DEBUG_MAPPING
ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode); ALOGD("mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
#endif #endif
*outKeyCode = AKEYCODE_UNKNOWN; *outKeyCode = AKEYCODE_UNKNOWN;
return NAME_NOT_FOUND; return NAME_NOT_FOUND;
} }
void KeyCharacterMap::tryRemapKey(int32_t keyCode, int32_t metaState,
int32_t *outKeyCode, int32_t *outMetaState) const {
*outKeyCode = keyCode;
*outMetaState = metaState;
const Key* key;
const Behavior* behavior;
if (getKeyBehavior(keyCode, metaState, &key, &behavior)) {
if (behavior->replacementKeyCode) {
*outKeyCode = behavior->replacementKeyCode;
int32_t newMetaState = metaState & ~behavior->metaState;
// Reset dependent meta states.
if (behavior->metaState & AMETA_ALT_ON) {
newMetaState &= ~(AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON);
}
if (behavior->metaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
newMetaState &= ~AMETA_ALT_ON;
}
if (behavior->metaState & AMETA_CTRL_ON) {
newMetaState &= ~(AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON);
}
if (behavior->metaState & (AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON)) {
newMetaState &= ~AMETA_CTRL_ON;
}
if (behavior->metaState & AMETA_SHIFT_ON) {
newMetaState &= ~(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON);
}
if (behavior->metaState & (AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON)) {
newMetaState &= ~AMETA_SHIFT_ON;
}
// ... and put universal bits back if needed
*outMetaState = normalizeMetaState(newMetaState);
}
}
#if DEBUG_MAPPING
ALOGD("tryRemapKey: keyCode=%d, metaState=0x%08x ~ "
"replacement keyCode=%d, replacement metaState=0x%08x.",
keyCode, metaState, *outKeyCode, *outMetaState);
#endif
}
bool KeyCharacterMap::getKey(int32_t keyCode, const Key** outKey) const { bool KeyCharacterMap::getKey(int32_t keyCode, const Key** outKey) const {
ssize_t index = mKeys.indexOfKey(keyCode); ssize_t index = mKeys.indexOfKey(keyCode);
if (index >= 0) { if (index >= 0) {
@ -584,6 +626,7 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
int32_t metaState = parcel->readInt32(); int32_t metaState = parcel->readInt32();
char16_t character = parcel->readInt32(); char16_t character = parcel->readInt32();
int32_t fallbackKeyCode = parcel->readInt32(); int32_t fallbackKeyCode = parcel->readInt32();
int32_t replacementKeyCode = parcel->readInt32();
if (parcel->errorCheck()) { if (parcel->errorCheck()) {
return NULL; return NULL;
} }
@ -592,6 +635,7 @@ sp<KeyCharacterMap> KeyCharacterMap::readFromParcel(Parcel* parcel) {
behavior->metaState = metaState; behavior->metaState = metaState;
behavior->character = character; behavior->character = character;
behavior->fallbackKeyCode = fallbackKeyCode; behavior->fallbackKeyCode = fallbackKeyCode;
behavior->replacementKeyCode = replacementKeyCode;
if (lastBehavior) { if (lastBehavior) {
lastBehavior->next = behavior; lastBehavior->next = behavior;
} else { } else {
@ -624,6 +668,7 @@ void KeyCharacterMap::writeToParcel(Parcel* parcel) const {
parcel->writeInt32(behavior->metaState); parcel->writeInt32(behavior->metaState);
parcel->writeInt32(behavior->character); parcel->writeInt32(behavior->character);
parcel->writeInt32(behavior->fallbackKeyCode); parcel->writeInt32(behavior->fallbackKeyCode);
parcel->writeInt32(behavior->replacementKeyCode);
} }
parcel->writeInt32(0); parcel->writeInt32(0);
} }
@ -655,13 +700,14 @@ KeyCharacterMap::Key::~Key() {
// --- KeyCharacterMap::Behavior --- // --- KeyCharacterMap::Behavior ---
KeyCharacterMap::Behavior::Behavior() : KeyCharacterMap::Behavior::Behavior() :
next(NULL), metaState(0), character(0), fallbackKeyCode(0) { next(NULL), metaState(0), character(0), fallbackKeyCode(0), replacementKeyCode(0) {
} }
KeyCharacterMap::Behavior::Behavior(const Behavior& other) : KeyCharacterMap::Behavior::Behavior(const Behavior& other) :
next(other.next ? new Behavior(*other.next) : NULL), next(other.next ? new Behavior(*other.next) : NULL),
metaState(other.metaState), character(other.character), metaState(other.metaState), character(other.character),
fallbackKeyCode(other.fallbackKeyCode) { fallbackKeyCode(other.fallbackKeyCode),
replacementKeyCode(other.replacementKeyCode) {
} }
@ -923,6 +969,7 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
Behavior behavior; Behavior behavior;
bool haveCharacter = false; bool haveCharacter = false;
bool haveFallback = false; bool haveFallback = false;
bool haveReplacement = false;
do { do {
char ch = mTokenizer->peekChar(); char ch = mTokenizer->peekChar();
@ -939,6 +986,11 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
mTokenizer->getLocation().string()); mTokenizer->getLocation().string());
return BAD_VALUE; return BAD_VALUE;
} }
if (haveReplacement) {
ALOGE("%s: Cannot combine character literal with replace action.",
mTokenizer->getLocation().string());
return BAD_VALUE;
}
behavior.character = character; behavior.character = character;
haveCharacter = true; haveCharacter = true;
} else { } else {
@ -949,6 +1001,11 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
mTokenizer->getLocation().string()); mTokenizer->getLocation().string());
return BAD_VALUE; return BAD_VALUE;
} }
if (haveReplacement) {
ALOGE("%s: Cannot combine 'none' with replace action.",
mTokenizer->getLocation().string());
return BAD_VALUE;
}
haveCharacter = true; haveCharacter = true;
} else if (token == "fallback") { } else if (token == "fallback") {
mTokenizer->skipDelimiters(WHITESPACE); mTokenizer->skipDelimiters(WHITESPACE);
@ -960,13 +1017,36 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
token.string()); token.string());
return BAD_VALUE; return BAD_VALUE;
} }
if (haveFallback) { if (haveFallback || haveReplacement) {
ALOGE("%s: Cannot combine multiple fallback key codes.", ALOGE("%s: Cannot combine multiple fallback/replacement key codes.",
mTokenizer->getLocation().string()); mTokenizer->getLocation().string());
return BAD_VALUE; return BAD_VALUE;
} }
behavior.fallbackKeyCode = keyCode; behavior.fallbackKeyCode = keyCode;
haveFallback = true; haveFallback = true;
} else if (token == "replace") {
mTokenizer->skipDelimiters(WHITESPACE);
token = mTokenizer->nextToken(WHITESPACE);
int32_t keyCode = getKeyCodeByLabel(token.string());
if (!keyCode) {
ALOGE("%s: Invalid key code label for replace, got '%s'.",
mTokenizer->getLocation().string(),
token.string());
return BAD_VALUE;
}
if (haveCharacter) {
ALOGE("%s: Cannot combine character literal with replace action.",
mTokenizer->getLocation().string());
return BAD_VALUE;
}
if (haveFallback || haveReplacement) {
ALOGE("%s: Cannot combine multiple fallback/replacement key codes.",
mTokenizer->getLocation().string());
return BAD_VALUE;
}
behavior.replacementKeyCode = keyCode;
haveReplacement = true;
} else { } else {
ALOGE("%s: Expected a key behavior after ':'.", ALOGE("%s: Expected a key behavior after ':'.",
mTokenizer->getLocation().string()); mTokenizer->getLocation().string());
@ -1016,8 +1096,10 @@ status_t KeyCharacterMap::Parser::parseKeyProperty() {
newBehavior->next = key->firstBehavior; newBehavior->next = key->firstBehavior;
key->firstBehavior = newBehavior; key->firstBehavior = newBehavior;
#if DEBUG_PARSER #if DEBUG_PARSER
ALOGD("Parsed key meta: keyCode=%d, meta=0x%x, char=%d, fallback=%d.", mKeyCode, ALOGD("Parsed key meta: keyCode=%d, meta=0x%x, char=%d, fallback=%d replace=%d.",
newBehavior->metaState, newBehavior->character, newBehavior->fallbackKeyCode); mKeyCode,
newBehavior->metaState, newBehavior->character,
newBehavior->fallbackKeyCode, newBehavior->replacementKeyCode);
#endif #endif
break; break;
} }

View File

@ -176,6 +176,11 @@ static int32_t setEphemeralMetaState(int32_t mask, bool down, int32_t oldMetaSta
~(mask | AMETA_ALT_ON | AMETA_SHIFT_ON | AMETA_CTRL_ON | AMETA_META_ON); ~(mask | AMETA_ALT_ON | AMETA_SHIFT_ON | AMETA_CTRL_ON | AMETA_META_ON);
} }
return normalizeMetaState(newMetaState);
}
int32_t normalizeMetaState(int32_t oldMetaState) {
int32_t newMetaState = oldMetaState;
if (newMetaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) { if (newMetaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
newMetaState |= AMETA_ALT_ON; newMetaState |= AMETA_ALT_ON;
} }

View File

@ -604,15 +604,6 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
return setError(EGL_BAD_SURFACE, EGL_FALSE); return setError(EGL_BAD_SURFACE, EGL_FALSE);
egl_surface_t * const s = get_surface(surface); egl_surface_t * const s = get_surface(surface);
ANativeWindow* window = s->win.get();
if (window) {
int result = native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL);
if (result != OK) {
ALOGE("eglDestroySurface: native_window_api_disconnect (win=%p) "
"failed (%#x)",
window, result);
}
}
EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface); EGLBoolean result = s->cnx->egl.eglDestroySurface(dp->disp.dpy, s->surface);
if (result == EGL_TRUE) { if (result == EGL_TRUE) {
_s.terminate(); _s.terminate();

View File

@ -438,10 +438,12 @@ bool EventHub::markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
return false; return false;
} }
status_t EventHub::mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, status_t EventHub::mapKey(int32_t deviceId,
int32_t* outKeycode, uint32_t* outFlags) const { int32_t scanCode, int32_t usageCode, int32_t metaState,
int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags) const {
AutoMutex _l(mLock); AutoMutex _l(mLock);
Device* device = getDeviceLocked(deviceId); Device* device = getDeviceLocked(deviceId);
status_t status = NAME_NOT_FOUND;
if (device) { if (device) {
// Check the key character map first. // Check the key character map first.
@ -449,22 +451,34 @@ status_t EventHub::mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
if (kcm != NULL) { if (kcm != NULL) {
if (!kcm->mapKey(scanCode, usageCode, outKeycode)) { if (!kcm->mapKey(scanCode, usageCode, outKeycode)) {
*outFlags = 0; *outFlags = 0;
return NO_ERROR; status = NO_ERROR;
} }
} }
// Check the key layout next. // Check the key layout next.
if (device->keyMap.haveKeyLayout()) { if (status != NO_ERROR && device->keyMap.haveKeyLayout()) {
if (!device->keyMap.keyLayoutMap->mapKey( if (!device->keyMap.keyLayoutMap->mapKey(
scanCode, usageCode, outKeycode, outFlags)) { scanCode, usageCode, outKeycode, outFlags)) {
return NO_ERROR; status = NO_ERROR;
}
}
if (status == NO_ERROR) {
if (kcm != NULL) {
kcm->tryRemapKey(*outKeycode, metaState, outKeycode, outMetaState);
} else {
*outMetaState = metaState;
} }
} }
} }
*outKeycode = 0; if (status != NO_ERROR) {
*outFlags = 0; *outKeycode = 0;
return NAME_NOT_FOUND; *outFlags = 0;
*outMetaState = metaState;
}
return status;
} }
status_t EventHub::mapAxis(int32_t deviceId, int32_t scanCode, AxisInfo* outAxisInfo) const { status_t EventHub::mapAxis(int32_t deviceId, int32_t scanCode, AxisInfo* outAxisInfo) const {

View File

@ -197,8 +197,9 @@ public:
virtual bool hasInputProperty(int32_t deviceId, int property) const = 0; virtual bool hasInputProperty(int32_t deviceId, int property) const = 0;
virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, virtual status_t mapKey(int32_t deviceId,
int32_t* outKeycode, uint32_t* outFlags) const = 0; int32_t scanCode, int32_t usageCode, int32_t metaState,
int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const = 0;
virtual status_t mapAxis(int32_t deviceId, int32_t scanCode, virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
AxisInfo* outAxisInfo) const = 0; AxisInfo* outAxisInfo) const = 0;
@ -285,8 +286,9 @@ public:
virtual bool hasInputProperty(int32_t deviceId, int property) const; virtual bool hasInputProperty(int32_t deviceId, int property) const;
virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, virtual status_t mapKey(int32_t deviceId,
int32_t* outKeycode, uint32_t* outFlags) const; int32_t scanCode, int32_t usageCode, int32_t metaState,
int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const;
virtual status_t mapAxis(int32_t deviceId, int32_t scanCode, virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
AxisInfo* outAxisInfo) const; AxisInfo* outAxisInfo) const;

View File

@ -2193,13 +2193,7 @@ void KeyboardInputMapper::process(const RawEvent* rawEvent) {
mCurrentHidUsage = 0; mCurrentHidUsage = 0;
if (isKeyboardOrGamepadKey(scanCode)) { if (isKeyboardOrGamepadKey(scanCode)) {
int32_t keyCode; processKey(rawEvent->when, rawEvent->value != 0, scanCode, usageCode);
uint32_t flags;
if (getEventHub()->mapKey(getDeviceId(), scanCode, usageCode, &keyCode, &flags)) {
keyCode = AKEYCODE_UNKNOWN;
flags = 0;
}
processKey(rawEvent->when, rawEvent->value != 0, keyCode, scanCode, flags);
} }
break; break;
} }
@ -2224,8 +2218,18 @@ bool KeyboardInputMapper::isKeyboardOrGamepadKey(int32_t scanCode) {
|| (scanCode >= BTN_JOYSTICK && scanCode < BTN_DIGI); || (scanCode >= BTN_JOYSTICK && scanCode < BTN_DIGI);
} }
void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode, void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode,
int32_t scanCode, uint32_t policyFlags) { int32_t usageCode) {
int32_t keyCode;
int32_t keyMetaState;
uint32_t policyFlags;
if (getEventHub()->mapKey(getDeviceId(), scanCode, usageCode, mMetaState,
&keyCode, &keyMetaState, &policyFlags)) {
keyCode = AKEYCODE_UNKNOWN;
keyMetaState = mMetaState;
policyFlags = 0;
}
if (down) { if (down) {
// Rotate key codes according to orientation if needed. // Rotate key codes according to orientation if needed.
@ -2278,6 +2282,12 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
if (metaStateChanged) { if (metaStateChanged) {
mMetaState = newMetaState; mMetaState = newMetaState;
updateLedState(false); updateLedState(false);
// If global meta state changed send it along with the key.
// If it has not changed then we'll use what keymap gave us,
// since key replacement logic might temporarily reset a few
// meta bits for given key.
keyMetaState = newMetaState;
} }
nsecs_t downTime = mDownTime; nsecs_t downTime = mDownTime;
@ -2305,7 +2315,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
NotifyKeyArgs args(when, getDeviceId(), mSource, policyFlags, NotifyKeyArgs args(when, getDeviceId(), mSource, policyFlags,
down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP,
AKEY_EVENT_FLAG_FROM_SYSTEM, keyCode, scanCode, newMetaState, downTime); AKEY_EVENT_FLAG_FROM_SYSTEM, keyCode, scanCode, keyMetaState, downTime);
getListener()->notifyKey(&args); getListener()->notifyKey(&args);
} }
@ -3568,8 +3578,10 @@ void TouchInputMapper::configureVirtualKeys() {
virtualKey.scanCode = virtualKeyDefinition.scanCode; virtualKey.scanCode = virtualKeyDefinition.scanCode;
int32_t keyCode; int32_t keyCode;
int32_t dummyKeyMetaState;
uint32_t flags; uint32_t flags;
if (getEventHub()->mapKey(getDeviceId(), virtualKey.scanCode, 0, &keyCode, &flags)) { if (getEventHub()->mapKey(getDeviceId(), virtualKey.scanCode, 0, 0,
&keyCode, &dummyKeyMetaState, &flags)) {
ALOGW(INDENT "VirtualKey %d: could not obtain key code, ignoring", ALOGW(INDENT "VirtualKey %d: could not obtain key code, ignoring",
virtualKey.scanCode); virtualKey.scanCode);
mVirtualKeys.pop(); // drop the key mVirtualKeys.pop(); // drop the key

View File

@ -1175,8 +1175,7 @@ private:
bool isKeyboardOrGamepadKey(int32_t scanCode); bool isKeyboardOrGamepadKey(int32_t scanCode);
void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode, void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode);
uint32_t policyFlags);
ssize_t findKeyDown(int32_t scanCode); ssize_t findKeyDown(int32_t scanCode);

View File

@ -518,8 +518,9 @@ private:
return false; return false;
} }
virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, virtual status_t mapKey(int32_t deviceId,
int32_t* outKeycode, uint32_t* outFlags) const { int32_t scanCode, int32_t usageCode, int32_t metaState,
int32_t* outKeycode, int32_t *outMetaState, uint32_t* outFlags) const {
Device* device = getDevice(deviceId); Device* device = getDevice(deviceId);
if (device) { if (device) {
const KeyInfo* key = getKey(device, scanCode, usageCode); const KeyInfo* key = getKey(device, scanCode, usageCode);
@ -530,6 +531,9 @@ private:
if (outFlags) { if (outFlags) {
*outFlags = key->flags; *outFlags = key->flags;
} }
if (outMetaState) {
*outMetaState = metaState;
}
return OK; return OK;
} }
} }

View File

@ -913,11 +913,16 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs, status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
maxBatchReportLatencyNs); maxBatchReportLatencyNs);
// Call flush() before calling activate() on the sensor. Wait for a first flush complete // Call flush() before calling activate() on the sensor. Wait for a first
// event before sending events on this connection. Ignore one-shot sensors which don't // flush complete event before sending events on this connection. Ignore
// support flush(). Also if this sensor isn't already active, don't call flush(). // one-shot sensors which don't support flush(). Ignore on-change sensors
// to maintain the on-change logic (any on-change events except the initial
// one should be trigger by a change in value). Also if this sensor isn't
// already active, don't call flush().
const SensorDevice& device(SensorDevice::getInstance()); const SensorDevice& device(SensorDevice::getInstance());
if (err == NO_ERROR && sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT && if (err == NO_ERROR &&
sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT &&
sensor->getSensor().getReportingMode() != AREPORTING_MODE_ON_CHANGE &&
rec->getNumConnections() > 1) { rec->getNumConnections() > 1) {
if (device.getHalDeviceVersion() >= SENSORS_DEVICE_API_VERSION_1_1) { if (device.getHalDeviceVersion() >= SENSORS_DEVICE_API_VERSION_1_1) {
connection->setFirstFlushPending(handle, true); connection->setFirstFlushPending(handle, true);