| 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.gsa; | 5 package org.chromium.chrome.browser.gsa; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 9 import android.content.Context; |
| 9 import android.content.Intent; | 10 import android.content.Intent; |
| 10 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
| 11 import android.content.pm.ResolveInfo; | 12 import android.content.pm.ResolveInfo; |
| 12 import android.text.TextUtils; | 13 import android.text.TextUtils; |
| 13 | 14 |
| 14 import org.chromium.base.PackageUtils; | 15 import org.chromium.base.PackageUtils; |
| 15 import org.chromium.components.signin.ChromeSigninController; | 16 import org.chromium.components.signin.ChromeSigninController; |
| 16 | 17 |
| 17 import java.util.List; | 18 import java.util.List; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * A class responsible fore representing the current state of Chrome's integrati
on with GSA. | 21 * A class responsible fore representing the current state of Chrome's integrati
on with GSA. |
| 21 */ | 22 */ |
| 22 public class GSAState { | 23 public class GSAState { |
| 23 private static final int GSA_VERSION_FOR_DOCUMENT = 300401021; | 24 private static final int GSA_VERSION_FOR_DOCUMENT = 300401021; |
| 24 private static final int GMS_CORE_VERSION = 6577010; | 25 private static final int GMS_CORE_VERSION = 6577010; |
| 25 | 26 |
| 26 static final String SEARCH_INTENT_PACKAGE = "com.google.android.googlequicks
earchbox"; | 27 static final String SEARCH_INTENT_PACKAGE = "com.google.android.googlequicks
earchbox"; |
| 27 private static final String GMS_CORE_PACKAGE = "com.google.android.gms"; | 28 private static final String GMS_CORE_PACKAGE = "com.google.android.gms"; |
| 28 | 29 |
| 29 static final String SEARCH_INTENT_ACTION = | 30 static final String SEARCH_INTENT_ACTION = |
| 30 "com.google.android.googlequicksearchbox.TEXT_ASSIST"; | 31 "com.google.android.googlequicksearchbox.TEXT_ASSIST"; |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * An instance of GSAState class encapsulating knowledge about the current s
tatus. | 34 * An instance of GSAState class encapsulating knowledge about the current s
tatus. |
| 34 */ | 35 */ |
| 36 @SuppressLint("StaticFieldLeak") |
| 35 private static GSAState sGSAState; | 37 private static GSAState sGSAState; |
| 36 | 38 |
| 37 /** | 39 /** |
| 38 * The application context to use. | 40 * The application context to use. |
| 39 */ | 41 */ |
| 40 private final Context mContext; | 42 private final Context mContext; |
| 41 | 43 |
| 42 /** | 44 /** |
| 43 * Caches the result of a computation on whether GSA is available. | 45 * Caches the result of a computation on whether GSA is available. |
| 44 */ | 46 */ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 * Check whether the given package meets min requirements for using full doc
ument mode. | 128 * Check whether the given package meets min requirements for using full doc
ument mode. |
| 127 * @param packageName The package name we are inquiring about. | 129 * @param packageName The package name we are inquiring about. |
| 128 * @param minVersion The minimum version for the package to be. | 130 * @param minVersion The minimum version for the package to be. |
| 129 * @return Whether the package exists on the device and its version is highe
r than the minimum | 131 * @return Whether the package exists on the device and its version is highe
r than the minimum |
| 130 * required version. | 132 * required version. |
| 131 */ | 133 */ |
| 132 private boolean isPackageAboveVersion(String packageName, int minVersion) { | 134 private boolean isPackageAboveVersion(String packageName, int minVersion) { |
| 133 return PackageUtils.getPackageVersion(mContext, packageName) >= minVersi
on; | 135 return PackageUtils.getPackageVersion(mContext, packageName) >= minVersi
on; |
| 134 } | 136 } |
| 135 } | 137 } |
| OLD | NEW |