Log app versionCode in anomaly detection
Change-Id: Ie760a4156b14b739279aa398bd1d2b8485449e91 Fixes: 77919142 Test: RunSettingsRoboTests
This commit is contained in:
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.BatteryStats;
|
||||
@@ -595,5 +596,21 @@ public class BatteryUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return version number of an app represented by {@code packageName}, and return -1 if not
|
||||
* found.
|
||||
*/
|
||||
public long getAppLongVersionCode(String packageName) {
|
||||
try {
|
||||
final PackageInfo packageInfo = mPackageManager.getPackageInfo(packageName,
|
||||
0 /* flags */);
|
||||
return packageInfo.getLongVersionCode();
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Cannot find package: " + packageName, e);
|
||||
}
|
||||
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user