mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-07 22:42:13 +08:00
revert D2779079
Reviewed By: zjj010104 Differential Revision: D2802728 fb-gh-sync-id: 9e09f00d1d7facd2091fe60eee8565c4bf599b1d
This commit is contained in:
committed by
facebook-github-bot-7
parent
18cdead76b
commit
ee82bad3f7
@@ -17,7 +17,6 @@ import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@@ -47,7 +46,6 @@ import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import com.facebook.react.bridge.queue.CatalystQueueConfigurationSpec;
|
||||
import com.facebook.react.common.ApplicationHolder;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.devsupport.DevServerHelper;
|
||||
@@ -204,9 +202,6 @@ import com.facebook.systrace.Systrace;
|
||||
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
|
||||
initializeSoLoaderIfNecessary(applicationContext);
|
||||
|
||||
// TODO(9577825): remove this
|
||||
ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
|
||||
|
||||
mApplicationContext = applicationContext;
|
||||
mJSBundleFile = jsBundleFile;
|
||||
mJSMainModuleName = jsMainModuleName;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.common;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/**
|
||||
* Holds the current Application Object.
|
||||
*
|
||||
* TODO(9577825): This is a bad pattern, we should thread through an Environment object instead.
|
||||
* Remove once bridge is unforked.
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Deprecated
|
||||
public class ApplicationHolder {
|
||||
|
||||
private static Application sApplication;
|
||||
|
||||
public static void setApplication(Application application) {
|
||||
sApplication = application;
|
||||
}
|
||||
|
||||
public static Application getApplication() {
|
||||
return Assertions.assertNotNull(sApplication);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/asset_manager_jni.h>
|
||||
#include <jni/Environment.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <streambuf>
|
||||
@@ -19,19 +18,6 @@ using fbsystrace::FbSystraceSection;
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
static jclass gApplicationHolderClass;
|
||||
static jmethodID gGetApplicationMethod;
|
||||
static jmethodID gGetAssetManagerMethod;
|
||||
|
||||
std::string loadScriptFromAssets(std::string assetName) {
|
||||
JNIEnv *env = jni::Environment::current();
|
||||
jobject application = env->CallStaticObjectMethod(
|
||||
gApplicationHolderClass,
|
||||
gGetApplicationMethod);
|
||||
jobject assetManager = env->CallObjectMethod(application, gGetAssetManagerMethod);
|
||||
return loadScriptFromAssets(env, assetManager, assetName);
|
||||
}
|
||||
|
||||
std::string loadScriptFromAssets(
|
||||
JNIEnv *env,
|
||||
jobject assetManager,
|
||||
@@ -85,14 +71,4 @@ std::string loadScriptFromFile(std::string fileName) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void registerJSLoaderNatives() {
|
||||
JNIEnv *env = jni::Environment::current();
|
||||
jclass applicationHolderClass = env->FindClass("com/facebook/react/common/ApplicationHolder");
|
||||
gApplicationHolderClass = (jclass)env->NewGlobalRef(applicationHolderClass);
|
||||
gGetApplicationMethod = env->GetStaticMethodID(applicationHolderClass, "getApplication", "()Landroid/app/Application;");
|
||||
|
||||
jclass appClass = env->FindClass("android/app/Application");
|
||||
gGetAssetManagerMethod = env->GetMethodID(appClass, "getAssets", "()Landroid/content/res/AssetManager;");
|
||||
}
|
||||
|
||||
} }
|
||||
} }
|
||||
@@ -8,12 +8,6 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/**
|
||||
* Helper method for loading a JS script from Android assets without
|
||||
* a reference to an AssetManager.
|
||||
*/
|
||||
std::string loadScriptFromAssets(std::string assetName);
|
||||
|
||||
/**
|
||||
* Helper method for loading JS script from android asset
|
||||
*/
|
||||
@@ -24,6 +18,4 @@ std::string loadScriptFromAssets(JNIEnv *env, jobject assetManager, std::string
|
||||
*/
|
||||
std::string loadScriptFromFile(std::string fileName);
|
||||
|
||||
void registerJSLoaderNatives();
|
||||
|
||||
} }
|
||||
|
||||
@@ -780,7 +780,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
NativeArray::registerNatives();
|
||||
ReadableNativeArray::registerNatives();
|
||||
WritableNativeArray::registerNatives();
|
||||
registerJSLoaderNatives();
|
||||
|
||||
registerNatives("com/facebook/react/bridge/NativeMap", {
|
||||
makeNativeMethod("initialize", map::initialize),
|
||||
|
||||
Reference in New Issue
Block a user