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

Commit 19bfcdc8 authored by Steve Kondik's avatar Steve Kondik
Browse files

Revert "Revert "Block application install from unknown sources through adb""

This reverts commit 82b0dd81.

Change-Id: I4ba932d9e71157235721336040582f5280c0c131
parent c766741e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -575,6 +575,14 @@ public abstract class PackageManager {
     */
    public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;

    /**
     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
     * the package is from unknown sources but not trusted sources.
     * @hide
     */
    public static final int INSTALL_FAILED_UNKNOWN_SOURCES = -26;

    /**
     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
+12 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.Environment.UserEnvironment;
import android.os.UserManager;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.security.KeyStore;
import android.security.SystemKeyStore;
@@ -6770,6 +6771,17 @@ public class PackageManagerService extends IPackageManager.Stub {
            filteredFlags = flags & ~PackageManager.INSTALL_FROM_ADB;
        }

        // Check if unknown sources allowed
        if (android.app.AppOpsManager.isStrictEnable() &&
            ((filteredFlags & PackageManager.INSTALL_FROM_ADB) != 0) &&
            Global.getInt(mContext.getContentResolver(), Global.INSTALL_NON_MARKET_APPS, 0) <= 0) {
            try {
                observer.packageInstalled("", PackageManager.INSTALL_FAILED_UNKNOWN_SOURCES);
            } catch (RemoteException re) {
            }
            return;
        }

        verificationParams.setInstallerUid(uid);

        final Message msg = mHandler.obtainMessage(INIT_COPY);