| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.base; | 5 package org.chromium.base; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.pm.ApplicationInfo; | 8 import android.content.pm.ApplicationInfo; |
| 9 import android.content.pm.PackageInfo; | 9 import android.content.pm.PackageInfo; |
| 10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 @CalledByNative | 66 @CalledByNative |
| 67 public static String getGMSVersionCode(Context context) { | 67 public static String getGMSVersionCode(Context context) { |
| 68 String msg = "gms versionCode not available."; | 68 String msg = "gms versionCode not available."; |
| 69 try { | 69 try { |
| 70 PackageManager packageManager = context.getPackageManager(); | 70 PackageManager packageManager = context.getPackageManager(); |
| 71 PackageInfo packageInfo = packageManager.getPackageInfo("com.google.
android.gms", 0); | 71 PackageInfo packageInfo = packageManager.getPackageInfo("com.google.
android.gms", 0); |
| 72 msg = Integer.toString(packageInfo.versionCode); | 72 msg = Integer.toString(packageInfo.versionCode); |
| 73 } catch (NameNotFoundException e) { | 73 } catch (NameNotFoundException e) { |
| 74 Log.d(TAG, "GMS package is not found: %s", e); | 74 Log.d(TAG, "GMS package is not found.", e); |
| 75 } | 75 } |
| 76 return msg; | 76 return msg; |
| 77 } | 77 } |
| 78 | 78 |
| 79 @CalledByNative | 79 @CalledByNative |
| 80 public static String getPackageVersionCode(Context context) { | 80 public static String getPackageVersionCode(Context context) { |
| 81 String msg = "versionCode not available."; | 81 String msg = "versionCode not available."; |
| 82 try { | 82 try { |
| 83 PackageManager pm = context.getPackageManager(); | 83 PackageManager pm = context.getPackageManager(); |
| 84 PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); | 84 PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return Build.VERSION.SDK_INT; | 141 return Build.VERSION.SDK_INT; |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * @return Whether the current build version is greater than Android N. | 145 * @return Whether the current build version is greater than Android N. |
| 146 */ | 146 */ |
| 147 public static boolean isGreaterThanN() { | 147 public static boolean isGreaterThanN() { |
| 148 return Build.VERSION.SDK_INT > 24 || Build.VERSION.CODENAME.equals("NMR1
"); | 148 return Build.VERSION.SDK_INT > 24 || Build.VERSION.CODENAME.equals("NMR1
"); |
| 149 } | 149 } |
| 150 } | 150 } |
| OLD | NEW |