/* * Copyright (C) 2014 singwhatiwanna(任玉刚) <singwhatiwanna@gmail.com> * * collaborator:田啸,宋思宇,Mr.Simple * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ryg.dynamicload.internal; import android.content.pm.PackageInfo; import android.content.res.AssetManager; import android.content.res.Resources; import dalvik.system.DexClassLoader; /** * A plugin apk. Activities in a same apk share a same AssetManager, Resources * and DexClassLoader. * * @author siyu.song */ public class DLPluginPackage { public String packageName; public String defaultActivity; public DexClassLoader classLoader; public AssetManager assetManager; public Resources resources; public PackageInfo packageInfo; public DLPluginPackage(DexClassLoader loader, Resources resources, PackageInfo packageInfo) { this.packageName = packageInfo.packageName; this.classLoader = loader; this.assetManager = resources.getAssets(); this.resources = resources; this.packageInfo = packageInfo; defaultActivity = parseDefaultActivityName(); } private final String parseDefaultActivityName() { if (packageInfo.activities != null && packageInfo.activities.length > 0) { return packageInfo.activities[0].name; } return ""; } }