Update graphics stats to use long version codes.
Bug: 64459786
Test: manual
Change-Id: Iab84727e0ac486f505c10aacdb5ec8871aaf121e
diff --git a/core/proto/android/service/graphicsstats.proto b/core/proto/android/service/graphicsstats.proto
index ee9d6fc..801411d 100644
--- a/core/proto/android/service/graphicsstats.proto
+++ b/core/proto/android/service/graphicsstats.proto
@@ -31,7 +31,7 @@
optional string package_name = 1;
// The version code of the app
- optional int32 version_code = 2;
+ optional int64 version_code = 2;
// The start & end timestamps in UTC as
// milliseconds since January 1, 1970
diff --git a/libs/hwui/service/GraphicsStatsService.cpp b/libs/hwui/service/GraphicsStatsService.cpp
index 3ac1a45..e0303a8 100644
--- a/libs/hwui/service/GraphicsStatsService.cpp
+++ b/libs/hwui/service/GraphicsStatsService.cpp
@@ -42,7 +42,7 @@
constexpr int sHistogramSize = ProfileData::HistogramSize();
static bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto,
- const std::string& package, int versionCode,
+ const std::string& package, int64_t versionCode,
int64_t startTime, int64_t endTime, const ProfileData* data);
static void dumpAsTextToFd(service::GraphicsStatsProto* proto, int outFd);
@@ -154,7 +154,7 @@
}
bool mergeProfileDataIntoProto(service::GraphicsStatsProto* proto, const std::string& package,
- int versionCode, int64_t startTime, int64_t endTime,
+ int64_t versionCode, int64_t startTime, int64_t endTime,
const ProfileData* data) {
if (proto->stats_start() == 0 || proto->stats_start() > startTime) {
proto->set_stats_start(startTime);
@@ -230,7 +230,7 @@
return;
}
dprintf(fd, "\nPackage: %s", proto->package_name().c_str());
- dprintf(fd, "\nVersion: %d", proto->version_code());
+ dprintf(fd, "\nVersion: %lld", proto->version_code());
dprintf(fd, "\nStats since: %lldns", proto->stats_start());
dprintf(fd, "\nStats end: %lldns", proto->stats_end());
auto summary = proto->summary();
@@ -254,7 +254,7 @@
}
void GraphicsStatsService::saveBuffer(const std::string& path, const std::string& package,
- int versionCode, int64_t startTime, int64_t endTime,
+ int64_t versionCode, int64_t startTime, int64_t endTime,
const ProfileData* data) {
service::GraphicsStatsProto statsProto;
if (!parseFromFile(path, &statsProto)) {
@@ -320,8 +320,8 @@
}
void GraphicsStatsService::addToDump(Dump* dump, const std::string& path,
- const std::string& package, int versionCode, int64_t startTime,
- int64_t endTime, const ProfileData* data) {
+ const std::string& package, int64_t versionCode,
+ int64_t startTime, int64_t endTime, const ProfileData* data) {
service::GraphicsStatsProto statsProto;
if (!path.empty() && !parseFromFile(path, &statsProto)) {
statsProto.Clear();
diff --git a/libs/hwui/service/GraphicsStatsService.h b/libs/hwui/service/GraphicsStatsService.h
index 7ddc219..bce0f3d 100644
--- a/libs/hwui/service/GraphicsStatsService.h
+++ b/libs/hwui/service/GraphicsStatsService.h
@@ -44,12 +44,12 @@
};
ANDROID_API static void saveBuffer(const std::string& path, const std::string& package,
- int versionCode, int64_t startTime, int64_t endTime,
+ int64_t versionCode, int64_t startTime, int64_t endTime,
const ProfileData* data);
ANDROID_API static Dump* createDump(int outFd, DumpType type);
ANDROID_API static void addToDump(Dump* dump, const std::string& path,
- const std::string& package, int versionCode,
+ const std::string& package, int64_t versionCode,
int64_t startTime, int64_t endTime, const ProfileData* data);
ANDROID_API static void addToDump(Dump* dump, const std::string& path);
ANDROID_API static void finishDump(Dump* dump);
diff --git a/services/core/java/com/android/server/GraphicsStatsService.java b/services/core/java/com/android/server/GraphicsStatsService.java
index d3f77b6..4639d75 100644
--- a/services/core/java/com/android/server/GraphicsStatsService.java
+++ b/services/core/java/com/android/server/GraphicsStatsService.java
@@ -175,7 +175,8 @@
0,
UserHandle.getUserId(uid));
synchronized (mLock) {
- pfd = requestBufferForProcessLocked(token, uid, pid, packageName, info.versionCode);
+ pfd = requestBufferForProcessLocked(token, uid, pid, packageName,
+ info.getLongVersionCode());
}
} catch (PackageManager.NameNotFoundException ex) {
throw new RemoteException("Unable to find package: '" + packageName + "'");
@@ -197,7 +198,7 @@
}
private ParcelFileDescriptor requestBufferForProcessLocked(IGraphicsStatsCallback token,
- int uid, int pid, String packageName, int versionCode) throws RemoteException {
+ int uid, int pid, String packageName, long versionCode) throws RemoteException {
ActiveBuffer buffer = fetchActiveBuffersLocked(token, uid, pid, packageName, versionCode);
scheduleRotateLocked();
return getPfd(buffer.mProcessBuffer);
@@ -292,7 +293,7 @@
}
private ActiveBuffer fetchActiveBuffersLocked(IGraphicsStatsCallback token, int uid, int pid,
- String packageName, int versionCode) throws RemoteException {
+ String packageName, long versionCode) throws RemoteException {
int size = mActive.size();
long today = normalizeDate(System.currentTimeMillis()).getTimeInMillis();
for (int i = 0; i < size; i++) {
@@ -381,19 +382,19 @@
private static native int nGetAshmemSize();
private static native long nCreateDump(int outFd, boolean isProto);
private static native void nAddToDump(long dump, String path, String packageName,
- int versionCode, long startTime, long endTime, byte[] data);
+ long versionCode, long startTime, long endTime, byte[] data);
private static native void nAddToDump(long dump, String path);
private static native void nFinishDump(long dump);
- private static native void nSaveBuffer(String path, String packageName, int versionCode,
+ private static native void nSaveBuffer(String path, String packageName, long versionCode,
long startTime, long endTime, byte[] data);
private final class BufferInfo {
final String packageName;
- final int versionCode;
+ final long versionCode;
long startTime;
long endTime;
- BufferInfo(String packageName, int versionCode, long startTime) {
+ BufferInfo(String packageName, long versionCode, long startTime) {
this.packageName = packageName;
this.versionCode = versionCode;
this.startTime = startTime;
@@ -408,7 +409,8 @@
final IBinder mToken;
MemoryFile mProcessBuffer;
- ActiveBuffer(IGraphicsStatsCallback token, int uid, int pid, String packageName, int versionCode)
+ ActiveBuffer(IGraphicsStatsCallback token, int uid, int pid, String packageName,
+ long versionCode)
throws RemoteException, IOException {
mInfo = new BufferInfo(packageName, versionCode, System.currentTimeMillis());
mUid = uid;
diff --git a/services/core/jni/com_android_server_GraphicsStatsService.cpp b/services/core/jni/com_android_server_GraphicsStatsService.cpp
index 8385020..d1d253b 100644
--- a/services/core/jni/com_android_server_GraphicsStatsService.cpp
+++ b/services/core/jni/com_android_server_GraphicsStatsService.cpp
@@ -39,7 +39,7 @@
}
static void addToDump(JNIEnv* env, jobject, jlong dumpPtr, jstring jpath, jstring jpackage,
- jint versionCode, jlong startTime, jlong endTime, jbyteArray jdata) {
+ jlong versionCode, jlong startTime, jlong endTime, jbyteArray jdata) {
std::string path;
const ProfileData* data = nullptr;
LOG_ALWAYS_FATAL_IF(jdata == nullptr && jpath == nullptr, "Path and data can't both be null");
@@ -78,7 +78,7 @@
}
static void saveBuffer(JNIEnv* env, jobject clazz, jstring jpath, jstring jpackage,
- jint versionCode, jlong startTime, jlong endTime, jbyteArray jdata) {
+ jlong versionCode, jlong startTime, jlong endTime, jbyteArray jdata) {
ScopedByteArrayRO buffer(env, jdata);
LOG_ALWAYS_FATAL_IF(buffer.size() != sizeof(ProfileData),
"Buffer size %zu doesn't match expected %zu!", buffer.size(), sizeof(ProfileData));
@@ -96,10 +96,10 @@
static const JNINativeMethod sMethods[] = {
{ "nGetAshmemSize", "()I", (void*) getAshmemSize },
{ "nCreateDump", "(IZ)J", (void*) createDump },
- { "nAddToDump", "(JLjava/lang/String;Ljava/lang/String;IJJ[B)V", (void*) addToDump },
+ { "nAddToDump", "(JLjava/lang/String;Ljava/lang/String;JJJ[B)V", (void*) addToDump },
{ "nAddToDump", "(JLjava/lang/String;)V", (void*) addFileToDump },
{ "nFinishDump", "(J)V", (void*) finishDump },
- { "nSaveBuffer", "(Ljava/lang/String;Ljava/lang/String;IJJ[B)V", (void*) saveBuffer },
+ { "nSaveBuffer", "(Ljava/lang/String;Ljava/lang/String;JJJ[B)V", (void*) saveBuffer },
};
int register_android_server_GraphicsStatsService(JNIEnv* env)