Search in sources :

Example 1 with ProviderInfo

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;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) ProviderInfo(android.content.pm.ProviderInfo) ComponentName(android.content.ComponentName)

Example 2 with ProviderInfo

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);
    }
}
Also used : IPackageManager(android.content.pm.IPackageManager) ProviderInfo(android.content.pm.ProviderInfo) RemoteException(android.os.RemoteException)

Example 3 with ProviderInfo

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);
                }
            }
        }
    }
}
Also used : ZipEntry(java.util.zip.ZipEntry) PackageParser(android.content.pm.PackageParser) ProviderInfo(android.content.pm.ProviderInfo) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with ProviderInfo

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) {
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException)

Example 5 with ProviderInfo

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);
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ComponentName(android.content.ComponentName) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)200 ComponentName (android.content.ComponentName)43 RemoteException (android.os.RemoteException)36 ArrayList (java.util.ArrayList)33 PackageManager (android.content.pm.PackageManager)27 ResolveInfo (android.content.pm.ResolveInfo)23 ApplicationInfo (android.content.pm.ApplicationInfo)22 ServiceInfo (android.content.pm.ServiceInfo)16 Point (android.graphics.Point)16 VPackage (com.lody.virtual.server.pm.parser.VPackage)15 PackageInfo (android.content.pm.PackageInfo)14 Map (java.util.Map)14 Test (org.junit.Test)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 Uri (android.net.Uri)13 File (java.io.File)13 IPackageManager (android.content.pm.IPackageManager)12 ActivityInfo (android.content.pm.ActivityInfo)10 Before (org.junit.Before)10 Intent (android.content.Intent)8