Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
17bab3e3
Commit
17bab3e3
authored
1 year ago
by
Yasin Kilicdere
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Code Refactor: UserTrackerImpl.UserTracker.Callback calls." into main
parents
f8746dfe
0d3e3352
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
+22
-40
22 additions, 40 deletions
...emUI/src/com/android/systemui/settings/UserTrackerImpl.kt
with
22 additions
and
40 deletions
packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
+
22
−
40
View file @
17bab3e3
...
...
@@ -227,22 +227,10 @@ open class UserTrackerImpl internal constructor(
protected
open
fun
handleBeforeUserSwitching
(
newUserId
:
Int
)
{
setUserIdInternal
(
newUserId
)
val
list
=
synchronized
(
callbacks
)
{
callbacks
.
toList
()
}
val
latch
=
CountDownLatch
(
list
.
size
)
list
.
forEach
{
val
callback
=
it
.
callback
.
get
()
if
(
callback
!=
null
)
{
it
.
executor
.
execute
{
callback
.
onBeforeUserSwitching
(
newUserId
)
latch
.
countDown
()
}
}
else
{
latch
.
countDown
()
}
}
latch
.
await
()
notifySubscribers
{
callback
,
resultCallback
->
callback
.
onBeforeUserSwitching
(
newUserId
)
resultCallback
.
run
()
}.
await
()
}
@WorkerThread
...
...
@@ -250,21 +238,9 @@ open class UserTrackerImpl internal constructor(
Assert
.
isNotMainThread
()
Log
.
i
(
TAG
,
"Switching to user $newUserId"
)
val
list
=
synchronized
(
callbacks
)
{
callbacks
.
toList
()
}
val
latch
=
CountDownLatch
(
list
.
size
)
list
.
forEach
{
val
callback
=
it
.
callback
.
get
()
if
(
callback
!=
null
)
{
it
.
executor
.
execute
{
callback
.
onUserChanging
(
userId
,
userContext
)
{
latch
.
countDown
()
}
}
}
else
{
latch
.
countDown
()
}
}
latch
.
await
()
notifySubscribers
{
callback
,
resultCallback
->
callback
.
onUserChanging
(
newUserId
,
userContext
,
resultCallback
)
}.
await
()
}
@WorkerThread
...
...
@@ -294,9 +270,9 @@ open class UserTrackerImpl internal constructor(
Assert
.
isNotMainThread
()
Log
.
i
(
TAG
,
"Switched to user $newUserId"
)
notifySubscribers
{
onUserChanged
(
newUserId
,
userContext
)
onProfilesChanged
(
userProfiles
)
notifySubscribers
{
callback
,
_
->
callback
.
onUserChanged
(
newUserId
,
userContext
)
callback
.
onProfilesChanged
(
userProfiles
)
}
}
...
...
@@ -308,8 +284,8 @@ open class UserTrackerImpl internal constructor(
synchronized
(
mutex
)
{
userProfiles
=
profiles
.
map
{
UserInfo
(
it
)
}
// save a "deep" copy
}
notifySubscribers
{
onProfilesChanged
(
profiles
)
notifySubscribers
{
callback
,
_
->
callback
.
onProfilesChanged
(
profiles
)
}
}
...
...
@@ -325,18 +301,24 @@ open class UserTrackerImpl internal constructor(
}
}
private
inline
fun
notifySubscribers
(
crossinline
action
:
UserTracker
.
Callback
.()
->
Unit
)
{
private
inline
fun
notifySubscribers
(
crossinline
action
:
(
UserTracker
.
Callback
,
resultCallback
:
Runnable
)
->
Unit
):
CountDownLatch
{
val
list
=
synchronized
(
callbacks
)
{
callbacks
.
toList
()
}
val
latch
=
CountDownLatch
(
list
.
size
)
list
.
forEach
{
if
(
it
.
callback
.
get
()
!=
null
)
{
val
callback
=
it
.
callback
.
get
()
if
(
callback
!=
null
)
{
it
.
executor
.
execute
{
it
.
callback
.
get
()
?.
actio
n
()
action
(
callback
)
{
latch
.
countDow
n
()
}
}
}
else
{
latch
.
countDown
()
}
}
return
latch
}
override
fun
dump
(
pw
:
PrintWriter
,
args
:
Array
<
out
String
>)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment