android.content.pm.VersionedPackage Java Examples
The following examples show how to use
android.content.pm.VersionedPackage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #2
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #3
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #4
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #5
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { final int userId = getUserId(); try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, updateFlagsForPackage(flags, userId), userId); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #6
Source File: PackageManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private int uninstallSystemUpdates() { final PrintWriter pw = getOutPrintWriter(); List<String> failedUninstalls = new LinkedList<>(); try { final ParceledListSlice<ApplicationInfo> packages = mInterface.getInstalledApplications( PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM); final IPackageInstaller installer = mInterface.getPackageInstaller(); List<ApplicationInfo> list = packages.getList(); for (ApplicationInfo info : list) { if (info.isUpdatedSystemApp()) { pw.println("Uninstalling updates to " + info.packageName + "..."); final LocalIntentReceiver receiver = new LocalIntentReceiver(); installer.uninstall(new VersionedPackage(info.packageName, info.versionCode), null /*callerPackageName*/, 0 /* flags */, receiver.getIntentSender(), 0); final Intent result = receiver.getResult(); final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE); if (status != PackageInstaller.STATUS_SUCCESS) { failedUninstalls.add(info.packageName); } } } } catch (RemoteException e) { pw.println("Failure [" + e.getClass().getName() + " - " + e.getMessage() + "]"); return 0; } if (!failedUninstalls.isEmpty()) { pw.println("Failure [Couldn't uninstall packages: " + TextUtils.join(", ", failedUninstalls) + "]"); return 0; } pw.println("Success"); return 1; }
Example #7
Source File: ApplicationPackageManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { try { PackageInfo pi = mPM.getPackageInfoVersioned(versionedPackage, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(versionedPackage.toString()); }
Example #8
Source File: LoadedPlugin.java From VirtualAPK with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.O) @Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int i) throws NameNotFoundException { LoadedPlugin plugin = mPluginManager.getLoadedPlugin(versionedPackage.getPackageName()); if (null != plugin) { return plugin.mPackageInfo; } return this.mHostPackageManager.getPackageInfo(versionedPackage, i); }
Example #9
Source File: PackageManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private int runUninstall() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); int flags = 0; int userId = UserHandle.USER_ALL; long versionCode = PackageManager.VERSION_CODE_HIGHEST; String opt; while ((opt = getNextOption()) != null) { switch (opt) { case "-k": flags |= PackageManager.DELETE_KEEP_DATA; break; case "--user": userId = UserHandle.parseUserArg(getNextArgRequired()); break; case "--versionCode": versionCode = Long.parseLong(getNextArgRequired()); break; default: pw.println("Error: Unknown option: " + opt); return 1; } } final String packageName = getNextArg(); if (packageName == null) { pw.println("Error: package name not specified"); return 1; } // if a split is specified, just remove it and not the whole package final String splitName = getNextArg(); if (splitName != null) { return runRemoveSplit(packageName, splitName); } userId = translateUserId(userId, true /*allowAll*/, "runUninstall"); if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_SYSTEM; flags |= PackageManager.DELETE_ALL_USERS; } else { final PackageInfo info = mInterface.getPackageInfo(packageName, PackageManager.MATCH_STATIC_SHARED_LIBRARIES, userId); if (info == null) { pw.println("Failure [not installed for " + userId + "]"); return 1; } final boolean isSystem = (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; // If we are being asked to delete a system app for just one // user set flag so it disables rather than reverting to system // version of the app. if (isSystem) { flags |= PackageManager.DELETE_SYSTEM_APP; } } final LocalIntentReceiver receiver = new LocalIntentReceiver(); mInterface.getPackageInstaller().uninstall(new VersionedPackage(packageName, versionCode), null /*callerPackageName*/, flags, receiver.getIntentSender(), userId); final Intent result = receiver.getResult(); final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE); if (status == PackageInstaller.STATUS_SUCCESS) { pw.println("Success"); return 0; } else { pw.println("Failure [" + result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]"); return 1; } }
Example #10
Source File: PackageInstallerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void uninstall(VersionedPackage versionedPackage, String callerPackageName, int flags, IntentSender statusReceiver, int userId) throws RemoteException { final int callingUid = Binder.getCallingUid(); mPermissionManager.enforceCrossUserPermission(callingUid, userId, true, true, "uninstall"); if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) { mAppOps.checkPackage(callingUid, callerPackageName); } // Check whether the caller is device owner or affiliated profile owner, in which case we do // it silently. final int callingUserId = UserHandle.getUserId(callingUid); DevicePolicyManagerInternal dpmi = LocalServices.getService(DevicePolicyManagerInternal.class); final boolean isDeviceOwnerOrAffiliatedProfileOwner = dpmi != null && dpmi.isActiveAdminWithPolicy(callingUid, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER) && dpmi.isUserAffiliatedWithDevice(callingUserId); final PackageDeleteObserverAdapter adapter = new PackageDeleteObserverAdapter(mContext, statusReceiver, versionedPackage.getPackageName(), isDeviceOwnerOrAffiliatedProfileOwner, userId); if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DELETE_PACKAGES) == PackageManager.PERMISSION_GRANTED) { // Sweet, call straight through! mPm.deletePackageVersioned(versionedPackage, adapter.getBinder(), userId, flags); } else if (isDeviceOwnerOrAffiliatedProfileOwner) { // Allow the device owner and affiliated profile owner to silently delete packages // Need to clear the calling identity to get DELETE_PACKAGES permission long ident = Binder.clearCallingIdentity(); try { mPm.deletePackageVersioned(versionedPackage, adapter.getBinder(), userId, flags); } finally { Binder.restoreCallingIdentity(ident); } } else { ApplicationInfo appInfo = mPm.getApplicationInfo(callerPackageName, 0, userId); if (appInfo.targetSdkVersion >= Build.VERSION_CODES.P) { mContext.enforceCallingOrSelfPermission(Manifest.permission.REQUEST_DELETE_PACKAGES, null); } // Take a short detour to confirm with user final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.fromParts("package", versionedPackage.getPackageName(), null)); intent.putExtra(PackageInstaller.EXTRA_CALLBACK, adapter.getBinder().asBinder()); adapter.onUserActionRequired(intent); } }
Example #11
Source File: PackageManagerWrapper.java From v9porn with MIT License | 4 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int i) throws NameNotFoundException { return null; }
Example #12
Source File: PackageManagerWrapper.java From v9porn with MIT License | 4 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int i) throws NameNotFoundException { return null; }
Example #13
Source File: DelegateApplicationPackageManager.java From AndroidDownload with Apache License 2.0 | 4 votes |
@Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int i) throws NameNotFoundException { return null; }
Example #14
Source File: PackageManagerWrapper.java From condom with Apache License 2.0 | 4 votes |
@RequiresApi(O) @Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { return mBase.getPackageInfo(versionedPackage, flags); }
Example #15
Source File: PackageManagerWrapper.java From MiPushFramework with GNU General Public License v3.0 | 4 votes |
@RequiresApi(O) @Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { return mBase.getPackageInfo(versionedPackage, flags); }
Example #16
Source File: PackageManagerWrapper.java From island with Apache License 2.0 | 4 votes |
@RequiresApi(O) @Override public PackageInfo getPackageInfo(VersionedPackage versionedPackage, int flags) throws NameNotFoundException { return mBase.getPackageInfo(versionedPackage, flags); }