Skip to content

Commit 35f2d73

Browse files
committed
Api Rename
1 parent dae40db commit 35f2d73

18 files changed

+83
-91
lines changed

PluginCore/src/com/plugin/core/PluginAppTrace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private static Result beforeReceiver(Message msg) {
7676
if (clazz != null) {
7777
PluginInjector.hackHostClassLoaderIfNeeded();
7878

79-
Context baseContext = PluginLoader.getApplicatoin().getBaseContext();
79+
Context baseContext = PluginLoader.getApplication().getBaseContext();
8080
Context newBase = PluginLoader.getDefaultPluginContext(clazz);
8181

8282
PluginInjector.replaceReceiverContext(baseContext, newBase);

PluginCore/src/com/plugin/core/PluginInjector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,14 @@ static void replaceContext(Object manager, Context context) {
380380
* 如果插件中不包含service、receiver和contentprovider,是不需要替换classloader的
381381
*/
382382
public static void hackHostClassLoaderIfNeeded() {
383-
Object mLoadedApk = RefInvoker.getFieldObject(PluginLoader.getApplicatoin(), Application.class.getName(),
383+
Object mLoadedApk = RefInvoker.getFieldObject(PluginLoader.getApplication(), Application.class.getName(),
384384
"mLoadedApk");
385385
ClassLoader originalLoader = (ClassLoader) RefInvoker.getFieldObject(mLoadedApk, "android.app.LoadedApk",
386386
"mClassLoader");
387387
if (!(originalLoader instanceof HostClassLoader)) {
388-
HostClassLoader newLoader = new HostClassLoader("", PluginLoader.getApplicatoin()
388+
HostClassLoader newLoader = new HostClassLoader("", PluginLoader.getApplication()
389389
.getCacheDir().getAbsolutePath(),
390-
PluginLoader.getApplicatoin().getCacheDir().getAbsolutePath(), originalLoader);
390+
PluginLoader.getApplication().getCacheDir().getAbsolutePath(), originalLoader);
391391
RefInvoker.setFieldObject(mLoadedApk, "android.app.LoadedApk", "mClassLoader", newLoader);
392392
}
393393
}

PluginCore/src/com/plugin/core/PluginIntentResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void resolveService(Intent service) {
2424
if (classNameList != null && classNameList.size() > 0) {
2525
String stubServiceName = PluginManagerHelper.bindStubService(classNameList.get(0));
2626
if (stubServiceName != null) {
27-
service.setComponent(new ComponentName(PluginLoader.getApplicatoin().getPackageName(), stubServiceName));
27+
service.setComponent(new ComponentName(PluginLoader.getApplication().getPackageName(), stubServiceName));
2828
}
2929
}
3030
}
@@ -37,7 +37,7 @@ public static ArrayList<Intent> resolveReceiver(final Intent intent) {
3737
if (classNameList != null && classNameList.size() > 0) {
3838
for(String className: classNameList) {
3939
Intent newIntent = new Intent(intent);
40-
newIntent.setComponent(new ComponentName(PluginLoader.getApplicatoin().getPackageName(),
40+
newIntent.setComponent(new ComponentName(PluginLoader.getApplication().getPackageName(),
4141
PluginManagerHelper.bindStubReceiver()));
4242
//hackReceiverForClassLoader检测到这个标记后会进行替换
4343
newIntent.setAction(className + CLASS_SEPARATOR + (intent.getAction() == null ? "" : intent.getAction()));
@@ -115,7 +115,7 @@ public static void resolveActivity(Intent intent) {
115115
String stubActivityName = PluginManagerHelper.bindStubActivity(className, Integer.parseInt(pluginActivityInfo.getLaunchMode()));
116116

117117
intent.setComponent(
118-
new ComponentName(PluginLoader.getApplicatoin().getPackageName(), stubActivityName));
118+
new ComponentName(PluginLoader.getApplication().getPackageName(), stubActivityName));
119119
//PluginInstrumentationWrapper检测到这个标记后会进行替换
120120
intent.setAction(className + CLASS_SEPARATOR + (intent.getAction()==null?"":intent.getAction()));
121121
}

PluginCore/src/com/plugin/core/PluginLauncher.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public LoadedPlugin startPlugin(String packageName) {
7979
PluginDescriptor pluginDescriptor = PluginManagerHelper.getPluginDescriptorByPluginId(packageName);
8080

8181
Resources pluginRes = PluginCreator.createPluginResource(
82-
PluginLoader.getApplicatoin().getApplicationInfo().sourceDir,
83-
PluginLoader.getApplicatoin().getResources(), pluginDescriptor);
82+
PluginLoader.getApplication().getApplicationInfo().sourceDir,
83+
PluginLoader.getApplication().getResources(), pluginDescriptor);
8484

8585
DexClassLoader pluginClassLoader = PluginCreator.createPluginClassLoader(
8686
pluginDescriptor.getInstalledPath(),
@@ -90,7 +90,7 @@ public LoadedPlugin startPlugin(String packageName) {
9090

9191
Context pluginContext = PluginCreator.createPluginContext(
9292
pluginDescriptor,
93-
PluginLoader.getApplicatoin().getBaseContext(),
93+
PluginLoader.getApplication().getBaseContext(),
9494
pluginRes,
9595
pluginClassLoader);
9696

@@ -109,7 +109,7 @@ public LoadedPlugin startPlugin(String packageName) {
109109
plugin.pluginApplication = pluginApplication;//这里之所以不放在LoadedPlugin的构造器里面,是因为contentprovider在安装时loadclass,造成死循环
110110

111111
try {
112-
ActivityThread.installPackageInfo(PluginLoader.getApplicatoin(), packageName, pluginDescriptor,
112+
ActivityThread.installPackageInfo(PluginLoader.getApplication(), packageName, pluginDescriptor,
113113
pluginClassLoader, pluginRes, pluginApplication);
114114
} catch (ClassNotFoundException e) {
115115
e.printStackTrace();
@@ -146,7 +146,7 @@ private Application callPluginApplicationOnCreate(Context pluginContext, DexClas
146146
}
147147

148148
//安装ContentProvider, 在插件Application对象构造以后,oncreate调用之前
149-
PluginInjector.installContentProviders(PluginLoader.getApplicatoin(), pluginDescriptor.getProviderInfos().values());
149+
PluginInjector.installContentProviders(PluginLoader.getApplication(), pluginDescriptor.getProviderInfos().values());
150150

151151
//执行onCreate
152152
if (application != null) {
@@ -190,15 +190,15 @@ public void stopPlugin(String packageName, PluginDescriptor pluginDescriptor) {
190190
new Handler(Looper.getMainLooper()).post(new Runnable() {
191191
@Override
192192
public void run() {
193-
AndroidWebkitWebViewFactoryProvider.switchWebViewContext(PluginLoader.getApplicatoin());
193+
AndroidWebkitWebViewFactoryProvider.switchWebViewContext(PluginLoader.getApplication());
194194
}
195195
});
196196

197197
//退出LocalService
198198
LocalServiceManager.unRegistService(pluginDescriptor);
199199

200200
//退出Activity
201-
PluginLoader.getApplicatoin().sendBroadcast(new Intent(plugin.pluginPackageName + PluginActivityMonitor.ACTION_UN_INSTALL_PLUGIN));
201+
PluginLoader.getApplication().sendBroadcast(new Intent(plugin.pluginPackageName + PluginActivityMonitor.ACTION_UN_INSTALL_PLUGIN));
202202

203203
//退出BroadcastReceiver
204204
//广播一般有个注册方式
@@ -259,37 +259,37 @@ public boolean isRunning(String packageName) {
259259
static class LifecycleCallbackBrige implements android.app.Application.ActivityLifecycleCallbacks {
260260
@Override
261261
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
262-
AndroidAppApplication.dispatchActivityCreated(PluginLoader.getApplicatoin(), activity, savedInstanceState);
262+
AndroidAppApplication.dispatchActivityCreated(PluginLoader.getApplication(), activity, savedInstanceState);
263263
}
264264

265265
@Override
266266
public void onActivityStarted(Activity activity) {
267-
AndroidAppApplication.dispatchActivityStarted(PluginLoader.getApplicatoin(), activity);
267+
AndroidAppApplication.dispatchActivityStarted(PluginLoader.getApplication(), activity);
268268
}
269269

270270
@Override
271271
public void onActivityResumed(Activity activity) {
272-
AndroidAppApplication.dispatchActivityResumed(PluginLoader.getApplicatoin(), activity);
272+
AndroidAppApplication.dispatchActivityResumed(PluginLoader.getApplication(), activity);
273273
}
274274

275275
@Override
276276
public void onActivityPaused(Activity activity) {
277-
AndroidAppApplication.dispatchActivityPaused(PluginLoader.getApplicatoin(), activity);
277+
AndroidAppApplication.dispatchActivityPaused(PluginLoader.getApplication(), activity);
278278
}
279279

280280
@Override
281281
public void onActivityStopped(Activity activity) {
282-
AndroidAppApplication.dispatchActivityStopped(PluginLoader.getApplicatoin(), activity);
282+
AndroidAppApplication.dispatchActivityStopped(PluginLoader.getApplication(), activity);
283283
}
284284

285285
@Override
286286
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
287-
AndroidAppApplication.dispatchActivitySaveInstanceState(PluginLoader.getApplicatoin(), activity, outState);
287+
AndroidAppApplication.dispatchActivitySaveInstanceState(PluginLoader.getApplication(), activity, outState);
288288
}
289289

290290
@Override
291291
public void onActivityDestroyed(Activity activity) {
292-
AndroidAppApplication.dispatchActivityDestroyed(PluginLoader.getApplicatoin(), activity);
292+
AndroidAppApplication.dispatchActivityDestroyed(PluginLoader.getApplication(), activity);
293293
}
294294
}
295295
}

PluginCore/src/com/plugin/core/PluginLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class PluginLoader {
3737
private PluginLoader() {
3838
}
3939

40-
public static Application getApplicatoin() {
40+
public static Application getApplication() {
4141
return sApplication;
4242
}
4343

@@ -281,7 +281,7 @@ public static ArrayList<String> matchPlugin(Intent intent, int type) {
281281
if (packageName == null && intent.getComponent() != null) {
282282
packageName = intent.getComponent().getPackageName();
283283
}
284-
if (packageName != null && !packageName.equals(PluginLoader.getApplicatoin().getPackageName())) {
284+
if (packageName != null && !packageName.equals(PluginLoader.getApplication().getPackageName())) {
285285
PluginDescriptor dp = PluginManagerHelper.getPluginDescriptorByPluginId(packageName);
286286
if (dp != null) {
287287
List<String> list = dp.matchPlugin(intent, type);

PluginCore/src/com/plugin/core/PluginManifestParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static PluginDescriptor parseManifest(String pluginPath) {
6464
desciptor.setPackageName(packageName);
6565
desciptor.setVersion(versionName + "_" + versionCode);
6666

67-
desciptor.setStandalone(sharedUserId == null || !PluginLoader.getApplicatoin().getPackageName().equals(sharedUserId));
67+
desciptor.setStandalone(sharedUserId == null || !PluginLoader.getApplication().getPackageName().equals(sharedUserId));
6868

6969
LogUtil.d(packageName, versionCode, versionName, sharedUserId);
7070
} else if ("meta-data".equals(tag)) {

PluginCore/src/com/plugin/core/PluginResourceWrapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public String getResourcePackageName(int resid) throws NotFoundException {
3737
//就目前测试的情况来看,只有Coolpad、vivo、oppo等手机会在上面抛异常,走到这里来,
3838
//华为、三星、小米等手机不会到这里来。
3939
if (ResourceUtil.isMainResId(resid)) {
40-
return PluginLoader.getApplicatoin().getPackageName();
40+
return PluginLoader.getApplication().getPackageName();
4141
}
4242
throw new NotFoundException("Unable to find resource ID #0x"
4343
+ Integer.toHexString(resid));
@@ -54,7 +54,7 @@ public String getResourceName(int resid) throws NotFoundException {
5454
//就目前测试的情况来看,只有Coolpad、vivo、oppo等手机会在上面抛异常,走到这里来,
5555
//华为、三星、小米等手机不会到这里来。
5656
if (ResourceUtil.isMainResId(resid)) {
57-
return PluginLoader.getApplicatoin().getResources().getResourceName(resid);
57+
return PluginLoader.getApplication().getResources().getResourceName(resid);
5858
}
5959
throw new NotFoundException("Unable to find resource ID #0x"
6060
+ Integer.toHexString(resid));
@@ -80,7 +80,7 @@ public int getIdentifier(String name, String defType, String defPackage) {
8080
}
8181

8282
//传了packageName,而且不是宿主的packageName, 则直接返回
83-
if (!TextUtils.isEmpty(defPackage) && !PluginLoader.getApplicatoin().getPackageName().equals(defPackage)) {
83+
if (!TextUtils.isEmpty(defPackage) && !PluginLoader.getApplication().getPackageName().equals(defPackage)) {
8484
return super.getIdentifier(name, defType, defPackage);
8585
}
8686

@@ -114,7 +114,7 @@ public int getIdentifier(String name, String defType, String defPackage) {
114114
type = defType;
115115
}
116116

117-
if (PluginLoader.getApplicatoin().getPackageName().equals(packageName)) {
117+
if (PluginLoader.getApplication().getPackageName().equals(packageName)) {
118118
if (mPluginDescriptor.isStandalone()) {
119119
packageName = mPluginDescriptor.getPackageName();
120120
} else {

PluginCore/src/com/plugin/core/app/ActivityThread.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public synchronized static Object currentActivityThread() {
6363
//有些情况下上面的方法拿不到,下面再换个方法尝试一次
6464
if (sCurrentActivityThread == null) {
6565
Object impl = RefInvoker.invokeStaticMethod(android_app_ContextImpl, android_app_ContextImpl_getImpl,
66-
new Class[]{Context.class}, new Object[]{PluginLoader.getApplicatoin()});
66+
new Class[]{Context.class}, new Object[]{PluginLoader.getApplication()});
6767
if (impl != null) {
6868
sCurrentActivityThread = RefInvoker.getFieldObject(impl, android_app_ContextImpl, android_app_ContextImpl_mMainThread);
6969
}
@@ -202,8 +202,8 @@ public static void installPackageInfo(Context hostContext, String pluginId, Plug
202202
Class loadedAPKClass = pluginLoadedApk.getClass();
203203
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mApplication", pluginApplication);
204204
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mResources", pluginResource);
205-
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDirFile", new File(PluginLoader.getApplicatoin().getApplicationInfo().dataDir));
206-
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDir", PluginLoader.getApplicatoin().getApplicationInfo().dataDir);
205+
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDirFile", new File(PluginLoader.getApplication().getApplicationInfo().dataDir));
206+
RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mDataDir", PluginLoader.getApplication().getApplicationInfo().dataDir);
207207
//TODO 需要时再说
208208
//RefInvoker.setFieldObject(pluginLoadedApk, loadedAPKClass, "mLibDir", );
209209
}

PluginCore/src/com/plugin/core/manager/PluginCallbackImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ public void onPluginInstalled(String packageName, String version) {
2121
intent.putExtra("type", "install");
2222
intent.putExtra("id", packageName);
2323
intent.putExtra("version", version);
24-
PluginLoader.getApplicatoin().sendBroadcast(intent);
24+
PluginLoader.getApplication().sendBroadcast(intent);
2525
}
2626

2727
@Override
2828
public void onPluginRemoved(String packageName) {
2929
Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
3030
intent.putExtra("type", "remove");
3131
intent.putExtra("id", packageName);
32-
PluginLoader.getApplicatoin().sendBroadcast(intent);
32+
PluginLoader.getApplication().sendBroadcast(intent);
3333
}
3434

3535
@Override
3636
public void onPluginStarted(String packageName) {
3737
Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
3838
intent.putExtra("type", "init");
3939
intent.putExtra("id", packageName);
40-
PluginLoader.getApplicatoin().sendBroadcast(intent);
40+
PluginLoader.getApplication().sendBroadcast(intent);
4141
}
4242

4343
@Override
4444
public void onPluginRemoveAll() {
4545
Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
4646
intent.putExtra("type", "remove_all");
47-
PluginLoader.getApplicatoin().sendBroadcast(intent);
47+
PluginLoader.getApplication().sendBroadcast(intent);
4848
}
4949

5050
}

0 commit comments

Comments
 (0)