Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: base/android/java/org/chromium/base/BuildInfo.java

Issue 9838033: Upstream native crash handling changes for Android. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Revert of Revert with fixes. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/android/build_info.cc ('k') | base/base.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.base;
6
7 import android.content.Context;
8 import android.content.pm.PackageInfo;
9 import android.content.pm.PackageManager;
10 import android.content.pm.PackageManager.NameNotFoundException;
11 import android.os.Build;
12 import android.util.Log;
13
14 /**
15 * BuildInfo is a utility class providing easy access to {@link PackageInfo}
16 * information. This is primarly of use for accessesing package information
17 * from native code.
18 */
19 public class BuildInfo {
20 private static final String TAG = "BuildInfo";
21 private static final int MAX_FINGERPRINT_LENGTH = 128;
22
23 /**
24 * BuildInfo is a static utility class and therefore should'nt be
25 * instantiated.
26 */
27 private BuildInfo() {
28 }
29
30 @CalledByNative
31 public static String getDevice() {
32 return Build.DEVICE;
33 }
34
35 @CalledByNative
36 public static String getBrand() {
37 return Build.BRAND;
38 }
39
40 @CalledByNative
41 public static String getAndroidBuildId() {
42 return Build.ID;
43 }
44
45 /**
46 * @return The build fingerprint for the current Android install. The value i s truncated to a
47 * 128 characters as this is used for crash and UMA reporting, which s hould avoid huge
48 * strings.
49 */
50 @CalledByNative
51 public static String getAndroidBuildFingerprint() {
52 return Build.FINGERPRINT.substring(
53 0, Math.min(Build.FINGERPRINT.length(), MAX_FINGERPRINT_LENGTH));
54 }
55
56 @CalledByNative
57 public static String getDeviceModel() {
58 return Build.MODEL;
59 }
60
61 @CalledByNative
62 public static String getPackageVersionCode(Context context) {
63 String msg = "versionCode not available.";
64 try {
65 PackageManager pm = context.getPackageManager();
66 PackageInfo pi = pm.getPackageInfo("com.android.chrome", 0);
67 msg = "" + pi.versionCode;
68 } catch (NameNotFoundException e) {
69 Log.d(TAG, msg);
70 }
71 return msg;
72
73 }
74
75 @CalledByNative
76 public static String getPackageVersionName(Context context) {
77 String msg = "versionName not available";
78 try {
79 PackageManager pm = context.getPackageManager();
80 PackageInfo pi = pm.getPackageInfo("com.android.chrome", 0);
81 msg = pi.versionName;
82 } catch (NameNotFoundException e) {
83 Log.d(TAG, msg);
84 }
85 return msg;
86 }
87
88 }
OLDNEW
« no previous file with comments | « base/android/build_info.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698