Java 类android.content.pm.IPackageManager 实例源码

项目:IFWManager    文件:SenderPackageFilter.java   
@Override
public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
                       int callerUid, int callerPid, String resolvedType, int receivingUid) {
    IPackageManager pm = AppGlobals.getPackageManager();

    int packageUid = -1;
    try {
        // USER_SYSTEM here is not important. Only app id is used and getPackageUid() will
        // return a uid whether the app is installed for a user or not.
        packageUid = pm.getPackageUid(mPackageName, PackageManager.MATCH_UNINSTALLED_PACKAGES,
                UserHandle.USER_SYSTEM);
    } catch (RemoteException ex) {
        // handled below
    }

    if (packageUid == -1)  {
        return false;
    }

    return UserHandle.isSameApp(packageUid, callerUid);
}
项目:IFWManager    文件:SenderFilter.java   
static boolean isPrivilegedApp(int callerUid, int callerPid) {
    if (callerUid == Process.SYSTEM_UID || callerUid == 0 ||
            callerPid == Process.myPid() || callerPid == 0) {
        return true;
    }

    IPackageManager pm = AppGlobals.getPackageManager();
    try {
        return (pm.getPrivateFlagsForUid(callerUid) & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED)
                != 0;
    } catch (RemoteException ex) {
        Slog.e(IntentFirewall.TAG, "Remote exception while retrieving uid flags",
                ex);
    }

    return false;
}
项目:IFWManager    文件:IntentFirewall.java   
boolean signaturesMatch(int uid1, int uid2) {
    try {
        IPackageManager pm = AppGlobals.getPackageManager();
        return pm.checkUidSignatures(uid1, uid2) == PackageManager.SIGNATURE_MATCH;
    } catch (RemoteException ex) {
        Slog.e(TAG, "Remote exception while checking signatures", ex);
        return false;
    }
}
项目:SlienceInstall    文件:PM.java   
/**
 * 适配 5.0以下系统
 * 
 * @param path
 * @param iInstallerCallback
 * @throws Exception
 */
private void installPackageLowApi(String path, final IInstallerCallback iInstallerCallback) throws Exception {
    final Uri uri = Uri.parse(path);
    final int flags = PMFlags.INSTALL_REPLACE_EXISTING;
    final PackageInstallObserver observer = new PackageInstallObserver(iInstallerCallback);
    final IPackageManager ipm = getIPackageManager();
    RefInvoke.invokeMethodWithException(ipm.getClass(), "installPackage", ipm, new Class[] { Uri.class, IPackageInstallObserver.class, int.class, String.class }, new Object[] { uri, observer, flags, null });
}
项目:SlienceInstall    文件:PM.java   
/**
 * 适配 5.0以下系统
 * 
 * @param path
 * @param iInstallerCallback
 * @throws Exception
 */
private void installPackageLowApi(String path, final IInstallerCallback iInstallerCallback) throws Exception {
    final Uri uri = Uri.parse(path);
    final int flags = PMFlags.INSTALL_REPLACE_EXISTING;
    final PackageInstallObserver observer = new PackageInstallObserver(iInstallerCallback);
    final IPackageManager ipm = getIPackageManager();
    RefInvoke.invokeMethodWithException(ipm.getClass(), "installPackage", ipm, new Class[] { Uri.class, IPackageInstallObserver.class, int.class, String.class }, new Object[] { uri, observer, flags, null });
}
项目:droidel    文件:ActivityThread.java   
public static IPackageManager getPackageManager() {
    if (sPackageManager != null) {
        //Slog.v("PackageManager", "returning cur default = " + sPackageManager);
        return sPackageManager;
    }
    IBinder b = ServiceManager.getService("package");
    //Slog.v("PackageManager", "default service binder = " + b);
    sPackageManager = IPackageManager.Stub.asInterface(b);
    //Slog.v("PackageManager", "default service = " + sPackageManager);
    return sPackageManager;
}
项目:backup    文件:BackupManagerController.java   
public BackupManagerController() {
    backupManager = IBackupManager.Stub.asInterface(ServiceManager.getService("backup"));
    packageManager = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
}
项目:Brevent    文件:HideApiOverrideM.java   
public static List queryIntentReceivers(IPackageManager pm, Intent intent, int uid) {
    return pm.queryIntentReceivers(intent, null, 0, uid);
}
项目:Brevent    文件:HideApiOverrideM.java   
public static List queryIntentActivities(IPackageManager pm, Intent intent, int uid) {
    return pm.queryIntentActivities(intent, null, 0, uid);
}
项目:Brevent    文件:OpsItemAdapter.java   
private static IPackageManager getPackageManager() {
    return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
}
项目:prevent    文件:AppGlobals.java   
public static IPackageManager getPackageManager() {
    throw new UnsupportedOperationException();
}
项目:AppOpsX    文件:ActivityThread.java   
public static IPackageManager getPackageManager() {
  return null;
}
项目:SlienceInstall    文件:PM.java   
/**
 * 反射系统IPackageManager
 * 
 * @return
 */
private IPackageManager getIPackageManager() {
    IBinder iBinder = (IBinder) RefInvoke.invokeStaticMethod("android.os.ServiceManager", "getService", new Class[] { String.class }, new Object[] { "package" });
    IPackageManager ipm = IPackageManager.Stub.asInterface(iBinder);
    return ipm;
}
项目:SlienceInstall    文件:PM.java   
/**
 * 反射系统IPackageManager
 * 
 * @return
 */
private IPackageManager getIPackageManager() {
    IBinder iBinder = (IBinder) RefInvoke.invokeStaticMethod("android.os.ServiceManager", "getService", new Class[] { String.class }, new Object[] { "package" });
    IPackageManager ipm = IPackageManager.Stub.asInterface(iBinder);
    return ipm;
}