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
d6004db9
Commit
d6004db9
authored
10 months ago
by
Yisroel Forta
Committed by
Android (Google) Code Review
10 months ago
Browse files
Options
Downloads
Plain Diff
Merge "Handle failed AppStartInfo record write" into main
parents
27f27604
4b99fe8a
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
services/core/java/com/android/server/am/AppStartInfoTracker.java
+29
-8
29 additions, 8 deletions
.../core/java/com/android/server/am/AppStartInfoTracker.java
with
29 additions
and
8 deletions
services/core/java/com/android/server/am/AppStartInfoTracker.java
+
29
−
8
View file @
d6004db9
...
...
@@ -83,6 +83,7 @@ public final class AppStartInfoTracker {
private
static
final
int
FOREACH_ACTION_NONE
=
0
;
private
static
final
int
FOREACH_ACTION_REMOVE_ITEM
=
1
;
private
static
final
int
FOREACH_ACTION_STOP_ITERATION
=
2
;
private
static
final
int
FOREACH_ACTION_REMOVE_AND_STOP_ITERATION
=
3
;
private
static
final
String
MONITORING_MODE_EMPTY_TEXT
=
"No records"
;
...
...
@@ -659,8 +660,13 @@ public final class AppStartInfoTracker {
}
}
/**
* Run provided callback for each packake in start info dataset.
*
* @return whether the for each completed naturally, false if it was stopped manually.
*/
@GuardedBy
(
"mLock"
)
private
void
forEachPackageLocked
(
private
boolean
forEachPackageLocked
(
BiFunction
<
String
,
SparseArray
<
AppStartInfoContainer
>,
Integer
>
callback
)
{
if
(
callback
!=
null
)
{
ArrayMap
<
String
,
SparseArray
<
AppStartInfoContainer
>>
map
=
mData
.
getMap
();
...
...
@@ -670,14 +676,17 @@ public final class AppStartInfoTracker {
map
.
removeAt
(
i
);
break
;
case
FOREACH_ACTION_STOP_ITERATION:
i
=
0
;
break
;
return
false
;
case
FOREACH_ACTION_REMOVE_AND_STOP_ITERATION:
map
.
removeAt
(
i
);
return
false
;
case
FOREACH_ACTION_NONE:
default
:
break
;
}
}
}
return
true
;
}
@GuardedBy
(
"mLock"
)
...
...
@@ -870,13 +879,14 @@ public final class AppStartInfoTracker {
}
AtomicFile
af
=
new
AtomicFile
(
mProcStartInfoFile
);
FileOutputStream
out
=
null
;
boolean
succeeded
;
long
now
=
System
.
currentTimeMillis
();
try
{
out
=
af
.
startWrite
();
ProtoOutputStream
proto
=
new
ProtoOutputStream
(
out
);
proto
.
write
(
AppsStartInfoProto
.
LAST_UPDATE_TIMESTAMP
,
now
);
synchronized
(
mLock
)
{
forEachPackageLocked
(
succeeded
=
forEachPackageLocked
(
(
packageName
,
records
)
->
{
long
token
=
proto
.
start
(
AppsStartInfoProto
.
PACKAGES
);
proto
.
write
(
AppsStartInfoProto
.
Package
.
PACKAGE_NAME
,
packageName
);
...
...
@@ -884,19 +894,30 @@ public final class AppStartInfoTracker {
for
(
int
j
=
0
;
j
<
uidArraySize
;
j
++)
{
try
{
records
.
valueAt
(
j
)
.
writeToProto
(
proto
,
AppsStartInfoProto
.
Package
.
USERS
);
.
writeToProto
(
proto
,
AppsStartInfoProto
.
Package
.
USERS
);
}
catch
(
IOException
e
)
{
Slog
.
w
(
TAG
,
"Unable to write app start info into persistent"
+
"storage: "
+
e
);
// There was likely an issue with this record that won't resolve
// next time we try to persist so remove it. Also stop iteration
// as we failed the write and need to start again from scratch.
return
AppStartInfoTracker
.
FOREACH_ACTION_REMOVE_AND_STOP_ITERATION
;
}
}
proto
.
end
(
token
);
return
AppStartInfoTracker
.
FOREACH_ACTION_NONE
;
});
mLastAppStartInfoPersistTimestamp
=
now
;
if
(
succeeded
)
{
mLastAppStartInfoPersistTimestamp
=
now
;
}
}
if
(
succeeded
)
{
proto
.
flush
();
af
.
finishWrite
(
out
);
}
else
{
af
.
failWrite
(
out
);
}
proto
.
flush
();
af
.
finishWrite
(
out
);
}
catch
(
IOException
e
)
{
Slog
.
w
(
TAG
,
"Unable to write historical app start info into persistent storage: "
+
e
);
af
.
failWrite
(
out
);
...
...
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