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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/HostInfo.java

Issue 2629593003: [Chromoting.com] Make Android telemetry report host version/os/os version (Closed)
Patch Set: PTAL Point Created 3 years, 11 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
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/SessionConnector.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Resources; 8 import android.content.res.Resources;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 10
11 import org.chromium.base.Log;
12
13 import org.json.JSONArray; 11 import org.json.JSONArray;
14 import org.json.JSONException; 12 import org.json.JSONException;
15 import org.json.JSONObject; 13 import org.json.JSONObject;
16 14
15 import org.chromium.base.Log;
16
17 import java.text.ParsePosition; 17 import java.text.ParsePosition;
18 import java.text.SimpleDateFormat; 18 import java.text.SimpleDateFormat;
19 import java.util.ArrayList; 19 import java.util.ArrayList;
20 import java.util.Date; 20 import java.util.Date;
21 import java.util.Locale; 21 import java.util.Locale;
22 import java.util.TimeZone; 22 import java.util.TimeZone;
23 23
24 /** Class to represent a Host returned by {@link HostListManager}. */ 24 /** Class to represent a Host returned by {@link HostListManager}. */
25 public class HostInfo { 25 public class HostInfo {
26 private static final String TAG = "Chromoting"; 26 private static final String TAG = "Chromoting";
27 27
28 public final String name; 28 public final String name;
29 public final String id; 29 public final String id;
30 public final String jabberId; 30 public final String jabberId;
31 public final String publicKey; 31 public final String publicKey;
32 public final boolean isOnline; 32 public final boolean isOnline;
33 public final String hostOfflineReason; 33 public final String hostOfflineReason;
34 public final Date updatedTime; 34 public final Date updatedTime;
35 public final String hostVersion;
36 public final String hostOs;
37 public final String hostOsVersion;
35 38
36 private final ArrayList<String> mTokenUrlPatterns; 39 private final ArrayList<String> mTokenUrlPatterns;
37 40
38 // Format of time values coming from the Chromoting REST API. 41 // Format of time values coming from the Chromoting REST API.
39 // This is a specific form of RFC3339 (with no timezone info). 42 // This is a specific form of RFC3339 (with no timezone info).
40 // Example value to be parsed: 2014-11-21T01:02:33.814Z 43 // Example value to be parsed: 2014-11-21T01:02:33.814Z
41 private static final String RFC_3339_FORMAT = "yyyy'-'MM'-'dd'T'HH':'mm':'ss '.'SSS'Z'"; 44 private static final String RFC_3339_FORMAT = "yyyy'-'MM'-'dd'T'HH':'mm':'ss '.'SSS'Z'";
42 45
43 // Value to use if time string received from the network is malformed. 46 // Value to use if time string received from the network is malformed.
44 // Such malformed string should in theory never happen, but we want 47 // Such malformed string should in theory never happen, but we want
45 // to have a safe fallback in case it does happen. 48 // to have a safe fallback in case it does happen.
46 private static final Date FALLBACK_DATE_IN_THE_PAST = new Date(0); 49 private static final Date FALLBACK_DATE_IN_THE_PAST = new Date(0);
47 50
48 public HostInfo(String name, String id, String jabberId, String publicKey, 51 public HostInfo(String name, String id, String jabberId, String publicKey,
49 ArrayList<String> tokenUrlPatterns, boolean isOnline, String hostOff lineReason, 52 ArrayList<String> tokenUrlPatterns, boolean isOnline, String hostOff lineReason,
50 String updatedTime) { 53 String updatedTime, String hostVersion, String hostOs, String hostOs Version) {
51 this.name = name; 54 this.name = name;
52 this.id = id; 55 this.id = id;
53 this.jabberId = jabberId; 56 this.jabberId = jabberId;
54 this.publicKey = publicKey; 57 this.publicKey = publicKey;
55 this.mTokenUrlPatterns = tokenUrlPatterns; 58 this.mTokenUrlPatterns = tokenUrlPatterns;
56 this.isOnline = isOnline; 59 this.isOnline = isOnline;
57 this.hostOfflineReason = hostOfflineReason; 60 this.hostOfflineReason = hostOfflineReason;
61 this.hostVersion = hostVersion;
62 this.hostOs = hostOs;
63 this.hostOsVersion = hostOsVersion;
58 64
59 ParsePosition parsePosition = new ParsePosition(0); 65 ParsePosition parsePosition = new ParsePosition(0);
60 SimpleDateFormat format = new SimpleDateFormat(RFC_3339_FORMAT, Locale.U S); 66 SimpleDateFormat format = new SimpleDateFormat(RFC_3339_FORMAT, Locale.U S);
61 format.setTimeZone(TimeZone.getTimeZone("UTC")); 67 format.setTimeZone(TimeZone.getTimeZone("UTC"));
62 Date updatedTimeCandidate = format.parse(updatedTime, parsePosition); 68 Date updatedTimeCandidate = format.parse(updatedTime, parsePosition);
63 if (updatedTimeCandidate == null) { 69 if (updatedTimeCandidate == null) {
64 Log.e(TAG, "Unparseable host.updatedTime JSON: errorIndex = %d, inpu t = %s", 70 Log.e(TAG, "Unparseable host.updatedTime JSON: errorIndex = %d, inpu t = %s",
65 parsePosition.getErrorIndex(), updatedTime); 71 parsePosition.getErrorIndex(), updatedTime);
66 updatedTimeCandidate = FALLBACK_DATE_IN_THE_PAST; 72 updatedTimeCandidate = FALLBACK_DATE_IN_THE_PAST;
67 } 73 }
(...skipping 28 matching lines...) Expand all
96 for (int i = 0; i < jsonPatterns.length(); i++) { 102 for (int i = 0; i < jsonPatterns.length(); i++) {
97 String pattern = jsonPatterns.getString(i); 103 String pattern = jsonPatterns.getString(i);
98 if (pattern != null && !pattern.isEmpty()) { 104 if (pattern != null && !pattern.isEmpty()) {
99 tokenUrlPatterns.add(pattern); 105 tokenUrlPatterns.add(pattern);
100 } 106 }
101 } 107 }
102 } 108 }
103 return new HostInfo(json.getString("hostName"), json.getString("hostId") , 109 return new HostInfo(json.getString("hostName"), json.getString("hostId") ,
104 json.optString("jabberId"), json.optString("publicKey"), tokenUr lPatterns, 110 json.optString("jabberId"), json.optString("publicKey"), tokenUr lPatterns,
105 json.optString("status").equals("ONLINE"), json.optString("hostO fflineReason"), 111 json.optString("status").equals("ONLINE"), json.optString("hostO fflineReason"),
106 json.optString("updatedTime")); 112 json.optString("updatedTime"), json.optString("hostVersion"),
113 json.optString("hostOs"), json.optString("hostOsVersion"));
107 } 114 }
108 } 115 }
OLDNEW
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/SessionConnector.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698