OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.webapk.lib.client; | 5 package org.chromium.webapk.lib.client; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.os.Build; | 8 import android.os.Build; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 * odex. | 164 * odex. |
165 * | 165 * |
166 * - This API is not available on pre-L devices, but as the pre-L runtime di d not scope odex | 166 * - This API is not available on pre-L devices, but as the pre-L runtime di d not scope odex |
167 * files by <isa> on pre-L, this is not a problem. | 167 * files by <isa> on pre-L, this is not a problem. |
168 * | 168 * |
169 * - For devices L+, it's still possible for this API to be missing. In that case | 169 * - For devices L+, it's still possible for this API to be missing. In that case |
170 * we will fallback to A) interpretation, and failing that B) generate an odex in the | 170 * we will fallback to A) interpretation, and failing that B) generate an odex in the |
171 * client's file space. | 171 * client's file space. |
172 */ | 172 */ |
173 private static class VMRuntime { | 173 private static class VMRuntime { |
174 // TODO(crbug.com/635567): Fix this properly. | |
Ted C
2017/04/27 19:02:48
the comment above implies this is likely not an is
F
2017/04/28 18:25:15
Done.
| |
175 @SuppressLint("NewApi") | |
174 @SuppressWarnings("unchecked") | 176 @SuppressWarnings("unchecked") |
175 public static String getCurrentInstructionSet() throws NoSuchMethodExcep tion { | 177 public static String getCurrentInstructionSet() throws NoSuchMethodExcep tion { |
176 Method getCurrentInstructionSetMethod; | 178 Method getCurrentInstructionSetMethod; |
177 try { | 179 try { |
178 Class c = Class.forName("dalvik.system.VMRuntime"); | 180 Class c = Class.forName("dalvik.system.VMRuntime"); |
179 getCurrentInstructionSetMethod = c.getDeclaredMethod("getCurrent InstructionSet"); | 181 getCurrentInstructionSetMethod = c.getDeclaredMethod("getCurrent InstructionSet"); |
180 } catch (ClassNotFoundException | NoSuchMethodException e) { | 182 } catch (ClassNotFoundException | NoSuchMethodException e) { |
181 Log.w(TAG, "dalvik.system.VMRuntime#getCurrentInstructionSet is unsupported.", e); | 183 Log.w(TAG, "dalvik.system.VMRuntime#getCurrentInstructionSet is unsupported.", e); |
182 throw new NoSuchMethodException( | 184 throw new NoSuchMethodException( |
183 "dalvik.system.VMRuntime#getCurrentInstructionSet could not be found."); | 185 "dalvik.system.VMRuntime#getCurrentInstructionSet could not be found."); |
184 } | 186 } |
185 try { | 187 try { |
186 return (String) getCurrentInstructionSetMethod.invoke(null); | 188 return (String) getCurrentInstructionSetMethod.invoke(null); |
187 } catch (IllegalAccessException | InvocationTargetException e) { | 189 } catch (IllegalAccessException | InvocationTargetException e) { |
188 Log.w(TAG, "Failed to call dalvik.system.VMRuntime#getCurrentIns tructionSet", e); | 190 Log.w(TAG, "Failed to call dalvik.system.VMRuntime#getCurrentIns tructionSet", e); |
189 throw new NoSuchMethodException( | 191 throw new NoSuchMethodException( |
190 "dalvik.system.VMRuntime#getCurrentInstructionSet could not be found."); | 192 "dalvik.system.VMRuntime#getCurrentInstructionSet could not be found."); |
191 } | 193 } |
192 } | 194 } |
193 } | 195 } |
194 } | 196 } |
OLD | NEW |