use of android.content.pm.ProviderInfo in project atlas by alibaba.
the class AtlasBundleInfoManager method findBundleByComponentName.
// private String getFromAssets(String fileName,Context context){
// BufferedReader bufReader = null;
// try {
// InputStreamReader inputReader = new InputStreamReader(context.getResources().getAssets().open(fileName), CHARSET);
// bufReader = new BufferedReader(inputReader);
// String line="";
// String result="";
// while((line = bufReader.readLine()) != null)
// result += line;
// return result;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// } finally {
// if(bufReader!=null){
// try {
// bufReader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
//
// private String getFromFile(String fileName){
// File file = new File(fileName);
// Long fileLength = file.length();
// byte[] filecontent = new byte[fileLength.intValue()];
// try {
// FileInputStream in = new FileInputStream(file);
// in.read(filecontent);
// in.close();
// return new String(filecontent,CHARSET);
// } catch (Throwable e) {
// e.printStackTrace();
// }
// return null;
// }
private String findBundleByComponentName(String componentClassName) {
getComponentInfoFromManifestIfNeed();
ComponentName componentName = new ComponentName(RuntimeVariables.androidApplication.getPackageName(), componentClassName);
if (activityInfos != null) {
ActivityInfo info = activityInfos.get(componentClassName);
if (info != null) {
if (info.metaData != null) {
return info.metaData.getString("bundleLocation");
} else {
try {
ActivityInfo detailInfo = RuntimeVariables.androidApplication.getPackageManager().getActivityInfo(componentName, PackageManager.GET_META_DATA);
if (detailInfo != null && detailInfo.metaData != null) {
info.metaData = detailInfo.metaData;
return detailInfo.metaData.getString("bundleLocation");
} else {
return null;
}
} catch (Throwable e) {
}
}
}
}
if (serviceInfos != null) {
ServiceInfo info = serviceInfos.get(componentClassName);
if (info != null) {
if (info.metaData != null) {
return info.metaData.getString("bundleLocation");
} else {
try {
ServiceInfo detailInfo = RuntimeVariables.androidApplication.getPackageManager().getServiceInfo(componentName, PackageManager.GET_META_DATA);
if (detailInfo != null && detailInfo.metaData != null) {
info = detailInfo;
return detailInfo.metaData.getString("bundleLocation");
} else {
return null;
}
} catch (Throwable e) {
}
}
}
}
if (receiverInfos != null) {
ActivityInfo info = receiverInfos.get(componentClassName);
if (info != null) {
if (info.metaData != null) {
return info.metaData.getString("bundleLocation");
} else {
try {
ActivityInfo detailInfo = RuntimeVariables.androidApplication.getPackageManager().getReceiverInfo(componentName, PackageManager.GET_META_DATA);
if (detailInfo != null && detailInfo.metaData != null) {
info.metaData = detailInfo.metaData;
return detailInfo.metaData.getString("bundleLocation");
} else {
return null;
}
} catch (Throwable e) {
}
}
}
}
if (providerInfos != null) {
ProviderInfo info = providerInfos.get(componentClassName);
if (info != null) {
if (info.metaData != null) {
return info.metaData.getString("bundleLocation");
} else {
try {
ProviderInfo detailInfo = RuntimeVariables.androidApplication.getPackageManager().getProviderInfo(componentName, PackageManager.GET_META_DATA);
if (detailInfo != null && detailInfo.metaData != null) {
info.metaData = detailInfo.metaData;
return detailInfo.metaData.getString("bundleLocation");
} else {
return null;
}
} catch (Throwable e) {
}
}
}
}
return null;
}
use of android.content.pm.ProviderInfo in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method revokeUriPermission.
public void revokeUriPermission(IApplicationThread caller, Uri uri, int modeFlags) {
enforceNotIsolatedCaller("revokeUriPermission");
synchronized (this) {
final ProcessRecord r = getRecordForAppLocked(caller);
if (r == null) {
throw new SecurityException("Unable to find app for caller " + caller + " when revoking permission to uri " + uri);
}
if (uri == null) {
Slog.w(TAG, "revokeUriPermission: null uri");
return;
}
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if (modeFlags == 0) {
return;
}
final IPackageManager pm = AppGlobals.getPackageManager();
final String authority = uri.getAuthority();
ProviderInfo pi = null;
ContentProviderRecord cpr = mProviderMap.getProviderByName(authority, r.userId);
if (cpr != null) {
pi = cpr.info;
} else {
try {
pi = pm.resolveContentProvider(authority, PackageManager.GET_URI_PERMISSION_PATTERNS, r.userId);
} catch (RemoteException ex) {
}
}
if (pi == null) {
Slog.w(TAG, "No content provider found for permission revoke: " + uri.toSafeString());
return;
}
revokeUriPermissionLocked(r.uid, uri, modeFlags);
}
}
use of android.content.pm.ProviderInfo in project android_frameworks_base by ParanoidAndroid.
the class PackageManagerService method querySyncProviders.
/**
* @deprecated
*/
@Deprecated
public void querySyncProviders(List<String> outNames, List<ProviderInfo> outInfo) {
// reader
synchronized (mPackages) {
final Iterator<Map.Entry<String, PackageParser.Provider>> i = mProviders.entrySet().iterator();
final int userId = UserHandle.getCallingUserId();
while (i.hasNext()) {
Map.Entry<String, PackageParser.Provider> entry = i.next();
PackageParser.Provider p = entry.getValue();
PackageSetting ps = mSettings.mPackages.get(p.owner.packageName);
if (ps != null && p.syncable && (!mSafeMode || (p.info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)) {
ProviderInfo info = PackageParser.generateProviderInfo(p, 0, ps.readUserState(userId), userId);
if (info != null) {
outNames.add(entry.getKey());
outInfo.add(info);
}
}
}
}
}
use of android.content.pm.ProviderInfo in project android_frameworks_base by ParanoidAndroid.
the class ActivityThread method installContentProviders.
private void installContentProviders(Context context, List<ProviderInfo> providers) {
final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>();
for (ProviderInfo cpi : providers) {
if (DEBUG_PROVIDER) {
StringBuilder buf = new StringBuilder(128);
buf.append("Pub ");
buf.append(cpi.authority);
buf.append(": ");
buf.append(cpi.name);
Log.i(TAG, buf.toString());
}
IActivityManager.ContentProviderHolder cph = installProvider(context, null, cpi, false, /*noisy*/
true, /*noReleaseNeeded*/
true);
if (cph != null) {
cph.noReleaseNeeded = true;
results.add(cph);
}
}
try {
ActivityManagerNative.getDefault().publishContentProviders(getApplicationThread(), results);
} catch (RemoteException ex) {
}
}
use of android.content.pm.ProviderInfo in project android_frameworks_base by ResurrectionRemix.
the class MetaDataTest method testProviderWithData.
@SmallTest
public void testProviderWithData() throws Exception {
ComponentName cn = new ComponentName(mContext, LocalProvider.class);
ProviderInfo pi = mContext.getPackageManager().resolveContentProvider("com.android.frameworks.coretests.LocalProvider", PackageManager.GET_META_DATA);
checkMetaData(cn, pi);
pi = mContext.getPackageManager().resolveContentProvider("com.android.frameworks.coretests.LocalProvider", 0);
assertNull("Meta data returned when not requested", pi.metaData);
}
Aggregations