Pass through availability of audio mic for input devices.
Bug: 15374820 Change-Id: Id2ca6da10165e3a887ebfbb18f663a3bf316ac79
This commit is contained in:
parent
82f393aad6
commit
063ff53d0b
@ -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;
|
||||
|
@ -127,28 +127,31 @@ String8 getInputDeviceConfigurationFilePathByName(
|
||||
// --- InputDeviceInfo ---
|
||||
|
||||
InputDeviceInfo::InputDeviceInfo() {
|
||||
initialize(-1, 0, -1, InputDeviceIdentifier(), String8(), false);
|
||||
initialize(-1, 0, -1, InputDeviceIdentifier(), String8(), false, false);
|
||||
}
|
||||
|
||||
InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
|
||||
mId(other.mId), mGeneration(other.mGeneration), mControllerNumber(other.mControllerNumber),
|
||||
mIdentifier(other.mIdentifier), mAlias(other.mAlias), mIsExternal(other.mIsExternal),
|
||||
mSources(other.mSources), mKeyboardType(other.mKeyboardType),
|
||||
mKeyCharacterMap(other.mKeyCharacterMap), mHasVibrator(other.mHasVibrator),
|
||||
mHasButtonUnderPad(other.mHasButtonUnderPad), mMotionRanges(other.mMotionRanges) {
|
||||
mHasMic(other.mHasMic), mSources(other.mSources),
|
||||
mKeyboardType(other.mKeyboardType), mKeyCharacterMap(other.mKeyCharacterMap),
|
||||
mHasVibrator(other.mHasVibrator), mHasButtonUnderPad(other.mHasButtonUnderPad),
|
||||
mMotionRanges(other.mMotionRanges) {
|
||||
}
|
||||
|
||||
InputDeviceInfo::~InputDeviceInfo() {
|
||||
}
|
||||
|
||||
void InputDeviceInfo::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) {
|
||||
mId = id;
|
||||
mGeneration = generation;
|
||||
mControllerNumber = controllerNumber;
|
||||
mIdentifier = identifier;
|
||||
mAlias = alias;
|
||||
mIsExternal = isExternal;
|
||||
mHasMic = hasMic;
|
||||
mSources = 0;
|
||||
mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE;
|
||||
mHasVibrator = false;
|
||||
|
@ -1279,6 +1279,11 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Determine whether the device has a mic.
|
||||
if (deviceHasMicLocked(device)) {
|
||||
device->classes |= INPUT_DEVICE_CLASS_MIC;
|
||||
}
|
||||
|
||||
// Determine whether the device is external or internal.
|
||||
if (isExternalDeviceLocked(device)) {
|
||||
device->classes |= INPUT_DEVICE_CLASS_EXTERNAL;
|
||||
@ -1415,6 +1420,16 @@ bool EventHub::isExternalDeviceLocked(Device* device) {
|
||||
return device->identifier.bus == BUS_USB || device->identifier.bus == BUS_BLUETOOTH;
|
||||
}
|
||||
|
||||
bool EventHub::deviceHasMicLocked(Device* device) {
|
||||
if (device->configuration) {
|
||||
bool value;
|
||||
if (device->configuration->tryGetProperty(String8("audio.mic"), value)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t EventHub::getNextControllerNumberLocked(Device* device) {
|
||||
if (mControllerNumbers.isFull()) {
|
||||
ALOGI("Maximum number of controllers reached, assigning controller number 0 to device %s",
|
||||
|
@ -131,6 +131,9 @@ enum {
|
||||
/* The input device has a vibrator (supports FF_RUMBLE). */
|
||||
INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200,
|
||||
|
||||
/* The input device has a microphone. */
|
||||
INPUT_DEVICE_CLASS_MIC = 0x00000400,
|
||||
|
||||
/* The input device is virtual (not a real device, not part of UI configuration). */
|
||||
INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000,
|
||||
|
||||
@ -394,6 +397,7 @@ private:
|
||||
status_t loadKeyMapLocked(Device* device);
|
||||
|
||||
bool isExternalDeviceLocked(Device* device);
|
||||
bool deviceHasMicLocked(Device* device);
|
||||
|
||||
int32_t getNextControllerNumberLocked(Device* device);
|
||||
void releaseControllerNumberLocked(Device* device);
|
||||
|
@ -417,6 +417,11 @@ InputDevice* InputReader::createDeviceLocked(int32_t deviceId, int32_t controlle
|
||||
device->setExternal(true);
|
||||
}
|
||||
|
||||
// Devices with mics.
|
||||
if (classes & INPUT_DEVICE_CLASS_MIC) {
|
||||
device->setMic(true);
|
||||
}
|
||||
|
||||
// Switch-like devices.
|
||||
if (classes & INPUT_DEVICE_CLASS_SWITCH) {
|
||||
device->addMapper(new SwitchInputMapper(device));
|
||||
@ -858,7 +863,7 @@ InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t genera
|
||||
int32_t controllerNumber, const InputDeviceIdentifier& identifier, uint32_t classes) :
|
||||
mContext(context), mId(id), mGeneration(generation), mControllerNumber(controllerNumber),
|
||||
mIdentifier(identifier), mClasses(classes),
|
||||
mSources(0), mIsExternal(false), mDropUntilNextSync(false) {
|
||||
mSources(0), mIsExternal(false), mHasMic(false), mDropUntilNextSync(false) {
|
||||
}
|
||||
|
||||
InputDevice::~InputDevice() {
|
||||
@ -877,6 +882,7 @@ void InputDevice::dump(String8& dump) {
|
||||
deviceInfo.getDisplayName().string());
|
||||
dump.appendFormat(INDENT2 "Generation: %d\n", mGeneration);
|
||||
dump.appendFormat(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
|
||||
dump.appendFormat(INDENT2 "HasMic: %s\n", toString(mHasMic));
|
||||
dump.appendFormat(INDENT2 "Sources: 0x%08x\n", deviceInfo.getSources());
|
||||
dump.appendFormat(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
|
||||
|
||||
@ -1008,8 +1014,7 @@ void InputDevice::timeoutExpired(nsecs_t when) {
|
||||
|
||||
void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) {
|
||||
outDeviceInfo->initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias,
|
||||
mIsExternal);
|
||||
|
||||
mIsExternal, mHasMic);
|
||||
size_t numMappers = mMappers.size();
|
||||
for (size_t i = 0; i < numMappers; i++) {
|
||||
InputMapper* mapper = mMappers[i];
|
||||
|
@ -555,6 +555,9 @@ public:
|
||||
inline bool isExternal() { return mIsExternal; }
|
||||
inline void setExternal(bool external) { mIsExternal = external; }
|
||||
|
||||
inline void setMic(bool hasMic) { mHasMic = hasMic; }
|
||||
inline bool hasMic() const { return mHasMic; }
|
||||
|
||||
inline bool isIgnored() { return mMappers.isEmpty(); }
|
||||
|
||||
void dump(String8& dump);
|
||||
@ -618,6 +621,7 @@ private:
|
||||
|
||||
uint32_t mSources;
|
||||
bool mIsExternal;
|
||||
bool mHasMic;
|
||||
bool mDropUntilNextSync;
|
||||
|
||||
typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code);
|
||||
|
Loading…
Reference in New Issue
Block a user