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

Commit 1ebb665b authored by Tsung-Mao Fang's avatar Tsung-Mao Fang Committed by Presubmit Automerger Backend
Browse files

[automerge] FRP bypass defense in the settings app 2p: 71f2d836

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20640996

Bug: 258422561
Bug: 202975040
Change-Id: I33d8635f6695619b415285f67001135f695a880c
Merged-In: Ia18f367109df5af7da0a5acad7702898a459d32e
parents 3da973ce 71f2d836
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.settingslib.search.Indexable;
import com.android.settingslib.widget.LayoutPreference;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.setupcompat.util.WizardManagerHelper;

import java.util.UUID;

@@ -63,7 +64,7 @@ import java.util.UUID;
public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceFragment
        implements DialogCreatable, HelpResourceProvider, Indexable {

    private static final String TAG = "SettingsPreference";
    private static final String TAG = "SettingsPreferenceFragment";

    private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";

@@ -122,6 +123,15 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
    @VisibleForTesting
    public boolean mPreferenceHighlighted = false;

    @Override
    public void onAttach(Context context) {
        if (shouldSkipForInitialSUW() && !WizardManagerHelper.isDeviceProvisioned(getContext())) {
            Log.w(TAG, "Skip " + getClass().getSimpleName() + " before SUW completed.");
            finish();
        }
        super.onAttach(context);
    }

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
@@ -268,6 +278,16 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
                || (mAdapter.getPreferenceAdapterPosition(preference) != RecyclerView.NO_POSITION));
    }

    /**
     * Whether UI should be skipped in the initial SUW flow.
     *
     * @return {@code true} when UI should be skipped in the initial SUW flow.
     * {@code false} when UI should not be skipped in the initial SUW flow.
     */
    protected boolean shouldSkipForInitialSUW() {
        return false;
    }

    protected void onDataSetChanged() {
        highlightPreferenceIfNeeded();
        updateEmptyView();
+5 −0
Original line number Diff line number Diff line
@@ -84,6 +84,11 @@ public class AccountDashboardFragment extends DashboardFragment {
        return controllers;
    }

    @Override
    protected boolean shouldSkipForInitialSUW() {
        return true;
    }

    static void buildAutofillPreferenceControllers(
            Context context, List<AbstractPreferenceController> controllers) {
        controllers.add(new DefaultAutofillPreferenceController(context));
+5 −0
Original line number Diff line number Diff line
@@ -503,6 +503,11 @@ public class AppInfoDashboardFragment extends DashboardFragment
        return true;
    }

    @Override
    protected boolean shouldSkipForInitialSUW() {
        return true;
    }

    private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
        stopListeningToPackageRemove();
        // Create new intent to launch Uninstaller activity
+5 −0
Original line number Diff line number Diff line
@@ -215,6 +215,11 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        }
    }

    @Override
    protected boolean shouldSkipForInitialSUW() {
        return true;
    }

    /**
     * Long-pressing a developer options quick settings tile will by default (see
     * QS_TILE_PREFERENCES in the manifest) take you to the developer options page.
+5 −0
Original line number Diff line number Diff line
@@ -64,6 +64,11 @@ public class ResetDashboardFragment extends DashboardFragment {
        use(EraseEuiccDataController.class).setFragment(this);
    }

    @Override
    protected boolean shouldSkipForInitialSUW() {
        return true;
    }

    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
            Lifecycle lifecycle) {
        final List<AbstractPreferenceController> controllers = new ArrayList<>();
Loading