Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_apps_PackageInstaller
Commits
a17dcac3
Commit
a17dcac3
authored
11 years ago
by
Alex Klyubin
Committed by
Android (Google) Code Review
11 years ago
Browse files
Options
Download
Plain Diff
Merge "Robustify logging of analytics about PackageInstaller." into klp-dev
parents
9222a09d
3e9a765f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
65 deletions
+42
-65
src/com/android/packageinstaller/EventLogTags.logtags
src/com/android/packageinstaller/EventLogTags.logtags
+1
-1
src/com/android/packageinstaller/InstallFlowAnalytics.java
src/com/android/packageinstaller/InstallFlowAnalytics.java
+41
-64
No files found.
src/com/android/packageinstaller/EventLogTags.logtags
View file @
a17dcac3
...
...
@@ -3,4 +3,4 @@
option java_package com.android.packageinstaller
# APK install attempt via PackageInstaller (see InstallFlowAnalytics for format)
90300 install_package_attempt (
type|4
)
90300 install_package_attempt (
result_and_flags|1),(total_time|1|3),(time_till_pkg_info_obtained|1|3),(time_till_install_clicked|1|3
)
This diff is collapsed.
Click to expand it.
src/com/android/packageinstaller/InstallFlowAnalytics.java
View file @
a17dcac3
...
...
@@ -115,7 +115,7 @@ public class InstallFlowAnalytics implements Parcelable {
/**
* Time instant when the user clicked the Install button, measured in elapsed realtime
* milliseconds. See {@link SystemClock#elapsedRealtime()}. This field is only valid if the
* Install button has been clicked as
record
ed
in
{@link #
mInstallButtonClicked
}.
* Install button has been clicked
,
as
signal
ed
by
{@link #
FLAG_INSTALL_BUTTON_CLICKED
}.
*/
private
long
mInstallButtonClickTimestampMillis
;
...
...
@@ -385,12 +385,45 @@ public class InstallFlowAnalytics implements Parcelable {
}
private
void
writeToEventLog
()
{
Object
[]
value
=
getEventLogEventValue
();
EventLog
.
writeEvent
(
EventLogTags
.
INSTALL_PACKAGE_ATTEMPT
,
value
);
byte
packageManagerInstallResultByte
=
0
;
if
(
mResult
==
RESULT_PACKAGE_MANAGER_INSTALL_FAILED
)
{
// PackageManager install error codes are negative, starting from -1 and going to
// -111 (at the moment). We thus store them in negated form.
packageManagerInstallResultByte
=
clipUnsignedValueToUnsignedByte
(
-
mPackageManagerInstallResult
);
}
int
resultAndFlags
=
(
mResult
&
0xff
)
|
((
packageManagerInstallResultByte
&
0xff
)
<<
8
)
|
((
mFlags
&
0xffff
)
<<
16
);
// Total elapsed time from start to end, in milliseconds.
int
totalElapsedTime
=
clipUnsignedLongToUnsignedInt
(
mEndTimestampMillis
-
mStartTimestampMillis
);
// Total elapsed time from start till information about the package being installed was
// obtained, in milliseconds.
int
elapsedTimeTillPackageInfoObtained
=
(
isPackageInfoObtained
())
?
clipUnsignedLongToUnsignedInt
(
mPackageInfoObtainedTimestampMillis
-
mStartTimestampMillis
)
:
0
;
// Total elapsed time from start till Install button clicked, in milliseconds
// milliseconds.
int
elapsedTimeTillInstallButtonClick
=
(
isInstallButtonClicked
())
?
clipUnsignedLongToUnsignedInt
(
mInstallButtonClickTimestampMillis
-
mStartTimestampMillis
)
:
0
;
EventLogTags
.
writeInstallPackageAttempt
(
resultAndFlags
,
totalElapsedTime
,
elapsedTimeTillPackageInfoObtained
,
elapsedTimeTillInstallButtonClick
);
mLogged
=
true
;
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
v
(
TAG
,
"Aalytics:"
Log
.
v
(
TAG
,
"A
n
alytics:"
+
"\n\tinstallsFromUnknownSourcesPermitted: "
+
isInstallsFromUnknownSourcesPermitted
()
+
"\n\tinstallRequestFromUnknownSource: "
+
isInstallRequestFromUnknownSource
()
...
...
@@ -417,67 +450,11 @@ public class InstallFlowAnalytics implements Parcelable {
+
((
isInstallButtonClicked
())
?
((
mInstallButtonClickTimestampMillis
-
mStartTimestampMillis
)
+
" ms"
)
:
"n/a"
));
StringBuilder
dump
=
new
StringBuilder
();
for
(
Object
element
:
value
)
{
if
(
dump
.
length
()
>
0
)
{
dump
.
append
(
", "
);
}
if
(
element
instanceof
Integer
)
{
dump
.
append
(
"0x"
)
.
append
(
Long
.
toString
(((
Integer
)
element
)
&
0xffffffff
L
,
16
));
}
else
{
dump
.
append
(
element
);
}
}
Log
.
v
(
TAG
,
"Wrote to Event Log: "
+
dump
);
}
}
private
Object
[]
getEventLogEventValue
()
{
// IMPLEMENTATION NOTE: Analytics are packed into the following list:
// * 32-bit int (ordered from least significant to most significant bits):
// * 1 byte: outcome of the flow (see RESULT_... constants)
// * 1 byte: PackageManager install error code (negated) or 0 if it didn't run
// * 2 bytes: flags (see FLAG_... constants)
// * 32-bit unsigned int: total elapsed time (milliseconds)
// * 32-bit unsigned int: time elapsed from start till information about the package being
// installed was obtained (milliseconds)
// * 32-bit unsigned int: time elapsed from start till Install button click (milliseconds)
byte
packageManagerInstallResultByte
=
0
;
if
(
mResult
==
RESULT_PACKAGE_MANAGER_INSTALL_FAILED
)
{
// PackageManager install error codes are negative, starting from -1 and going to
// -111 (at the moment). We thus store them in negated form.
packageManagerInstallResultByte
=
clipUnsignedValueToUnsignedByte
(
-
mPackageManagerInstallResult
);
Log
.
v
(
TAG
,
"Wrote to Event Log: 0x"
+
Long
.
toString
(
resultAndFlags
&
0xffffffff
L
,
16
)
+
", "
+
totalElapsedTime
+
", "
+
elapsedTimeTillPackageInfoObtained
+
", "
+
elapsedTimeTillInstallButtonClick
);
}
// Total elapsed time from start to end, in milliseconds.
int
totalElapsedTime
=
clipUnsignedLongToUnsignedInt
(
mEndTimestampMillis
-
mStartTimestampMillis
);
// Total elapsed time from start till information about the package being installed was
// obtained, in milliseconds.
int
elapsedTimeTillPackageInfoObtained
=
(
isPackageInfoObtained
())
?
clipUnsignedLongToUnsignedInt
(
mPackageInfoObtainedTimestampMillis
-
mStartTimestampMillis
)
:
0
;
// Total elapsed time from start till Install button clicked, in milliseconds
// milliseconds.
int
elapsedTimeTillInstallButtonClick
=
(
isInstallButtonClicked
())
?
clipUnsignedLongToUnsignedInt
(
mInstallButtonClickTimestampMillis
-
mStartTimestampMillis
)
:
0
;
return
new
Object
[]
{
(
int
)
((
mResult
&
0xff
)
|
((
packageManagerInstallResultByte
&
0xff
)
<<
8
)
|
((
mFlags
&
0xffff
L
)
<<
16
)),
totalElapsedTime
,
elapsedTimeTillPackageInfoObtained
,
elapsedTimeTillInstallButtonClick
,
};
}
private
static
final
byte
clipUnsignedValueToUnsignedByte
(
long
value
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment