use of android.os.IInterface in project VirtualApp by asLody.
the class GetContentProvider method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
int nameIdx = getProviderNameIndex();
String name = (String) args[nameIdx];
int userId = VUserHandle.myUserId();
ProviderInfo info = VPackageManager.get().resolveContentProvider(name, 0, userId);
if (info != null && info.enabled && isAppPkg(info.packageName)) {
int targetVPid = VActivityManager.get().initProcess(info.packageName, info.processName, userId);
if (targetVPid == -1) {
return null;
}
args[nameIdx] = StubManifest.getStubAuthority(targetVPid);
Object holder = method.invoke(who, args);
if (holder == null) {
return null;
}
IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
if (provider != null) {
provider = VActivityManager.get().acquireProviderClient(userId, info);
}
IActivityManager.ContentProviderHolder.provider.set(holder, provider);
IActivityManager.ContentProviderHolder.info.set(holder, info);
return holder;
}
Object holder = method.invoke(who, args);
if (holder != null) {
IInterface provider = IActivityManager.ContentProviderHolder.provider.get(holder);
info = IActivityManager.ContentProviderHolder.info.get(holder);
if (provider != null) {
provider = ProviderHook.createProxy(true, info.authority, provider);
}
IActivityManager.ContentProviderHolder.provider.set(holder, provider);
return holder;
}
return null;
}
use of android.os.IInterface in project VirtualApp by asLody.
the class GetIntentSender method call.
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
String creator = (String) args[1];
String[] resolvedTypes = (String[]) args[6];
int type = (int) args[0];
int flags = (int) args[7];
if ((PendingIntent.FLAG_UPDATE_CURRENT & flags) != 0) {
flags = (flags & ~(PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_NO_CREATE)) | PendingIntent.FLAG_CANCEL_CURRENT;
}
if (args[5] instanceof Intent[]) {
Intent[] intents = (Intent[]) args[5];
if (intents.length > 0) {
Intent intent = intents[intents.length - 1];
if (resolvedTypes != null && resolvedTypes.length > 0) {
intent.setDataAndType(intent.getData(), resolvedTypes[resolvedTypes.length - 1]);
}
Intent targetIntent = redirectIntentSender(type, creator, intent);
if (targetIntent != null) {
args[5] = new Intent[] { targetIntent };
}
}
}
args[7] = flags;
args[1] = getHostPkg();
IInterface sender = (IInterface) method.invoke(who, args);
if (sender != null && creator != null) {
VActivityManager.get().addPendingIntent(sender.asBinder(), creator);
}
return sender;
}
use of android.os.IInterface in project VirtualApp by asLody.
the class VClientImpl method acquireProviderClient.
@Override
public IBinder acquireProviderClient(ProviderInfo info) {
if (mTempLock != null) {
mTempLock.block();
}
if (!VClientImpl.get().isBound()) {
VClientImpl.get().bindApplication(info.packageName, info.processName);
}
IInterface provider = null;
String[] authorities = info.authority.split(";");
String authority = authorities.length == 0 ? info.authority : authorities[0];
ContentResolver resolver = VirtualCore.get().getContext().getContentResolver();
ContentProviderClient client = null;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
client = resolver.acquireUnstableContentProviderClient(authority);
} else {
client = resolver.acquireContentProviderClient(authority);
}
} catch (Throwable e) {
e.printStackTrace();
}
if (client != null) {
provider = mirror.android.content.ContentProviderClient.mContentProvider.get(client);
client.release();
}
return provider != null ? provider.asBinder() : null;
}
use of android.os.IInterface 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.os.IInterface in project VirtualApp by asLody.
the class VActivityManagerService method startServiceCommon.
private ComponentName startServiceCommon(Intent service, boolean scheduleServiceArgs, int userId) {
ServiceInfo serviceInfo = resolveServiceInfo(service, userId);
if (serviceInfo == null) {
return null;
}
ProcessRecord targetApp = startProcessIfNeedLocked(ComponentUtils.getProcessName(serviceInfo), userId, serviceInfo.packageName);
if (targetApp == null) {
VLog.e(TAG, "Unable to start new Process for : " + ComponentUtils.toComponentName(serviceInfo));
return null;
}
IInterface appThread = targetApp.appThread;
ServiceRecord r = findRecordLocked(userId, serviceInfo);
if (r == null) {
r = new ServiceRecord();
r.startId = 0;
r.activeSince = SystemClock.elapsedRealtime();
r.process = targetApp;
r.serviceInfo = serviceInfo;
try {
IApplicationThreadCompat.scheduleCreateService(appThread, r, r.serviceInfo, 0);
} catch (RemoteException e) {
e.printStackTrace();
}
addRecord(r);
}
r.lastActivityTime = SystemClock.uptimeMillis();
if (scheduleServiceArgs) {
r.startId++;
boolean taskRemoved = serviceInfo.applicationInfo != null && serviceInfo.applicationInfo.targetSdkVersion < Build.VERSION_CODES.ECLAIR;
try {
IApplicationThreadCompat.scheduleServiceArgs(appThread, r, taskRemoved, r.startId, 0, service);
} catch (RemoteException e) {
e.printStackTrace();
}
}
return ComponentUtils.toComponentName(serviceInfo);
}
Aggregations