Search in sources :

Example 31 with ProviderInfo

use of android.content.pm.ProviderInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountSyncSettings method addSyncStateSwitch.

private void addSyncStateSwitch(Account account, String authority, String packageName, int uid) {
    SyncStateSwitchPreference item = (SyncStateSwitchPreference) getCachedPreference(authority);
    if (item == null) {
        item = new SyncStateSwitchPreference(getPrefContext(), account, authority, packageName, uid);
        getPreferenceScreen().addPreference(item);
    } else {
        item.setup(account, authority, packageName, uid);
    }
    item.setPersistent(false);
    final ProviderInfo providerInfo = getPackageManager().resolveContentProviderAsUser(authority, 0, mUserHandle.getIdentifier());
    if (providerInfo == null) {
        return;
    }
    CharSequence providerLabel = providerInfo.loadLabel(getPackageManager());
    if (TextUtils.isEmpty(providerLabel)) {
        Log.e(TAG, "Provider needs a label for authority '" + authority + "'");
        return;
    }
    String title = getString(R.string.sync_item_title, providerLabel);
    item.setTitle(title);
    item.setKey(authority);
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 32 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_frameworks_base by ResurrectionRemix.

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

Example 33 with ProviderInfo

use of android.content.pm.ProviderInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RunningServiceDetails method addProcessDetailsView.

void addProcessDetailsView(RunningState.ProcessItem pi, boolean isMain) {
    addProcessesHeader();
    ActiveDetail detail = new ActiveDetail();
    View root = mInflater.inflate(R.layout.running_service_details_process, mAllDetails, false);
    mAllDetails.addView(root);
    detail.mRootView = root;
    detail.mViewHolder = new RunningProcessesView.ViewHolder(root);
    detail.mActiveItem = detail.mViewHolder.bind(mState, pi, mBuilder);
    TextView description = (TextView) root.findViewById(R.id.comp_description);
    if (pi.mUserId != UserHandle.myUserId()) {
        // Processes for another user are all shown batched together; there is
        // no reason to have a description.
        description.setVisibility(View.GONE);
    } else if (isMain) {
        description.setText(R.string.main_running_process_description);
    } else {
        int textid = 0;
        CharSequence label = null;
        ActivityManager.RunningAppProcessInfo rpi = pi.mRunningProcessInfo;
        final ComponentName comp = rpi.importanceReasonComponent;
        //        + " pid=" + rpi.importanceReasonPid + " comp=" + comp);
        switch(rpi.importanceReasonCode) {
            case ActivityManager.RunningAppProcessInfo.REASON_PROVIDER_IN_USE:
                textid = R.string.process_provider_in_use_description;
                if (rpi.importanceReasonComponent != null) {
                    try {
                        ProviderInfo prov = getActivity().getPackageManager().getProviderInfo(rpi.importanceReasonComponent, 0);
                        label = RunningState.makeLabel(getActivity().getPackageManager(), prov.name, prov);
                    } catch (NameNotFoundException e) {
                    }
                }
                break;
            case ActivityManager.RunningAppProcessInfo.REASON_SERVICE_IN_USE:
                textid = R.string.process_service_in_use_description;
                if (rpi.importanceReasonComponent != null) {
                    try {
                        ServiceInfo serv = getActivity().getPackageManager().getServiceInfo(rpi.importanceReasonComponent, 0);
                        label = RunningState.makeLabel(getActivity().getPackageManager(), serv.name, serv);
                    } catch (NameNotFoundException e) {
                    }
                }
                break;
        }
        if (textid != 0 && label != null) {
            description.setText(getActivity().getString(textid, label));
        }
    }
    mActiveDetails.add(detail);
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) ProviderInfo(android.content.pm.ProviderInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) TextView(android.widget.TextView) ComponentName(android.content.ComponentName) View(android.view.View) TextView(android.widget.TextView)

Example 34 with ProviderInfo

use of android.content.pm.ProviderInfo in project cornerstone by Onskreen.

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 35 with ProviderInfo

use of android.content.pm.ProviderInfo in project DroidPlugin by DroidPluginTeam.

the class MyActivityManagerService method selectStubProviderInfo.

@Override
public ProviderInfo selectStubProviderInfo(int callingPid, int callingUid, ProviderInfo targetInfo) throws RemoteException {
    runProcessGC();
    //先从正在运行的进程中查找看是否有符合条件的进程,如果有则直接使用之
    String stubProcessName1 = mRunningProcessList.getStubProcessByTarget(targetInfo);
    if (stubProcessName1 != null) {
        List<ProviderInfo> stubInfos = mStaticProcessList.getProviderInfoForProcessName(stubProcessName1);
        for (ProviderInfo stubInfo : stubInfos) {
            if (!mRunningProcessList.isStubInfoUsed(stubInfo)) {
                mRunningProcessList.setTargetProcessName(stubInfo, targetInfo);
                return stubInfo;
            }
        }
    }
    List<String> stubProcessNames = mStaticProcessList.getProcessNames();
    for (String stubProcessName : stubProcessNames) {
        List<ProviderInfo> stubInfos = mStaticProcessList.getProviderInfoForProcessName(stubProcessName);
        if (mRunningProcessList.isProcessRunning(stubProcessName)) {
            if (mRunningProcessList.isPkgEmpty(stubProcessName)) {
                //空进程,没有运行任何插件包。
                for (ProviderInfo stubInfo : stubInfos) {
                    if (!mRunningProcessList.isStubInfoUsed(stubInfo)) {
                        mRunningProcessList.setTargetProcessName(stubInfo, targetInfo);
                        return stubInfo;
                    }
                }
                throw throwException("没有找到合适的StubInfo");
            } else if (mRunningProcessList.isPkgCanRunInProcess(targetInfo.packageName, stubProcessName, targetInfo.processName)) {
                for (ProviderInfo stubInfo : stubInfos) {
                    if (!mRunningProcessList.isStubInfoUsed(stubInfo)) {
                        mRunningProcessList.setTargetProcessName(stubInfo, targetInfo);
                        return stubInfo;
                    }
                }
                throw throwException("没有找到合适的StubInfo");
            } else {
            //需要处理签名一样的情况。
            }
        } else {
            for (ProviderInfo stubInfo : stubInfos) {
                if (!mRunningProcessList.isStubInfoUsed(stubInfo)) {
                    mRunningProcessList.setTargetProcessName(stubInfo, targetInfo);
                    return stubInfo;
                }
            }
            throw throwException("没有找到合适的StubInfo");
        }
    }
    throw throwException("没有可用的进程了");
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)114 RemoteException (android.os.RemoteException)36 ComponentName (android.content.ComponentName)27 PackageManager (android.content.pm.PackageManager)17 Point (android.graphics.Point)16 ArrayList (java.util.ArrayList)16 IPackageManager (android.content.pm.IPackageManager)12 ApplicationInfo (android.content.pm.ApplicationInfo)11 PackageInfo (android.content.pm.PackageInfo)10 Uri (android.net.Uri)9 PackageParser (android.content.pm.PackageParser)8 ResolveInfo (android.content.pm.ResolveInfo)8 IOException (java.io.IOException)8 ActivityInfo (android.content.pm.ActivityInfo)6 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)6 ServiceInfo (android.content.pm.ServiceInfo)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 Context (android.content.Context)5 VPackage (com.lody.virtual.server.pm.parser.VPackage)5 Map (java.util.Map)5