• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package org.chromium.net;
6
7/**
8 * Version based on chrome/VERSION.
9 * {@hide as it's only used internally}
10 */
11public class ApiVersion {
12    private static final String CRONET_VERSION = "@MAJOR@.@MINOR@.@BUILD@.@PATCH@";
13    private static final int API_LEVEL = @API_LEVEL@;
14    /**
15     * The minimum API level of implementations that are compatible with this API.
16     * The last API level which broke backwards API compatibility. In other words, the
17     * Cronet API that this class is part of won't work with Cronet implementations that implement
18     * API levels less than this value. That is if
19     * ImplVersion.getApiLevel() < ApiVersion.getApiLevel(), then the Cronet implementation
20     * providing ImplVersion cannot be used with the Cronet API providing ApiVersion; if they are
21     * used together various unexpected Errors, like AbstractMethodError, may result.
22     */
23    private static final int MIN_COMPATIBLE_API_LEVEL = 3;
24    private static final String LAST_CHANGE = "@LASTCHANGE@";
25
26    /**
27     * Private constructor. All members of this class should be static.
28     */
29    private ApiVersion() {}
30
31    public static String getCronetVersionWithLastChange() {
32        return CRONET_VERSION + "@" + LAST_CHANGE.substring(0, 8);
33    }
34
35    /**
36     * Returns API level of the API linked into the application. This is the maximum API
37     * level the application can use, even if the application is run with a newer implementation.
38     */
39    public static int getMaximumAvailableApiLevel() {
40        return API_LEVEL;
41    }
42
43    /**
44     * The minimum API level of implementations that are compatible with this API.
45     * Returns the last API level which broke backwards API compatibility. In other words, the
46     * Cronet API that this class is part of won't work with Cronet implementations that implement
47     * API levels less than this value. That is if
48     * ImplVersion.getApiLevel() < ApiVersion.getApiLevel(), then the Cronet implementation
49     * providing ImplVersion cannot be used with the Cronet API providing ApiVersion; if they are
50     * used together various unexpected Errors, like AbstractMethodError, may result.
51     */
52    public static int getApiLevel() {
53        return MIN_COMPATIBLE_API_LEVEL;
54    }
55
56    public static String getCronetVersion() {
57        return CRONET_VERSION;
58    }
59
60    public static String getLastChange() {
61        return LAST_CHANGE;
62    }
63}
64