OLD | NEW |
| (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.content.app; | |
6 | |
7 import android.os.Build; | |
8 | |
9 import org.chromium.base.CalledByNative; | |
10 | |
11 /** | |
12 * Provides necessary information for building the user agent string. | |
13 */ | |
14 class UserAgent { | |
15 // TODO(yfriedman): Keep this reasonably up to date. | |
16 private static final String PREVIOUS_VERSION = "4.0.3"; | |
17 | |
18 @CalledByNative | |
19 static String getUserAgentOSInfo() { | |
20 String osInfo = ""; | |
21 final String version = Build.VERSION.RELEASE; | |
22 if (version.length() > 0) { | |
23 if (Character.isDigit(version.charAt(0))) { | |
24 // Release is a version, eg "3.1" | |
25 osInfo += version; | |
26 } else { | |
27 // Release doesn't have a version number yet, eg "Honeycomb" | |
28 // In this case, use the previous release's version | |
29 osInfo += PREVIOUS_VERSION; | |
30 } | |
31 } else { | |
32 // default to "1.0" | |
33 osInfo += "1.0"; | |
34 } | |
35 osInfo += ";"; | |
36 | |
37 if ("REL".equals(Build.VERSION.CODENAME)) { | |
38 final String model = Build.MODEL; | |
39 if (model.length() > 0) { | |
40 osInfo += " " + model; | |
41 } | |
42 } | |
43 final String id = Build.ID; | |
44 if (id.length() > 0) { | |
45 osInfo += " Build/" + id; | |
46 } | |
47 | |
48 return osInfo; | |
49 } | |
50 } | |
OLD | NEW |