1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.settings.security; 18 19 import com.android.internal.widget.LockPatternView; 20 21 import java.util.List; 22 23 /** 24 * An invisible retained worker fragment to track the AsyncWork that saves the chosen lock pattern. 25 */ 26 public class SavePatternWorker extends SaveLockWorkerBase { 27 28 private List<LockPatternView.Cell> mChosenPattern; 29 private String mCurrentPattern; 30 start(int userId, List<LockPatternView.Cell> chosenPattern, String currentPattern)31 void start(int userId, List<LockPatternView.Cell> chosenPattern, String currentPattern) { 32 init(userId); 33 mCurrentPattern = currentPattern; 34 mChosenPattern = chosenPattern; 35 start(); 36 } 37 38 @Override saveLock()39 void saveLock() { 40 int userId = getUserId(); 41 // If called after saveLockPattern, this will always be true 42 boolean isPatternEverChosen = getUtils().isPatternEverChosen(userId); 43 44 getUtils().saveLockPattern(mChosenPattern, mCurrentPattern, userId); 45 46 if (!isPatternEverChosen) { 47 getUtils().setVisiblePatternEnabled(true, userId); 48 } 49 } 50 } 51