| 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.annotation.TargetApi; | |
| 8 import android.content.Context; | 7 import android.content.Context; |
| 9 import android.content.pm.ApplicationInfo; | 8 import android.content.pm.ApplicationInfo; |
| 10 import android.content.pm.PackageInfo; | 9 import android.content.pm.PackageInfo; |
| 11 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
| 12 import android.content.pm.PackageManager.NameNotFoundException; | 11 import android.content.pm.PackageManager.NameNotFoundException; |
| 13 import android.os.Build; | 12 import android.os.Build; |
| 14 import android.util.Log; | 13 import android.util.Log; |
| 15 | 14 |
| 16 import org.chromium.base.annotations.CalledByNative; | 15 import org.chromium.base.annotations.CalledByNative; |
| 17 | 16 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 @CalledByNative | 126 @CalledByNative |
| 128 public static int getSdkInt() { | 127 public static int getSdkInt() { |
| 129 return Build.VERSION.SDK_INT; | 128 return Build.VERSION.SDK_INT; |
| 130 } | 129 } |
| 131 | 130 |
| 132 private static boolean isLanguageSplit(String splitName) { | 131 private static boolean isLanguageSplit(String splitName) { |
| 133 // Names look like "config.XX". | 132 // Names look like "config.XX". |
| 134 return splitName.length() == 9 && splitName.startsWith("config."); | 133 return splitName.length() == 9 && splitName.startsWith("config."); |
| 135 } | 134 } |
| 136 | |
| 137 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
| 138 @CalledByNative | |
| 139 public static boolean hasLanguageApkSplits(Context context) { | |
| 140 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | |
| 141 return false; | |
| 142 } | |
| 143 PackageInfo packageInfo = PackageUtils.getOwnPackageInfo(context); | |
| 144 if (packageInfo.splitNames != null) { | |
| 145 for (int i = 0; i < packageInfo.splitNames.length; ++i) { | |
| 146 if (isLanguageSplit(packageInfo.splitNames[i])) { | |
| 147 return true; | |
| 148 } | |
| 149 } | |
| 150 } | |
| 151 return false; | |
| 152 } | |
| 153 } | 135 } |
| OLD | NEW |