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

Commit 7629a18a authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Revert "Expand install observer semantics"

This reverts commit ab8a501f.

Change-Id: I4ab4ae1a96efa2adf9d5a513793d8b84eef38b4e
parent ab8a501f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ LOCAL_SRC_FILES += \
	core/java/android/content/pm/IPackageDataObserver.aidl \
	core/java/android/content/pm/IPackageDeleteObserver.aidl \
	core/java/android/content/pm/IPackageInstallObserver.aidl \
	core/java/android/content/pm/IPackageInstallObserver2.aidl \
	core/java/android/content/pm/IPackageManager.aidl \
	core/java/android/content/pm/IPackageMoveObserver.aidl \
	core/java/android/content/pm/IPackageStatsObserver.aidl \
+7 −25
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import android.content.pm.ContainerEncryptionParams;
import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageInstallObserver2;
import android.content.pm.IPackageInstallObserver;
import android.content.pm.IPackageManager;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
@@ -39,7 +39,6 @@ import android.content.pm.VerificationParams;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.IUserManager;
import android.os.Process;
import android.os.RemoteException;
@@ -701,21 +700,14 @@ public final class Pm {
        ActivityManager.dumpPackageStateStatic(FileDescriptor.out, pkg);
    }

    class PackageInstallObserver extends IPackageInstallObserver2.Stub {
    class PackageInstallObserver extends IPackageInstallObserver.Stub {
        boolean finished;
        int result;
        String extraPermission;
        String extraPackage;

        @Override
        public void packageInstalled(String name, Bundle extras, int status) {
        public void packageInstalled(String name, int status) {
            synchronized( this) {
                finished = true;
                result = status;
                if (status == PackageManager.INSTALL_FAILED_DUPLICATE_PERMISSION) {
                    extraPermission = extras.getString(PackageManager.EXTRA_EXISTING_PERMISSION);
                    extraPackage = extras.getString(PackageManager.EXTRA_EXISTING_PACKAGE);
                }
                notifyAll();
            }
        }
@@ -725,8 +717,7 @@ public final class Pm {
     * Converts a failure code into a string by using reflection to find a matching constant
     * in PackageManager.
     */
    private String installFailureToString(PackageInstallObserver obs) {
        final int result = obs.result;
    private String installFailureToString(int result) {
        Field[] fields = PackageManager.class.getFields();
        for (Field f: fields) {
            if (f.getType() == int.class) {
@@ -741,16 +732,7 @@ public final class Pm {
                        // get the int value and compare it to result.
                        try {
                            if (result == f.getInt(null)) {
                                StringBuilder sb = new StringBuilder(64);
                                sb.append(fieldName);
                                if (obs.extraPermission != null) {
                                    sb.append(" perm=");
                                    sb.append(obs.extraPermission);
                                }
                                if (obs.extraPackage != null) {
                                    sb.append(" pkg=" + obs.extraPackage);
                                }
                                return sb.toString();
                                return fieldName;
                            }
                        } catch (IllegalAccessException e) {
                            // this shouldn't happen since we only look for public static fields.
@@ -974,7 +956,7 @@ public final class Pm {
            VerificationParams verificationParams = new VerificationParams(verificationURI,
                    originatingURI, referrerURI, VerificationParams.NO_UID, null);

            mPm.installPackageWithVerificationAndEncryptionEtc(apkURI, null, obs, installFlags,
            mPm.installPackageWithVerificationAndEncryption(apkURI, obs, installFlags,
                    installerPackageName, verificationParams, encryptionParams);

            synchronized (obs) {
@@ -988,7 +970,7 @@ public final class Pm {
                    System.out.println("Success");
                } else {
                    System.err.println("Failure ["
                            + installFailureToString(obs)
                            + installFailureToString(obs.result)
                            + "]");
                }
            }
+5 −44
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageInstallObserver;
import android.content.pm.IPackageInstallObserver2;
import android.content.pm.IPackageManager;
import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
@@ -1074,7 +1073,7 @@ final class ApplicationPackageManager extends PackageManager {
    public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags,
                               String installerPackageName) {
        try {
            mPM.installPackageEtc(packageURI, observer, null, flags, installerPackageName);
            mPM.installPackage(packageURI, observer, flags, installerPackageName);
        } catch (RemoteException e) {
            // Should never happen!
        }
@@ -1085,8 +1084,8 @@ final class ApplicationPackageManager extends PackageManager {
            int flags, String installerPackageName, Uri verificationURI,
            ManifestDigest manifestDigest, ContainerEncryptionParams encryptionParams) {
        try {
            mPM.installPackageWithVerificationEtc(packageURI, observer, null, flags,
                    installerPackageName, verificationURI, manifestDigest, encryptionParams);
            mPM.installPackageWithVerification(packageURI, observer, flags, installerPackageName,
                    verificationURI, manifestDigest, encryptionParams);
        } catch (RemoteException e) {
            // Should never happen!
        }
@@ -1097,46 +1096,8 @@ final class ApplicationPackageManager extends PackageManager {
            IPackageInstallObserver observer, int flags, String installerPackageName,
            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
        try {
            mPM.installPackageWithVerificationAndEncryptionEtc(packageURI, observer, null,
                    flags, installerPackageName, verificationParams, encryptionParams);
        } catch (RemoteException e) {
            // Should never happen!
        }
    }

    // Expanded observer-API versions
    @Override
    public void installPackage(Uri packageURI, PackageInstallObserver observer,
            int flags, String installerPackageName) {
        try {
            mPM.installPackageEtc(packageURI, null, observer.mObserver,
                    flags, installerPackageName);
        } catch (RemoteException e) {
            // Should never happen!
        }
    }

    @Override
    public void installPackageWithVerification(Uri packageURI,
            PackageInstallObserver observer, int flags, String installerPackageName,
            Uri verificationURI, ManifestDigest manifestDigest,
            ContainerEncryptionParams encryptionParams) {
        try {
            mPM.installPackageWithVerificationEtc(packageURI, null, observer.mObserver, flags,
                    installerPackageName, verificationURI, manifestDigest, encryptionParams);
        } catch (RemoteException e) {
            // Should never happen!
        }
    }

    @Override
    public void installPackageWithVerificationAndEncryption(Uri packageURI,
            PackageInstallObserver observer, int flags, String installerPackageName,
            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
        try {
            mPM.installPackageWithVerificationAndEncryptionEtc(packageURI, null,
                    observer.mObserver, flags, installerPackageName, verificationParams,
                    encryptionParams);
            mPM.installPackageWithVerificationAndEncryption(packageURI, observer, flags,
                    installerPackageName, verificationParams, encryptionParams);
        } catch (RemoteException e) {
            // Should never happen!
        }
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

import android.content.pm.IPackageInstallObserver2;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;

/**
 * @hide
 *
 * New-style observer for package installers to use.
 */
public class PackageInstallObserver {
    IPackageInstallObserver2.Stub mObserver = new IPackageInstallObserver2.Stub() {
        @Override
        public void packageInstalled(String pkgName, Bundle extras, int result)
                throws RemoteException {
            PackageInstallObserver.this.packageInstalled(pkgName, extras, result);
        }
    }; 

    /**
     * This method will be called to report the result of the package installation attempt.
     *
     * @param pkgName Name of the package whose installation was attempted
     * @param extras If non-null, this Bundle contains extras providing additional information
     *        about the install result
     * @param result The numeric success or failure code indicating the basic outcome
     */
    public void packageInstalled(String pkgName, Bundle extras, int result) {
    }
}
+0 −45
Original line number Diff line number Diff line
/*
**
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

package android.content.pm;

import android.os.Bundle;

/**
 * API for installation callbacks from the Package Manager.  In certain result cases
 * additional information will be provided.
 * @hide
 */
oneway interface IPackageInstallObserver2 {
    /**
     * The install operation has completed.  {@code returnCode} holds a numeric code
     * indicating success or failure.  In certain cases the {@code extras} Bundle will
     * contain additional details:
     *
     * <p><table>
     * <tr>
     *   <td>INSTALL_FAILED_DUPLICATE_PERMISSION</td>
     *   <td>Two strings are provided in the extras bundle: EXTRA_EXISTING_PERMISSION
     *       is the name of the permission that the app is attempting to define, and
     *       EXTRA_EXISTING_PACKAGE is the package name of the app which has already
     *       defined the permission.</td>
     * </tr>
     * </table> 
     */
    void packageInstalled(in String packageName, in Bundle extras, int returnCode);
}
Loading