Merge "Use std::mutex instead of AutoMutex" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bd73765b69
@@ -379,7 +379,7 @@ private:
|
|||||||
jobject mServiceObj;
|
jobject mServiceObj;
|
||||||
sp<Looper> mLooper;
|
sp<Looper> mLooper;
|
||||||
|
|
||||||
Mutex mLock;
|
std::mutex mLock;
|
||||||
struct Locked {
|
struct Locked {
|
||||||
// Display size information.
|
// Display size information.
|
||||||
std::vector<DisplayViewport> viewports{};
|
std::vector<DisplayViewport> viewports{};
|
||||||
@@ -469,7 +469,7 @@ void NativeInputManager::dump(std::string& dump) {
|
|||||||
dump += StringPrintf(INDENT "Interactive: %s\n", toString(mInteractive.load()));
|
dump += StringPrintf(INDENT "Interactive: %s\n", toString(mInteractive.load()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
dump += StringPrintf(INDENT "System UI Lights Out: %s\n",
|
dump += StringPrintf(INDENT "System UI Lights Out: %s\n",
|
||||||
toString(mLocked.systemUiLightsOut));
|
toString(mLocked.systemUiLightsOut));
|
||||||
dump += StringPrintf(INDENT "Pointer Speed: %" PRId32 "\n", mLocked.pointerSpeed);
|
dump += StringPrintf(INDENT "Pointer Speed: %" PRId32 "\n", mLocked.pointerSpeed);
|
||||||
@@ -532,7 +532,7 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
mLocked.viewports = viewports;
|
mLocked.viewports = viewports;
|
||||||
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
||||||
if (controller != nullptr) {
|
if (controller != nullptr) {
|
||||||
@@ -669,7 +669,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
outConfig->pointerVelocityControlParameters.scale = exp2f(mLocked.pointerSpeed
|
outConfig->pointerVelocityControlParameters.scale = exp2f(mLocked.pointerSpeed
|
||||||
* POINTER_SPEED_EXPONENT);
|
* POINTER_SPEED_EXPONENT);
|
||||||
@@ -717,7 +717,7 @@ std::unordered_map<std::string, T> NativeInputManager::readMapFromInterleavedJav
|
|||||||
std::shared_ptr<PointerControllerInterface> NativeInputManager::obtainPointerController(
|
std::shared_ptr<PointerControllerInterface> NativeInputManager::obtainPointerController(
|
||||||
int32_t /* deviceId */) {
|
int32_t /* deviceId */) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
||||||
if (controller == nullptr) {
|
if (controller == nullptr) {
|
||||||
@@ -1065,7 +1065,7 @@ void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeInputManager::setSystemUiLightsOut(bool lightsOut) {
|
void NativeInputManager::setSystemUiLightsOut(bool lightsOut) {
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.systemUiLightsOut != lightsOut) {
|
if (mLocked.systemUiLightsOut != lightsOut) {
|
||||||
mLocked.systemUiLightsOut = lightsOut;
|
mLocked.systemUiLightsOut = lightsOut;
|
||||||
@@ -1085,7 +1085,7 @@ void NativeInputManager::updateInactivityTimeoutLocked() REQUIRES(mLock) {
|
|||||||
|
|
||||||
void NativeInputManager::setPointerDisplayId(int32_t displayId) {
|
void NativeInputManager::setPointerDisplayId(int32_t displayId) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.pointerDisplayId == displayId) {
|
if (mLocked.pointerDisplayId == displayId) {
|
||||||
return;
|
return;
|
||||||
@@ -1101,7 +1101,7 @@ void NativeInputManager::setPointerDisplayId(int32_t displayId) {
|
|||||||
|
|
||||||
void NativeInputManager::setPointerSpeed(int32_t speed) {
|
void NativeInputManager::setPointerSpeed(int32_t speed) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.pointerSpeed == speed) {
|
if (mLocked.pointerSpeed == speed) {
|
||||||
return;
|
return;
|
||||||
@@ -1117,7 +1117,7 @@ void NativeInputManager::setPointerSpeed(int32_t speed) {
|
|||||||
|
|
||||||
void NativeInputManager::setPointerAcceleration(float acceleration) {
|
void NativeInputManager::setPointerAcceleration(float acceleration) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.pointerAcceleration == acceleration) {
|
if (mLocked.pointerAcceleration == acceleration) {
|
||||||
return;
|
return;
|
||||||
@@ -1133,7 +1133,7 @@ void NativeInputManager::setPointerAcceleration(float acceleration) {
|
|||||||
|
|
||||||
void NativeInputManager::setTouchpadPointerSpeed(int32_t speed) {
|
void NativeInputManager::setTouchpadPointerSpeed(int32_t speed) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.touchpadPointerSpeed == speed) {
|
if (mLocked.touchpadPointerSpeed == speed) {
|
||||||
return;
|
return;
|
||||||
@@ -1149,7 +1149,7 @@ void NativeInputManager::setTouchpadPointerSpeed(int32_t speed) {
|
|||||||
|
|
||||||
void NativeInputManager::setTouchpadNaturalScrollingEnabled(bool enabled) {
|
void NativeInputManager::setTouchpadNaturalScrollingEnabled(bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.touchpadNaturalScrollingEnabled == enabled) {
|
if (mLocked.touchpadNaturalScrollingEnabled == enabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1165,7 +1165,7 @@ void NativeInputManager::setTouchpadNaturalScrollingEnabled(bool enabled) {
|
|||||||
|
|
||||||
void NativeInputManager::setTouchpadTapToClickEnabled(bool enabled) {
|
void NativeInputManager::setTouchpadTapToClickEnabled(bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.touchpadTapToClickEnabled == enabled) {
|
if (mLocked.touchpadTapToClickEnabled == enabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1181,7 +1181,7 @@ void NativeInputManager::setTouchpadTapToClickEnabled(bool enabled) {
|
|||||||
|
|
||||||
void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) {
|
void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.touchpadRightClickZoneEnabled == enabled) {
|
if (mLocked.touchpadRightClickZoneEnabled == enabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1197,7 +1197,7 @@ void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) {
|
|||||||
|
|
||||||
void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled) {
|
void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
auto it = mLocked.disabledInputDevices.find(deviceId);
|
auto it = mLocked.disabledInputDevices.find(deviceId);
|
||||||
bool currentlyEnabled = it == mLocked.disabledInputDevices.end();
|
bool currentlyEnabled = it == mLocked.disabledInputDevices.end();
|
||||||
@@ -1215,7 +1215,7 @@ void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled)
|
|||||||
|
|
||||||
void NativeInputManager::setShowTouches(bool enabled) {
|
void NativeInputManager::setShowTouches(bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.showTouches == enabled) {
|
if (mLocked.showTouches == enabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1243,7 +1243,7 @@ void NativeInputManager::reloadCalibration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeInputManager::setPointerIconType(PointerIconStyle iconId) {
|
void NativeInputManager::setPointerIconType(PointerIconStyle iconId) {
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
||||||
if (controller != nullptr) {
|
if (controller != nullptr) {
|
||||||
controller->updatePointerIcon(iconId);
|
controller->updatePointerIcon(iconId);
|
||||||
@@ -1251,7 +1251,7 @@ void NativeInputManager::setPointerIconType(PointerIconStyle iconId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeInputManager::reloadPointerIcons() {
|
void NativeInputManager::reloadPointerIcons() {
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
||||||
if (controller != nullptr) {
|
if (controller != nullptr) {
|
||||||
controller->reloadPointerResources();
|
controller->reloadPointerResources();
|
||||||
@@ -1259,7 +1259,7 @@ void NativeInputManager::reloadPointerIcons() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) {
|
void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) {
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
std::shared_ptr<PointerController> controller = mLocked.pointerController.lock();
|
||||||
if (controller != nullptr) {
|
if (controller != nullptr) {
|
||||||
controller->setCustomPointerIcon(icon);
|
controller->setCustomPointerIcon(icon);
|
||||||
@@ -1522,7 +1522,7 @@ void NativeInputManager::onPointerDownOutsideFocus(const sp<IBinder>& touchedTok
|
|||||||
|
|
||||||
void NativeInputManager::setPointerCapture(const PointerCaptureRequest& request) {
|
void NativeInputManager::setPointerCapture(const PointerCaptureRequest& request) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.pointerCaptureRequest == request) {
|
if (mLocked.pointerCaptureRequest == request) {
|
||||||
return;
|
return;
|
||||||
@@ -1633,7 +1633,7 @@ std::optional<std::string> NativeInputManager::getBluetoothAddress(int32_t devic
|
|||||||
|
|
||||||
void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) {
|
void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) {
|
||||||
{ // acquire lock
|
{ // acquire lock
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
|
|
||||||
if (mLocked.stylusButtonMotionEventsEnabled == enabled) {
|
if (mLocked.stylusButtonMotionEventsEnabled == enabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1657,7 +1657,7 @@ bool NativeInputManager::isPerDisplayTouchModeEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FloatPoint NativeInputManager::getMouseCursorPosition() {
|
FloatPoint NativeInputManager::getMouseCursorPosition() {
|
||||||
AutoMutex _l(mLock);
|
std::scoped_lock _l(mLock);
|
||||||
const auto pc = mLocked.pointerController.lock();
|
const auto pc = mLocked.pointerController.lock();
|
||||||
if (!pc) return {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION};
|
if (!pc) return {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user