Skip to content
This repository was archived by the owner on May 1, 2023. It is now read-only.

Commit dc799bc

Browse files
Delyan Kratunovfacebook-github-bot
Delyan Kratunov
authored andcommitted
Add installer package
Reviewed By: yukonfb Differential Revision: D33284842 fbshipit-source-id: 5c75b47a63a89bb5431a53485b1d63b63639f7a6
1 parent bc342ac commit dc799bc

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

java/main/com/facebook/profilo/provider/packageinfo/PackageInfoProvider.java

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
public class PackageInfoProvider extends MetadataTraceProvider {
1919

2020
@Nullable private String mVersionName;
21+
@Nullable private String mInstaller;
2122
private int mVersionCode;
2223
private final Context mContext;
2324

@@ -40,13 +41,19 @@ private void resolvePackageInfo() {
4041
PackageInfo pi;
4142
try {
4243
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
44+
mVersionName = pi.versionName;
45+
mVersionCode = pi.versionCode;
4346
} catch (PackageManager.NameNotFoundException e) {
4447
return;
4548
} catch (RuntimeException e) {
4649
return;
4750
}
48-
mVersionName = pi.versionName;
49-
mVersionCode = pi.versionCode;
51+
52+
try {
53+
mInstaller = pm.getInstallerPackageName(mContext.getPackageName());
54+
} catch (RuntimeException e) {
55+
mInstaller = "<exception>";
56+
}
5057
}
5158

5259
@Override
@@ -67,15 +74,13 @@ protected void logOnTraceEnd(TraceContext context, ExtraDataFileProvider dataFil
6774
Identifiers.APP_VERSION_NAME,
6875
ProfiloConstants.NO_MATCH,
6976
(long) 0);
70-
if ("App version" != null) {
71-
returnedMatchID =
72-
BufferLogger.writeBytesEntry(
73-
context.mainBuffer,
74-
ProfiloConstants.NONE,
75-
EntryType.STRING_KEY,
76-
returnedMatchID,
77-
"App version");
78-
}
77+
returnedMatchID =
78+
BufferLogger.writeBytesEntry(
79+
context.mainBuffer,
80+
ProfiloConstants.NONE,
81+
EntryType.STRING_KEY,
82+
returnedMatchID,
83+
"App version");
7984
BufferLogger.writeBytesEntry(
8085
context.mainBuffer,
8186
ProfiloConstants.NONE,
@@ -92,5 +97,29 @@ protected void logOnTraceEnd(TraceContext context, ExtraDataFileProvider dataFil
9297
Identifiers.APP_VERSION_CODE,
9398
ProfiloConstants.NONE,
9499
(long) mVersionCode);
100+
101+
returnedMatchID =
102+
BufferLogger.writeStandardEntry(
103+
context.mainBuffer,
104+
Logger.FILL_TIMESTAMP | Logger.FILL_TID,
105+
EntryType.TRACE_ANNOTATION,
106+
ProfiloConstants.NONE,
107+
ProfiloConstants.NONE,
108+
ProfiloConstants.NONE,
109+
ProfiloConstants.NONE,
110+
ProfiloConstants.NONE);
111+
returnedMatchID =
112+
BufferLogger.writeBytesEntry(
113+
context.mainBuffer,
114+
ProfiloConstants.NONE,
115+
EntryType.STRING_KEY,
116+
returnedMatchID,
117+
"Installer");
118+
BufferLogger.writeBytesEntry(
119+
context.mainBuffer,
120+
ProfiloConstants.NONE,
121+
EntryType.STRING_VALUE,
122+
returnedMatchID,
123+
mInstaller != null ? mInstaller : "null");
95124
}
96125
}

0 commit comments

Comments
 (0)