use of android.content.pm.ProviderInfo in project VirtualApp by asLody.
the class VClientImpl method bindApplicationNoCheck.
private void bindApplicationNoCheck(String packageName, String processName, ConditionVariable lock) {
mTempLock = lock;
try {
setupUncaughtHandler();
} catch (Throwable e) {
e.printStackTrace();
}
try {
fixInstalledProviders();
} catch (Throwable e) {
e.printStackTrace();
}
ActivityThread.mInitialApplication.set(VirtualCore.mainThread(), null);
AppBindData data = new AppBindData();
data.appInfo = VPackageManager.get().getApplicationInfo(packageName, 0, getUserId(vuid));
data.processName = processName;
data.providers = VPackageManager.get().queryContentProviders(processName, getVUid(), PackageManager.GET_META_DATA);
mBoundApplication = data;
VirtualRuntime.setupRuntime(data.processName, data.appInfo);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public synchronized void start() {
new Exception().printStackTrace();
super.start();
}
});
int targetSdkVersion = data.appInfo.targetSdkVersion;
if (targetSdkVersion < Build.VERSION_CODES.GINGERBREAD) {
StrictMode.ThreadPolicy newPolicy = new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy()).permitNetwork().build();
StrictMode.setThreadPolicy(newPolicy);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (mirror.android.os.StrictMode.sVmPolicyMask != null) {
mirror.android.os.StrictMode.sVmPolicyMask.set(0);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && targetSdkVersion < Build.VERSION_CODES.LOLLIPOP) {
mirror.android.os.Message.updateCheckRecycle.call(targetSdkVersion);
}
if (StubManifest.ENABLE_IO_REDIRECT) {
startIOUniformer();
}
NativeEngine.hookNative();
Object mainThread = VirtualCore.mainThread();
NativeEngine.startDexOverride();
Context context = createPackageContext(data.appInfo.packageName);
System.setProperty("java.io.tmpdir", context.getCacheDir().getAbsolutePath());
File codeCacheDir;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
codeCacheDir = context.getCodeCacheDir();
} else {
codeCacheDir = context.getCacheDir();
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
if (HardwareRenderer.setupDiskCache != null) {
HardwareRenderer.setupDiskCache.call(codeCacheDir);
}
} else {
if (ThreadedRenderer.setupDiskCache != null) {
ThreadedRenderer.setupDiskCache.call(codeCacheDir);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (RenderScriptCacheDir.setupDiskCache != null) {
RenderScriptCacheDir.setupDiskCache.call(codeCacheDir);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if (RenderScript.setupDiskCache != null) {
RenderScript.setupDiskCache.call(codeCacheDir);
}
}
Object boundApp = fixBoundApp(mBoundApplication);
mBoundApplication.info = ContextImpl.mPackageInfo.get(context);
mirror.android.app.ActivityThread.AppBindData.info.set(boundApp, data.info);
VMRuntime.setTargetSdkVersion.call(VMRuntime.getRuntime.call(), data.appInfo.targetSdkVersion);
boolean conflict = SpecialComponentList.isConflictingInstrumentation(packageName);
if (!conflict) {
PatchManager.getInstance().checkEnv(AppInstrumentation.class);
}
mInitialApplication = LoadedApk.makeApplication.call(data.info, false, null);
mirror.android.app.ActivityThread.mInitialApplication.set(mainThread, mInitialApplication);
ContextFixer.fixContext(mInitialApplication);
List<ProviderInfo> providers = VPackageManager.get().queryContentProviders(data.processName, vuid, PackageManager.GET_META_DATA);
if (providers != null) {
installContentProviders(mInitialApplication, providers);
}
if (lock != null) {
lock.open();
mTempLock = null;
}
try {
mInstrumentation.callApplicationOnCreate(mInitialApplication);
PatchManager.getInstance().checkEnv(HCallbackHook.class);
if (conflict) {
PatchManager.getInstance().checkEnv(AppInstrumentation.class);
}
Application createdApp = ActivityThread.mInitialApplication.get(mainThread);
if (createdApp != null) {
mInitialApplication = createdApp;
}
} catch (Exception e) {
if (!mInstrumentation.onException(mInitialApplication, e)) {
throw new RuntimeException("Unable to create application " + mInitialApplication.getClass().getName() + ": " + e.toString(), e);
}
}
VActivityManager.get().appDoneExecuting();
}
use of android.content.pm.ProviderInfo in project VirtualApp by asLody.
the class VClientImpl method fixInstalledProviders.
private void fixInstalledProviders() {
clearSettingProvider();
Map clientMap = ActivityThread.mProviderMap.get(VirtualCore.mainThread());
boolean highApi = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
for (Object clientRecord : clientMap.values()) {
if (highApi) {
IInterface provider = ActivityThread.ProviderClientRecordJB.mProvider.get(clientRecord);
Object holder = ActivityThread.ProviderClientRecordJB.mHolder.get(clientRecord);
ProviderInfo info = IActivityManager.ContentProviderHolder.info.get(holder);
if (holder != null && !info.authority.startsWith(StubManifest.STUB_CP_AUTHORITY)) {
provider = ProviderHook.createProxy(true, info.authority, provider);
ActivityThread.ProviderClientRecordJB.mProvider.set(clientRecord, provider);
IActivityManager.ContentProviderHolder.provider.set(holder, provider);
}
} else {
String authority = ActivityThread.ProviderClientRecord.mName.get(clientRecord);
IInterface provider = ActivityThread.ProviderClientRecord.mProvider.get(clientRecord);
if (provider != null && !authority.startsWith(StubManifest.STUB_CP_AUTHORITY)) {
provider = ProviderHook.createProxy(true, authority, provider);
ActivityThread.ProviderClientRecord.mProvider.set(clientRecord, provider);
}
}
}
}
use of android.content.pm.ProviderInfo in project VirtualApp by asLody.
the class PackageParserEx method generateProviderInfo.
public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags, PackageUserState state, int userId) {
if (p == null)
return null;
if (!checkUseInstalledOrHidden(state, flags)) {
return null;
}
if (!copyNeeded(flags, p.owner, p.metaData) && ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) != 0 || p.info.uriPermissionPatterns == null)) {
return p.info;
}
// Make shallow copies so we can store the metadata safely
ProviderInfo pi = new ProviderInfo(p.info);
pi.metaData = p.metaData;
if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
pi.uriPermissionPatterns = null;
}
pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
return pi;
}
use of android.content.pm.ProviderInfo in project ADWLauncher2 by boombuler.
the class Workspace method removeItems.
void removeItems(final ArrayList<ShortcutInfo> apps) {
final int count = getChildCount();
final PackageManager manager = getContext().getPackageManager();
final AppWidgetManager widgets = AppWidgetManager.getInstance(getContext());
final HashSet<String> packageNames = new HashSet<String>();
final int appCount = apps.size();
for (int i = 0; i < appCount; i++) {
final ComponentName component = apps.get(i).intent.getComponent();
if (component != null)
packageNames.add(component.getPackageName());
}
for (int i = 0; i < count; i++) {
final CellLayout layout = (CellLayout) getChildAt(i);
// Avoid ANRs by treating each screen separately
post(new Runnable() {
public void run() {
final ArrayList<View> childrenToRemove = new ArrayList<View>();
childrenToRemove.clear();
int childCount = layout.getChildCount();
for (int j = 0; j < childCount; j++) {
final View view = layout.getChildAt(j);
Object tag = view.getTag();
if (tag instanceof ShortcutInfo) {
final ShortcutInfo info = (ShortcutInfo) tag;
final Intent intent = info.intent;
final ComponentName name = intent.getComponent();
if (Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {
for (String packageName : packageNames) {
if (packageName.equals(name.getPackageName())) {
mLauncher.getModel().deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
}
}
} else if (tag instanceof UserFolderInfo) {
final UserFolderInfo info = (UserFolderInfo) tag;
final ArrayList<ShortcutInfo> contents = info.contents;
final ArrayList<ShortcutInfo> toRemove = new ArrayList<ShortcutInfo>(1);
final int contentsCount = contents.size();
boolean removedFromFolder = false;
for (int k = 0; k < contentsCount; k++) {
final ShortcutInfo appInfo = contents.get(k);
final Intent intent = appInfo.intent;
final ComponentName name = intent.getComponent();
if (Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {
for (String packageName : packageNames) {
if (packageName.equals(name.getPackageName())) {
toRemove.add(appInfo);
mLauncher.getModel().deleteItemFromDatabase(mLauncher, appInfo);
removedFromFolder = true;
}
}
}
}
contents.removeAll(toRemove);
if (removedFromFolder) {
final Folder folder = getOpenFolder();
if (folder != null)
folder.notifyDataSetChanged();
}
} else if (tag instanceof LiveFolderInfo) {
final LiveFolderInfo info = (LiveFolderInfo) tag;
final Uri uri = info.uri;
final ProviderInfo providerInfo = manager.resolveContentProvider(uri.getAuthority(), 0);
if (providerInfo != null) {
for (String packageName : packageNames) {
if (packageName.equals(providerInfo.packageName)) {
mLauncher.getModel().deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
}
}
} else if (tag instanceof LauncherAppWidgetInfo) {
final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
final AppWidgetProviderInfo provider = widgets.getAppWidgetInfo(info.appWidgetId);
if (provider != null) {
for (String packageName : packageNames) {
if (packageName.equals(provider.provider.getPackageName())) {
mLauncher.getModel().deleteItemFromDatabase(mLauncher, info);
childrenToRemove.add(view);
}
}
}
}
}
childCount = childrenToRemove.size();
for (int j = 0; j < childCount; j++) {
View child = childrenToRemove.get(j);
layout.removeViewInLayout(child);
if (child instanceof DropTarget) {
mDragController.removeDropTarget((DropTarget) child);
}
}
if (childCount > 0) {
layout.requestLayout();
layout.invalidate();
}
}
});
}
}
use of android.content.pm.ProviderInfo in project ADWLauncher2 by boombuler.
the class Launcher method getPackageNameFromIntent.
public String getPackageNameFromIntent(Intent intent) {
String pName = intent.getPackage();
if (pName == null) {
ComponentName cName = intent.getComponent();
if (cName != null)
pName = cName.getPackageName();
}
if (pName == null) {
PackageManager mgr = getPackageManager();
ResolveInfo res = mgr.resolveActivity(intent, 0);
if (res != null)
pName = res.activityInfo.packageName;
}
if (pName == null) {
Uri data = intent.getData();
if (data != null) {
String host = data.getHost();
PackageManager mgr = getPackageManager();
ProviderInfo packageInfo = mgr.resolveContentProvider(host, 0);
if (packageInfo != null)
pName = packageInfo.packageName;
}
}
return pName;
}
Aggregations