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
9cbee64d
Commit
9cbee64d
authored
6 years ago
by
TreeHugger Robot
Committed by
Android (Google) Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "ResourceManager: Disable APK Assets cache."
parents
80a2b709
bc956218
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
core/java/android/app/ResourcesManager.java
+35
-18
35 additions, 18 deletions
core/java/android/app/ResourcesManager.java
with
35 additions
and
18 deletions
core/java/android/app/ResourcesManager.java
+
35
−
18
View file @
9cbee64d
...
...
@@ -125,10 +125,13 @@ public class ResourcesManager {
}
}
private
static
final
boolean
ENABLE_APK_ASSETS_CACHE
=
true
;
/**
* The ApkAssets we are caching and intend to hold strong references to.
*/
private
final
LruCache
<
ApkKey
,
ApkAssets
>
mLoadedApkAssets
=
new
LruCache
<>(
3
);
private
final
LruCache
<
ApkKey
,
ApkAssets
>
mLoadedApkAssets
=
(
ENABLE_APK_ASSETS_CACHE
)
?
new
LruCache
<>(
3
)
:
null
;
/**
* The ApkAssets that are being referenced in the wild that we can reuse, even if they aren't
...
...
@@ -316,9 +319,12 @@ public class ResourcesManager {
private
@NonNull
ApkAssets
loadApkAssets
(
String
path
,
boolean
sharedLib
,
boolean
overlay
)
throws
IOException
{
final
ApkKey
newKey
=
new
ApkKey
(
path
,
sharedLib
,
overlay
);
ApkAssets
apkAssets
=
mLoadedApkAssets
.
get
(
newKey
);
if
(
apkAssets
!=
null
)
{
return
apkAssets
;
ApkAssets
apkAssets
=
null
;
if
(
mLoadedApkAssets
!=
null
)
{
apkAssets
=
mLoadedApkAssets
.
get
(
newKey
);
if
(
apkAssets
!=
null
)
{
return
apkAssets
;
}
}
// Optimistically check if this ApkAssets exists somewhere else.
...
...
@@ -326,7 +332,10 @@ public class ResourcesManager {
if
(
apkAssetsRef
!=
null
)
{
apkAssets
=
apkAssetsRef
.
get
();
if
(
apkAssets
!=
null
)
{
mLoadedApkAssets
.
put
(
newKey
,
apkAssets
);
if
(
mLoadedApkAssets
!=
null
)
{
mLoadedApkAssets
.
put
(
newKey
,
apkAssets
);
}
return
apkAssets
;
}
else
{
// Clean up the reference.
...
...
@@ -341,7 +350,11 @@ public class ResourcesManager {
}
else
{
apkAssets
=
ApkAssets
.
loadFromPath
(
path
,
false
/*system*/
,
sharedLib
);
}
mLoadedApkAssets
.
put
(
newKey
,
apkAssets
);
if
(
mLoadedApkAssets
!=
null
)
{
mLoadedApkAssets
.
put
(
newKey
,
apkAssets
);
}
mCachedApkAssets
.
put
(
newKey
,
new
WeakReference
<>(
apkAssets
));
return
apkAssets
;
}
...
...
@@ -441,18 +454,22 @@ public class ResourcesManager {
pw
.
println
(
"ResourcesManager:"
);
pw
.
increaseIndent
();
pw
.
print
(
"cached apks: total="
);
pw
.
print
(
mLoadedApkAssets
.
size
());
pw
.
print
(
" created="
);
pw
.
print
(
mLoadedApkAssets
.
createCount
());
pw
.
print
(
" evicted="
);
pw
.
print
(
mLoadedApkAssets
.
evictionCount
());
pw
.
print
(
" hit="
);
pw
.
print
(
mLoadedApkAssets
.
hitCount
());
pw
.
print
(
" miss="
);
pw
.
print
(
mLoadedApkAssets
.
missCount
());
pw
.
print
(
" max="
);
pw
.
print
(
mLoadedApkAssets
.
maxSize
());
if
(
mLoadedApkAssets
!=
null
)
{
pw
.
print
(
"cached apks: total="
);
pw
.
print
(
mLoadedApkAssets
.
size
());
pw
.
print
(
" created="
);
pw
.
print
(
mLoadedApkAssets
.
createCount
());
pw
.
print
(
" evicted="
);
pw
.
print
(
mLoadedApkAssets
.
evictionCount
());
pw
.
print
(
" hit="
);
pw
.
print
(
mLoadedApkAssets
.
hitCount
());
pw
.
print
(
" miss="
);
pw
.
print
(
mLoadedApkAssets
.
missCount
());
pw
.
print
(
" max="
);
pw
.
print
(
mLoadedApkAssets
.
maxSize
());
}
else
{
pw
.
print
(
"cached apks: 0 [cache disabled]"
);
}
pw
.
println
();
pw
.
print
(
"total apks: "
);
...
...
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