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 @SuppressLint("NewApi") |
174 @SuppressWarnings("unchecked") | 175 @SuppressWarnings("unchecked") |
175 public static String getCurrentInstructionSet() throws NoSuchMethodExcep
tion { | 176 public static String getCurrentInstructionSet() throws NoSuchMethodExcep
tion { |
176 Method getCurrentInstructionSetMethod; | 177 Method getCurrentInstructionSetMethod; |
177 try { | 178 try { |
178 Class c = Class.forName("dalvik.system.VMRuntime"); | 179 Class c = Class.forName("dalvik.system.VMRuntime"); |
179 getCurrentInstructionSetMethod = c.getDeclaredMethod("getCurrent
InstructionSet"); | 180 getCurrentInstructionSetMethod = c.getDeclaredMethod("getCurrent
InstructionSet"); |
180 } catch (ClassNotFoundException | NoSuchMethodException e) { | 181 } catch (ClassNotFoundException | NoSuchMethodException e) { |
181 Log.w(TAG, "dalvik.system.VMRuntime#getCurrentInstructionSet is
unsupported.", e); | 182 Log.w(TAG, "dalvik.system.VMRuntime#getCurrentInstructionSet is
unsupported.", e); |
182 throw new NoSuchMethodException( | 183 throw new NoSuchMethodException( |
183 "dalvik.system.VMRuntime#getCurrentInstructionSet could
not be found."); | 184 "dalvik.system.VMRuntime#getCurrentInstructionSet could
not be found."); |
184 } | 185 } |
185 try { | 186 try { |
186 return (String) getCurrentInstructionSetMethod.invoke(null); | 187 return (String) getCurrentInstructionSetMethod.invoke(null); |
187 } catch (IllegalAccessException | InvocationTargetException e) { | 188 } catch (IllegalAccessException | InvocationTargetException e) { |
188 Log.w(TAG, "Failed to call dalvik.system.VMRuntime#getCurrentIns
tructionSet", e); | 189 Log.w(TAG, "Failed to call dalvik.system.VMRuntime#getCurrentIns
tructionSet", e); |
189 throw new NoSuchMethodException( | 190 throw new NoSuchMethodException( |
190 "dalvik.system.VMRuntime#getCurrentInstructionSet could
not be found."); | 191 "dalvik.system.VMRuntime#getCurrentInstructionSet could
not be found."); |
191 } | 192 } |
192 } | 193 } |
193 } | 194 } |
194 } | 195 } |
OLD | NEW |