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

Commit 72c3120d authored by Joe Bolinger's avatar Joe Bolinger Committed by mse1969
Browse files

[BACKPORT] Ignore face settings extras when called by an external package.

Bug: 411418366
Flag: EXEMPT bug fix
Test: manual from any user not 0 (adb shell am start -a android.settings.FACE_SETTINGS --ei android.intent.extra.USER_ID 0)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:486947205e05e83314bd76e4822af442ca82be9c)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:387df9edf18fbfd42af166033c1532695f858c01)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:945e3401a4066f8a099c7499136b7ea2ba5f4009)
Merged-In: I06193e421a140a90568251fc25baa7fc81c12d78
Change-Id: I06193e421a140a90568251fc25baa7fc81c12d78
parent fe13a5d5
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.PasswordUtils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -145,10 +146,18 @@ public class FaceSettings extends DashboardFragment {

        mUserManager = context.getSystemService(UserManager.class);
        mFaceManager = context.getSystemService(FaceManager.class);

        final SettingsActivity activity = (SettingsActivity) requireActivity();
        final String callingPackage = PasswordUtils.getCallingAppPackageName(
                      getActivity().getActivityToken());
        if (callingPackage == null || !callingPackage.equals(activity.getPackageName())) {
            mUserId = UserHandle.myUserId();
        } else {
            // only allow these extras when called internally by Settings
            mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
            mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
        }

        mUserId = getActivity().getIntent().getIntExtra(
                Intent.EXTRA_USER_ID, UserHandle.myUserId());
        mFaceFeatureProvider = FeatureFactory.getFactory(getContext()).getFaceFeatureProvider();

        if (mUserManager.getUserInfo(mUserId).isManagedProfile()) {