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
4e057772
Commit
4e057772
authored
1 year ago
by
Dmitry Muhomor
Committed by
Dhina17
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
PackageInstaller: limit max AppSnippet icon size
Change-Id: I3a50feec03e4f913a5c0fabe975cf1206f7f2d40
parent
0e3b3ea1
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/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
+19
-4
19 additions, 4 deletions
...staller/src/com/android/packageinstaller/PackageUtil.java
with
19 additions
and
4 deletions
packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
+
19
−
4
View file @
4e057772
...
...
@@ -152,10 +152,25 @@ public class PackageUtil {
}
private
Bitmap
getBitmapFromDrawable
(
Drawable
drawable
)
{
// Create an empty bitmap with the dimensions of our drawable
final
Bitmap
bmp
=
Bitmap
.
createBitmap
(
drawable
.
getIntrinsicWidth
(),
drawable
.
getIntrinsicHeight
(),
Bitmap
.
Config
.
ARGB_8888
);
int
origW
=
drawable
.
getIntrinsicWidth
();
int
origH
=
drawable
.
getIntrinsicHeight
();
// resulting bitmap will be transferred over binder, which limits safe transcation size
// to a few hundred KiB
final
int
maxSide
=
250
;
// 250 KB at 4 bytes per pixel
int
w
=
origW
;
int
h
=
origH
;
if
(
Math
.
max
(
origW
,
origH
)
>
maxSide
)
{
double
ratio
=
Math
.
min
((
double
)
maxSide
/
origW
,
(
double
)
maxSide
/
origH
);
w
=
(
int
)
(
ratio
*
w
);
h
=
(
int
)
(
ratio
*
h
);
Log
.
d
(
"AppSnippet"
,
"getBitmapFromDrawable: downscaling, "
+
"origW "
+
origW
+
" origH "
+
origH
+
" scaleRatio "
+
ratio
+
" label "
+
label
);
}
final
Bitmap
bmp
=
Bitmap
.
createBitmap
(
w
,
h
,
Bitmap
.
Config
.
ARGB_8888
);
// Associate it with a canvas. This canvas will draw the icon on the bitmap
final
Canvas
canvas
=
new
Canvas
(
bmp
);
// Draw the drawable in the canvas. The canvas will ultimately paint the drawable in the
...
...
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