Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 381d94b7 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Treat moving app as installing in new location.

Moving apps to/from SD cards has historically been neglected, meaning
it can easily break.  This happened most recently for split APKs,
64-bit native code, and multiArch support.

To make this easier to maintain, treat move as a no-op upgrade,
following the inheriting code path that split APKs depends on.

Also clean up scary places where different flavors of flags were
being combined, and remove unused flags.  Fix media broadcasts to be
sent based on existing app storage location.

New API to abandon install session without opening it.

Bug: 17158495
Change-Id: Ia33bf8f6fdaae099124dfe534f0e320b37bc8e16
parent 941a8ba1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8670,6 +8670,7 @@ package android.content.pm {
  }
  public class PackageInstaller {
    method public void abandonSession(int);
    method public void addSessionCallback(android.content.pm.PackageInstaller.SessionCallback);
    method public void addSessionCallback(android.content.pm.PackageInstaller.SessionCallback, android.os.Handler);
    method public int createSession(android.content.pm.PackageInstaller.SessionParams) throws java.io.IOException;
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.IntentSender;
/** {@hide} */
interface IPackageInstaller {
    int createSession(in PackageInstaller.SessionParams params, String installerPackageName, int userId);
    void abandonSession(int sessionId);

    IPackageInstallerSession openSession(int sessionId);

    PackageInstaller.SessionInfo getSessionInfo(int sessionId);
+8 −0
Original line number Diff line number Diff line
@@ -312,6 +312,14 @@ public class PackageInstaller {
        }
    }

    public void abandonSession(int sessionId) {
        try {
            mInstaller.abandonSession(sessionId);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /**
     * Return details for a specific session. To succeed, the caller must either
     * own this session, or be the current home app.
+14 −4
Original line number Diff line number Diff line
@@ -456,6 +456,8 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
            throw new SecurityException("User restriction prevents installing");
        }

        // TODO: double check all possible install flags

        if ((callingUid == Process.SHELL_UID) || (callingUid == Process.ROOT_UID)) {
            installerPackageName = "com.android.shell";

@@ -578,6 +580,17 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
        return sessionId;
    }

    @Override
    public void abandonSession(int sessionId) {
        synchronized (mSessions) {
            final PackageInstallerSession session = mSessions.get(sessionId);
            if (session == null || !isCallingUidOwner(session)) {
                throw new SecurityException("Caller has no access to session " + sessionId);
            }
            session.abandon();
        }
    }

    private void checkInternalStorage(long sizeBytes) throws IOException {
        if (sizeBytes <= 0) return;

@@ -606,10 +619,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
    public IPackageInstallerSession openSession(int sessionId) {
        synchronized (mSessions) {
            final PackageInstallerSession session = mSessions.get(sessionId);
            if (session == null) {
                throw new IllegalStateException("Missing session " + sessionId);
            }
            if (!isCallingUidOwner(session)) {
            if (session == null || !isCallingUidOwner(session)) {
                throw new SecurityException("Caller has no access to session " + sessionId);
            }
            session.open();
+232 −526

File changed.

Preview size limit exceeded, changes collapsed.