PackageManager keeps track of who installed what.

Stores the package name of the installer app in packages.xml
This commit is contained in:
Jacek Surazski
2009-04-28 15:26:38 +02:00
parent 21fa8d31f4
commit 65e13171e1
7 changed files with 181 additions and 25 deletions

View File

@@ -2326,14 +2326,25 @@ class ApplicationContext extends Context {
}
@Override
public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags) {
public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags,
String installerPackageName) {
try {
mPM.installPackage(packageURI, observer, flags);
mPM.installPackage(packageURI, observer, flags, installerPackageName);
} catch (RemoteException e) {
// Should never happen!
}
}
@Override
public String getInstallerPackageName(String packageName) {
try {
return mPM.getInstallerPackageName(packageName);
} catch (RemoteException e) {
// Should never happen!
}
return null;
}
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
try {

View File

@@ -140,8 +140,11 @@ interface IPackageManager {
* @param observer a callback to use to notify when the package installation in finished.
* @param flags - possible values: {@link #FORWARD_LOCK_PACKAGE},
* {@link #REPLACE_EXISITING_PACKAGE}
* @param installerPackageName Optional package name of the application that is performing the
* installation. This identifies which market the package came from.
*/
void installPackage(in Uri packageURI, IPackageInstallObserver observer, int flags);
void installPackage(in Uri packageURI, IPackageInstallObserver observer, int flags,
in String installerPackageName);
/**
* Delete a package.
@@ -152,6 +155,8 @@ interface IPackageManager {
*/
void deletePackage(in String packageName, IPackageDeleteObserver observer, int flags);
String getInstallerPackageName(in String packageName);
void addPackageToPreferred(String packageName);
void removePackageFromPreferred(String packageName);

View File

@@ -1354,8 +1354,35 @@ public abstract class PackageManager {
*
* @see #installPackage(android.net.Uri)
*/
public void installPackage(
Uri packageURI, IPackageInstallObserver observer, int flags) {
installPackage(packageURI, observer, flags, null);
}
/**
* Install a package. Since this may take a little while, the result will
* be posted back to the given observer. An installation will fail if the calling context
* lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
* package named in the package file's manifest is already installed, or if there's no space
* available on the device.
*
* @param packageURI The location of the package file to install. This can be a 'file:' or a
* 'content:' URI.
* @param observer An observer callback to get notified when the package installation is
* complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
* called when that happens. observer may be null to indicate that no callback is desired.
* @param flags - possible values: {@link #FORWARD_LOCK_PACKAGE},
* {@link #REPLACE_EXISTING_PACKAGE}
* @param installerPackageName Optional package name of the application that is performing the
* installation. This identifies which market the package came from.
*
* @see #installPackage(android.net.Uri)
*
* @hide
*/
public abstract void installPackage(
Uri packageURI, IPackageInstallObserver observer, int flags);
Uri packageURI, IPackageInstallObserver observer, int flags,
String installerPackageName);
/**
* Attempts to delete a package. Since this may take a little while, the result will
@@ -1374,6 +1401,15 @@ public abstract class PackageManager {
*/
public abstract void deletePackage(
String packageName, IPackageDeleteObserver observer, int flags);
/**
* Retrieve the package name of the application that installed a package. This identifies
* which market the package came from.
*
* @param packageName The name of the package to query
*/
public abstract String getInstallerPackageName(String packageName);
/**
* Attempts to clear the user data directory of an application.
* Since this may take a little while, the result will
@@ -1483,7 +1519,7 @@ public abstract class PackageManager {
*
* @param packageURI The location of the package file to install
*
* @see #installPackage(android.net.Uri, IPackageInstallObserver, int)
* @see #installPackage(android.net.Uri, IPackageInstallObserver, int, String)
*/
public void installPackage(Uri packageURI) {
installPackage(packageURI, null, 0);