@@ -1038,7 +1038,7 @@ void InputDispatcher::dispatchEventLocked(nsecs_t currentTime, EventEntry* event
1038
1038
pokeUserActivityLocked (*eventEntry);
1039
1039
1040
1040
for (const InputTarget& inputTarget : inputTargets) {
1041
- sp<Connection> connection = getConnectionLocked (inputTarget.inputChannel );
1041
+ sp<Connection> connection = getConnectionLocked (inputTarget.inputChannel -> getToken () );
1042
1042
if (connection != nullptr ) {
1043
1043
prepareDispatchCycleLocked (currentTime, connection, eventEntry, &inputTarget);
1044
1044
} else {
@@ -1126,7 +1126,7 @@ void InputDispatcher::removeWindowByTokenLocked(const sp<IBinder>& token) {
1126
1126
}
1127
1127
1128
1128
void InputDispatcher::resumeAfterTargetsNotReadyTimeoutLocked (
1129
- nsecs_t newTimeout, const sp<InputChannel >& inputChannel ) {
1129
+ nsecs_t newTimeout, const sp<IBinder >& inputConnectionToken ) {
1130
1130
if (newTimeout > 0 ) {
1131
1131
// Extend the timeout.
1132
1132
mInputTargetWaitTimeoutTime = now () + newTimeout;
@@ -1135,13 +1135,9 @@ void InputDispatcher::resumeAfterTargetsNotReadyTimeoutLocked(
1135
1135
mInputTargetWaitTimeoutExpired = true ;
1136
1136
1137
1137
// Input state will not be realistic. Mark it out of sync.
1138
- sp<Connection> connection = getConnectionLocked (inputChannel );
1138
+ sp<Connection> connection = getConnectionLocked (inputConnectionToken );
1139
1139
if (connection != nullptr ) {
1140
- sp<IBinder> token = connection->inputChannel ->getToken ();
1141
-
1142
- if (token != nullptr ) {
1143
- removeWindowByTokenLocked (token);
1144
- }
1140
+ removeWindowByTokenLocked (inputConnectionToken);
1145
1141
1146
1142
if (connection->status == Connection::STATUS_NORMAL) {
1147
1143
CancelationOptions options (CancelationOptions::CANCEL_ALL_EVENTS,
@@ -1828,8 +1824,7 @@ std::string InputDispatcher::checkWindowReadyForMoreInputLocked(
1828
1824
}
1829
1825
1830
1826
// If the window's connection is not registered then keep waiting.
1831
- sp<Connection> connection =
1832
- getConnectionLocked (getInputChannelLocked (windowHandle->getToken ()));
1827
+ sp<Connection> connection = getConnectionLocked (windowHandle->getToken ());
1833
1828
if (connection == nullptr ) {
1834
1829
return StringPrintf (" Waiting because the %s window's input channel is not "
1835
1830
" registered with the input dispatcher. The window may be in the "
@@ -2477,7 +2472,7 @@ void InputDispatcher::synthesizeCancelationEventsForMonitorsLocked(
2477
2472
2478
2473
void InputDispatcher::synthesizeCancelationEventsForInputChannelLocked (
2479
2474
const sp<InputChannel>& channel, const CancelationOptions& options) {
2480
- sp<Connection> connection = getConnectionLocked (channel);
2475
+ sp<Connection> connection = getConnectionLocked (channel-> getToken () );
2481
2476
if (connection == nullptr ) {
2482
2477
return ;
2483
2478
}
@@ -3571,10 +3566,8 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<
3571
3566
return false ;
3572
3567
}
3573
3568
3574
- sp<InputChannel> fromChannel = getInputChannelLocked (fromToken);
3575
- sp<InputChannel> toChannel = getInputChannelLocked (toToken);
3576
- sp<Connection> fromConnection = getConnectionLocked (fromChannel);
3577
- sp<Connection> toConnection = getConnectionLocked (toChannel);
3569
+ sp<Connection> fromConnection = getConnectionLocked (fromToken);
3570
+ sp<Connection> toConnection = getConnectionLocked (toToken);
3578
3571
if (fromConnection != nullptr && toConnection != nullptr ) {
3579
3572
fromConnection->inputState .copyPointerStateTo (toConnection->inputState );
3580
3573
CancelationOptions
@@ -3873,7 +3866,7 @@ status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChan
3873
3866
3874
3867
{ // acquire lock
3875
3868
std::scoped_lock _l (mLock );
3876
- sp<Connection> existingConnection = getConnectionLocked (inputChannel);
3869
+ sp<Connection> existingConnection = getConnectionLocked (inputChannel-> getToken () );
3877
3870
if (existingConnection != nullptr ) {
3878
3871
ALOGW (" Attempted to register already registered input channel '%s'" ,
3879
3872
inputChannel->getName ().c_str ());
@@ -3948,7 +3941,7 @@ status_t InputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputCh
3948
3941
3949
3942
status_t InputDispatcher::unregisterInputChannelLocked (const sp<InputChannel>& inputChannel,
3950
3943
bool notify) {
3951
- sp<Connection> connection = getConnectionLocked (inputChannel);
3944
+ sp<Connection> connection = getConnectionLocked (inputChannel-> getToken () );
3952
3945
if (connection == nullptr ) {
3953
3946
ALOGW (" Attempted to unregister already unregistered input channel '%s'" ,
3954
3947
inputChannel->getName ().c_str ());
@@ -4056,14 +4049,14 @@ std::optional<int32_t> InputDispatcher::findGestureMonitorDisplayByTokenLocked(
4056
4049
return std::nullopt;
4057
4050
}
4058
4051
4059
- sp<Connection> InputDispatcher::getConnectionLocked (const sp<InputChannel >& inputChannel ) {
4060
- if (inputChannel == nullptr ) {
4052
+ sp<Connection> InputDispatcher::getConnectionLocked (const sp<IBinder >& inputConnectionToken ) {
4053
+ if (inputConnectionToken == nullptr ) {
4061
4054
return nullptr ;
4062
4055
}
4063
4056
4064
4057
for (const auto & pair : mConnectionsByFd ) {
4065
- sp<Connection> connection = pair.second ;
4066
- if (connection->inputChannel ->getToken () == inputChannel-> getToken () ) {
4058
+ const sp<Connection>& connection = pair.second ;
4059
+ if (connection->inputChannel ->getToken () == inputConnectionToken ) {
4067
4060
return connection;
4068
4061
}
4069
4062
}
@@ -4171,17 +4164,16 @@ void InputDispatcher::doNotifyFocusChangedLockedInterruptible(CommandEntry* comm
4171
4164
}
4172
4165
4173
4166
void InputDispatcher::doNotifyANRLockedInterruptible (CommandEntry* commandEntry) {
4167
+ sp<IBinder> token =
4168
+ commandEntry->inputChannel ? commandEntry->inputChannel ->getToken () : nullptr ;
4174
4169
mLock .unlock ();
4175
4170
4176
4171
nsecs_t newTimeout =
4177
- mPolicy ->notifyANR (commandEntry->inputApplicationHandle ,
4178
- commandEntry->inputChannel ? commandEntry->inputChannel ->getToken ()
4179
- : nullptr ,
4180
- commandEntry->reason );
4172
+ mPolicy ->notifyANR (commandEntry->inputApplicationHandle , token, commandEntry->reason );
4181
4173
4182
4174
mLock .lock ();
4183
4175
4184
- resumeAfterTargetsNotReadyTimeoutLocked (newTimeout, commandEntry-> inputChannel );
4176
+ resumeAfterTargetsNotReadyTimeoutLocked (newTimeout, token );
4185
4177
}
4186
4178
4187
4179
void InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible (
0 commit comments