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

Commit 85241b11 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents 4cc510b9 e859a0c2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -243,6 +243,11 @@
    <!-- Settings intelligence interaction log intent action -->
    <string name="config_settingsintelligence_log_action" translatable="false"></string>

    <!-- Sound picker package name -->
    <string name="config_sound_picker_package_name" translatable="false">
        com.android.soundpicker
    </string>

    <!-- AOSP Emergency app package name -->
    <string name="config_aosp_emergency_package_name" translatable="false">
        com.android.emergency
+2 −1
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ public class RingtonePreference extends Preference {
                true);
        mShowSilent = a.getBoolean(com.android.internal.R.styleable.RingtonePreference_showSilent,
                true);
        setIntent(new Intent(RingtoneManager.ACTION_RINGTONE_PICKER));
        setIntent(new Intent(RingtoneManager.ACTION_RINGTONE_PICKER)
                .setPackage(context.getString(R.string.config_sound_picker_package_name)));
        setUserId(UserHandle.myUserId());
        a.recycle();
    }
+16 −0
Original line number Diff line number Diff line
@@ -115,6 +115,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;
@@ -1237,4 +1238,19 @@ public final class Utils extends com.android.settingslib.Utils {
        }
        return input;
    }

    /**
     * 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);
    }
}
+11 −15
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.hardware.usb.IUsbManager;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -172,24 +173,19 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
        if (activity == null) {
            return false;
        }
        String callingPackageName = null;
        try {
            callingPackageName = ActivityManager.getService()
                .getLaunchedFromPackage(activity.getActivityToken());
        } catch (Exception e) {
            return false;
        }
        if (TextUtils.isEmpty(callingPackageName)) {
            Log.w(TAG, "Not able to get calling package name for permission check");
            return false;
        }
        if (mPm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, callingPackageName)
                != PackageManager.PERMISSION_GRANTED) {
            Log.w(TAG, "Package " + callingPackageName + " does not have required permission "
            int callerUid = ActivityManager.getService().getLaunchedFromUid(
                    activity.getActivityToken());
            if (ActivityManager.checkUidPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                    callerUid) != PackageManager.PERMISSION_GRANTED) {
                Log.w(TAG, "Uid " + callerUid + " does not have required permission "
                        + Manifest.permission.INTERACT_ACROSS_USERS_FULL);
                return false;
            }
            return true;
        } catch (RemoteException e) {
            return false;
        }
    }

    protected void setIntentAndFinish(boolean appChanged) {
+47 −19
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.instrumentation.SettingsStatsLog;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wifi.dpp.WifiDppUtils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.applications.AppUtils;
@@ -249,12 +250,20 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
                    } else {
                        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));
@@ -303,13 +312,28 @@ 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)) {
            WifiDppUtils.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);
                    AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
                            PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER));
                });
                break;
            case ButtonActionDialogFragment.DialogType.SPECIAL_DISABLE:
                mMetricsFeatureProvider.action(mActivity,
@@ -317,7 +341,9 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
                uninstallPkg(mAppEntry.info.packageName, false, true);
                break;
            case ButtonActionDialogFragment.DialogType.FORCE_STOP:
                requireAuthAndExecute(() -> {
                    forceStopPackage(mAppEntry.info.packageName);
                });
                break;
        }
    }
@@ -547,6 +573,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp

    @VisibleForTesting
    void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
        requireAuthAndExecute(() -> {
            stopListeningToPackageRemove();
            // Create new intent to launch Uninstaller activity
            Uri packageUri = Uri.parse("package:" + packageName);
@@ -557,6 +584,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
                    mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP);
            mFragment.startActivityForResult(uninstallIntent, mRequestUninstall);
            mDisableAfterUninstall = andDisable;
        });
    }

    @VisibleForTesting
Loading