| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.omaha; | 5 package org.chromium.chrome.browser.omaha; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Build; | 8 import android.os.Build; |
| 9 import android.util.Xml; | 9 import android.util.Xml; |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 long currentTimestamp, long installTimestamp, boolean sendInstallEve
nt) { | 40 long currentTimestamp, long installTimestamp, boolean sendInstallEve
nt) { |
| 41 if (sendInstallEvent) { | 41 if (sendInstallEvent) { |
| 42 return INSTALL_AGE_IMMEDIATELY_AFTER_INSTALLING; | 42 return INSTALL_AGE_IMMEDIATELY_AFTER_INSTALLING; |
| 43 } else { | 43 } else { |
| 44 return Math.max(0L, (currentTimestamp - installTimestamp) / MS_PER_D
AY); | 44 return Math.max(0L, (currentTimestamp - installTimestamp) / MS_PER_D
AY); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Generates the XML for the current request. | 49 * Generates the XML for the current request. |
| 50 * Follows the format laid out at http://code.google.com/p/omaha/wiki/Server
Protocol | 50 * Follows the format laid out at https://github.com/google/omaha/blob/wiki/
ServerProtocolV3.md |
| 51 * with some additional dummy values supplied. | 51 * with some additional dummy values supplied. |
| 52 */ | 52 */ |
| 53 public String generateXML(String sessionID, String versionName, long install
Age, | 53 public String generateXML(String sessionID, String versionName, long install
Age, |
| 54 RequestData data) throws RequestFailureException { | 54 RequestData data) throws RequestFailureException { |
| 55 XmlSerializer serializer = Xml.newSerializer(); | 55 XmlSerializer serializer = Xml.newSerializer(); |
| 56 StringWriter writer = new StringWriter(); | 56 StringWriter writer = new StringWriter(); |
| 57 try { | 57 try { |
| 58 serializer.setOutput(writer); | 58 serializer.setOutput(writer); |
| 59 serializer.startDocument("UTF-8", true); | 59 serializer.startDocument("UTF-8", true); |
| 60 | 60 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 /** Returns the brand code. If one can't be retrieved, return "". */ | 172 /** Returns the brand code. If one can't be retrieved, return "". */ |
| 173 protected abstract String getBrand(); | 173 protected abstract String getBrand(); |
| 174 | 174 |
| 175 /** Returns the current client ID. */ | 175 /** Returns the current client ID. */ |
| 176 protected abstract String getClient(); | 176 protected abstract String getClient(); |
| 177 | 177 |
| 178 /** URL for the Omaha server. */ | 178 /** URL for the Omaha server. */ |
| 179 public abstract String getServerUrl(); | 179 public abstract String getServerUrl(); |
| 180 } | 180 } |
| OLD | NEW |