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; | 7 import android.annotation.TargetApi; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.pm.ApplicationInfo; | 9 import android.content.pm.ApplicationInfo; |
10 import android.content.pm.PackageInfo; | 10 import android.content.pm.PackageInfo; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 127 |
128 /** | 128 /** |
129 * @return Whether the Android build is M or later. | 129 * @return Whether the Android build is M or later. |
130 */ | 130 */ |
131 public static boolean isMncOrLater() { | 131 public static boolean isMncOrLater() { |
132 // TODO(bauerb): Update this once the SDK is updated. | 132 // TODO(bauerb): Update this once the SDK is updated. |
133 return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 | 133 return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1 |
134 || TextUtils.equals("MNC", Build.VERSION.CODENAME); | 134 || TextUtils.equals("MNC", Build.VERSION.CODENAME); |
135 } | 135 } |
136 | 136 |
137 private static boolean isLanguageSplit(String splitName) { | |
138 // Names look like "config.XX". | |
139 return splitName.length() == 9 && splitName.startsWith("config."); | |
Yaron
2015/07/08 21:31:22
we control the split name, don't we? can we make i
agrieve
2015/07/09 00:11:30
Yeah, I don't love this either, but we don't contr
| |
140 } | |
141 | |
137 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 142 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
138 @CalledByNative | 143 @CalledByNative |
139 public static boolean hasApkSplits(Context context) { | 144 public static boolean hasLanguageApkSplits(Context context) { |
140 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | 145 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |
141 return false; | 146 return false; |
142 } | 147 } |
143 ApplicationInfo appInfo = context.getApplicationInfo(); | 148 PackageInfo packageInfo = PackageUtils.getOwnPackageInfo(context); |
144 return appInfo.splitSourceDirs != null && appInfo.splitSourceDirs.length > 0; | 149 if (packageInfo.splitNames != null) { |
150 for (int i = 0; i < packageInfo.splitNames.length; ++i) { | |
151 if (isLanguageSplit(packageInfo.splitNames[i])) { | |
152 return true; | |
153 } | |
154 } | |
155 } | |
156 return false; | |
145 } | 157 } |
146 } | 158 } |
OLD | NEW |