Remove some direct usage of getDevicePrefs()

Bug: 261635315
Test: Manually did testing on device.
Change-Id: I47c88bdc031d330f6efa573411ab5dbf154ec8a2
This commit is contained in:
Stefan Andonian
2023-10-06 18:59:19 +00:00
parent 9f34a29d0e
commit 2171d09fe6
4 changed files with 20 additions and 15 deletions

View File

@@ -15,8 +15,9 @@
*/
package com.android.launcher3.model;
import static com.android.launcher3.LauncherPrefs.nonRestorableItem;
import static com.android.launcher3.EncryptionType.ENCRYPTED;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
import static com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE;
import static com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER;
import android.app.prediction.AppTarget;
@@ -29,6 +30,7 @@ import android.os.UserHandle;
import androidx.annotation.NonNull;
import com.android.launcher3.ConstantItem;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
@@ -47,6 +49,9 @@ import java.util.stream.Collectors;
*/
public class PredictionUpdateTask extends BaseModelUpdateTask {
public static final ConstantItem<Boolean> LAST_PREDICTION_ENABLED =
nonRestorableItem("last_prediction_enabled_state", true, ENCRYPTED);
private final List<AppTarget> mTargets;
private final PredictorState mPredictorState;
@@ -61,8 +66,7 @@ public class PredictionUpdateTask extends BaseModelUpdateTask {
Context context = app.getContext();
// TODO: remove this
LauncherPrefs.getDevicePrefs(context).edit()
.putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
LauncherPrefs.get(context).put(LAST_PREDICTION_ENABLED, !mTargets.isEmpty());
Set<UserHandle> usersForChangedShortcuts =
dataModel.extraItems.get(mPredictorState.containerId).items.stream()