1 /* 2 * Copyright (C) 2021 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.systemui.car.keyguard; 18 19 import android.app.ActivityManager; 20 import android.content.Context; 21 import android.util.AttributeSet; 22 import android.util.Log; 23 24 import com.android.internal.widget.LockPatternUtils; 25 import com.android.keyguard.KeyguardPatternView; 26 27 /** 28 * Car specific {@link KeyguardPatternView} to simply animations. 29 * 30 * TODO(b/204220809): Instead of extending {@KeyguardPatternView} separate shared logic into 31 * interface. 32 */ 33 public class CarKeyguardPatternView extends KeyguardPatternView { 34 35 private static final String TAG = "CarKeyguardPatternView"; 36 CarKeyguardPatternView(Context context)37 public CarKeyguardPatternView(Context context) { 38 super(context); 39 } 40 CarKeyguardPatternView(Context context, AttributeSet attrs)41 public CarKeyguardPatternView(Context context, AttributeSet attrs) { 42 super(context, attrs); 43 } 44 45 @Override onFinishInflate()46 protected void onFinishInflate() { 47 super.onFinishInflate(); 48 49 // TODO: Remove this code block when b/158386500 is addressed properly. 50 LockPatternUtils utils = new LockPatternUtils(getContext()); 51 int currentUser = ActivityManager.getCurrentUser(); 52 if (!utils.isVisiblePatternEnabled(currentUser)) { 53 utils.setVisiblePatternEnabled(true, currentUser); 54 Log.w(TAG, "Pattern is inivisble for the current user. Setting it to be visible."); 55 } 56 } 57 58 @Override startAppearAnimation()59 public void startAppearAnimation() { 60 setAlpha(1f); 61 } 62 } 63