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

Commit 4d04fb67 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30686357',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30686357', 'googleplex-android-review.googlesource.com/31686511', 'googleplex-android-review.googlesource.com/31743864', 'googleplex-android-review.googlesource.com/31995154'] into security-aosp-24Q3-release.

Change-Id: I438f4f9ebec2d8bbae46c0d78f768ab3eddac62d
parents 2f92c177 9dc0dd2c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.ActionBarShadowController;
import com.android.settingslib.widget.AdaptiveIcon;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -1482,4 +1483,19 @@ public final class Utils extends com.android.settingslib.Utils {
        pm.setComponentEnabledSetting(componentName,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }

    /**
     * Returns {@code true} if the supplied package is a protected package. Otherwise, returns
     * {@code false}.
     *
     * @param context the context
     * @param packageName the package name
     */
    public static boolean isProtectedPackage(
            @NonNull Context context, @NonNull String packageName) {
        final List<String> protectedPackageNames = Arrays.asList(context.getResources()
                .getStringArray(com.android.internal.R.array
                        .config_biometric_protected_package_names));
        return protectedPackageNames != null && protectedPackageNames.contains(packageName);
    }
}
+46 −18
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.InstrumentedPreferenceFragment;
@@ -240,12 +241,20 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
            } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
                    showDialogInner(ButtonActionDialogFragment.DialogType.DISABLE);
                } else if (mAppEntry.info.enabled) {
                    requireAuthAndExecute(() -> {
                        mMetricsFeatureProvider.action(
                                mActivity,
                                SettingsEnums.ACTION_SETTINGS_DISABLE_APP,
                                getPackageNameForMetric());
                        AsyncTask.execute(new DisableChangerRunnable(mPm,
                                mAppEntry.info.packageName,
                                PackageManager.COMPONENT_ENABLED_STATE_DEFAULT));
                    });
                } else {
                    mMetricsFeatureProvider.action(
                            mActivity,
                            mAppEntry.info.enabled
                                    ? SettingsEnums.ACTION_SETTINGS_DISABLE_APP
                                    : SettingsEnums.ACTION_SETTINGS_ENABLE_APP,
                            SettingsEnums.ACTION_SETTINGS_ENABLE_APP,
                            getPackageNameForMetric());
                    AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
                            PackageManager.COMPONENT_ENABLED_STATE_DEFAULT));
@@ -289,17 +298,34 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
        }
    }

    /**
     * Runs the given action with restricted lock authentication if it is a protected package.
     *
     * @param action The action to run.
     */
    private void requireAuthAndExecute(Runnable action) {
        if (Utils.isProtectedPackage(mContext, mAppEntry.info.packageName)) {
            AppInfoDashboardFragment.showLockScreen(mContext, () -> action.run());
        } else {
            action.run();
        }
    }

    public void handleDialogClick(int id) {
        switch (id) {
            case ButtonActionDialogFragment.DialogType.DISABLE:
                requireAuthAndExecute(() -> {
                    mMetricsFeatureProvider.action(mActivity,
                            SettingsEnums.ACTION_SETTINGS_DISABLE_APP,
                            getPackageNameForMetric());
                    AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
                            PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER));
                });
                break;
            case ButtonActionDialogFragment.DialogType.FORCE_STOP:
                requireAuthAndExecute(() -> {
                    forceStopPackage(mAppEntry.info.packageName);
                });
                break;
        }
    }
@@ -535,6 +561,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp

    @VisibleForTesting
    void uninstallPkg(String packageName, boolean allUsers) {
        requireAuthAndExecute(() -> {
            stopListeningToPackageRemove();
            // Create new intent to launch Uninstaller activity
            Uri packageUri = Uri.parse("package:" + packageName);
@@ -543,6 +570,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp

            mMetricsFeatureProvider.action(mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP);
            mFragment.startActivityForResult(uninstallIntent, mRequestUninstall);
        });
    }

    @VisibleForTesting
+2 −2
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class NotificationAccessConfirmationActivity extends Activity
                NLSIntent, /* flags */ 0, mUserId);
        boolean hasNLSIntentFilter = false;
        for (ResolveInfo service : matchedServiceList) {
            if (service.serviceInfo.packageName.equals(mComponentName.getPackageName())) {
            if (service.serviceInfo.getComponentName().equals(mComponentName)) {
                if (!requiredPermission.equals(service.serviceInfo.permission)) {
                    Slog.e(LOG_TAG, "Service " + mComponentName + " lacks permission "
                            + requiredPermission);
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@@ -126,6 +127,14 @@ public class ContentProtectionTogglePreferenceController extends TogglePreferenc
                && mContentProtectionPolicy
                        != DevicePolicyManager.CONTENT_PROTECTION_NOT_CONTROLLED_BY_POLICY) {
            mSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
            return;
        }

        UserManager userManager = mContext.getSystemService(UserManager.class);
        if (userManager != null
                && userManager.isGuestUser()
                && mSwitchBar != null) {
            mSwitchBar.setEnabled(false);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class SpaAppBridgeActivity : Activity() {

    companion object {
        fun getDestinationForApp(destinationPrefix: String, intent: Intent): String? {
            val packageName = intent.data?.schemeSpecificPart ?: return null
            val packageName = intent.data?.schemeSpecificPart?.takeIf { Regex("^([a-zA-Z]\\w*\\.)*[a-zA-Z]\\w*$").matches(it) } ?: return null
            return "$destinationPrefix/$packageName/${UserHandle.myUserId()}"
        }
    }
Loading