| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.minting; | 5 package org.chromium.minting; |
| 6 | 6 |
| 7 import android.app.Application; | 7 import android.app.Application; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.pm.PackageManager.NameNotFoundException; | |
| 10 import android.util.Log; | 9 import android.util.Log; |
| 11 | 10 |
| 12 import org.chromium.minting.lib.common.WebAPKUtils; | 11 import org.chromium.minting.lib.common.WebApkUtils; |
| 13 | 12 |
| 14 import java.lang.reflect.Array; | 13 import java.lang.reflect.Array; |
| 15 import java.util.List; | 14 import java.util.List; |
| 16 | 15 |
| 17 /** | 16 /** |
| 18 * Example application for a minted APK. | 17 * Example application for a minted APK. |
| 19 */ | 18 */ |
| 20 public class MintingApplication extends Application { | 19 public class WebApkApplication extends Application { |
| 21 // Context of Chrome. | 20 // Context of Chrome. |
| 22 private Context mRemoteContext = null; | 21 private Context mRemoteContext = null; |
| 23 | 22 |
| 24 private static final String TAG = "cr.MintingApplication"; | 23 private static final String TAG = "cr.WebApkApplication"; |
| 25 /** | 24 /** |
| 26 * Copy all the objects from a specified field of the hostInstance to the sa
me field of the | 25 * Copy all the objects from a specified field of the hostInstance to the sa
me field of the |
| 27 * mintInstance. As a result, the given field of the mintInstance will conta
in all the | 26 * mintInstance. As a result, the given field of the mintInstance will conta
in all the |
| 28 * objects from both instances. | 27 * objects from both instances. |
| 29 * @param mintInstance the first instance which contains a field of the give
n fieldName. | 28 * @param mintInstance the first instance which contains a field of the give
n fieldName. |
| 30 * @param fieldName the name of field to expand to an Object array. | 29 * @param fieldName the name of field to expand to an Object array. |
| 31 * @param hostInstance the second instance which has a field of the given fi
eldName. | 30 * @param hostInstance the second instance which has a field of the given fi
eldName. |
| 32 * @throws NoSuchFieldException | 31 * @throws NoSuchFieldException |
| 33 * @throws IllegalArgumentException | 32 * @throws IllegalArgumentException |
| 34 * @throws IllegalAccessException | 33 * @throws IllegalAccessException |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // native library directories first. If a ".so" file doesn't exit, then
search /system/lib. | 136 // native library directories first. If a ".so" file doesn't exit, then
search /system/lib. |
| 138 Object extDexPathList = Reflect.getField(externalLoader, "pathList"); | 137 Object extDexPathList = Reflect.getField(externalLoader, "pathList"); |
| 139 Object mintDexPathList = Reflect.getField(mintLoader, "pathList"); | 138 Object mintDexPathList = Reflect.getField(mintLoader, "pathList"); |
| 140 expandField(mintDexPathList, "nativeLibraryDirectories", extDexPathList)
; | 139 expandField(mintDexPathList, "nativeLibraryDirectories", extDexPathList)
; |
| 141 expandField(mintDexPathList, "nativeLibraryPathElements", extDexPathList
); | 140 expandField(mintDexPathList, "nativeLibraryPathElements", extDexPathList
); |
| 142 } | 141 } |
| 143 | 142 |
| 144 @Override | 143 @Override |
| 145 public void onCreate() { | 144 public void onCreate() { |
| 146 super.onCreate(); | 145 super.onCreate(); |
| 147 mRemoteContext = WebAPKUtils.getHostBrowserContext(this); | 146 mRemoteContext = WebApkUtils.getHostBrowserContext(this); |
| 148 try { | 147 try { |
| 149 addExternalLoader(); | 148 addExternalLoader(); |
| 150 addNativeLibrarySearchPath(); | 149 addNativeLibrarySearchPath(); |
| 151 } catch (ReflectiveOperationException e) { | 150 } catch (ReflectiveOperationException e) { |
| 152 e.printStackTrace(); | 151 e.printStackTrace(); |
| 153 } | 152 } |
| 154 Log.w(TAG, "Successfully add external loader."); | 153 Log.w(TAG, "Successfully add external loader."); |
| 155 } | 154 } |
| 156 } | 155 } |
| OLD | NEW |