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 android.app.Activity; 20 import android.app.admin.DevicePolicyManager; 21 import android.content.Intent; 22 import android.os.Bundle; 23 24 import androidx.annotation.Nullable; 25 import androidx.fragment.app.Fragment; 26 27 import com.android.car.settings.common.BaseCarSettingsActivity; 28 29 /** 30 * Full screen wrapper activity for setting screen locks. Intended to be used by external intents 31 * to set up or change the user's screen lock (not used by settings itself). 32 */ 33 public class SettingsScreenLockActivity extends BaseCarSettingsActivity { 34 35 private static final int LOCK_CHECK = 14; 36 37 @Override 38 @Nullable getInitialFragment()39 protected Fragment getInitialFragment() { 40 return null; 41 } 42 43 @Override onCreate(@ullable Bundle savedInstanceState)44 protected void onCreate(@Nullable Bundle savedInstanceState) { 45 super.onCreate(savedInstanceState); 46 Intent intent = new Intent(this, VerifyLockChangeActivity.class); 47 startActivityForResult(intent, LOCK_CHECK); 48 } 49 50 @Override onActivityResult(int requestCode, int resultCode, Intent data)51 public void onActivityResult(int requestCode, int resultCode, Intent data) { 52 super.onActivityResult(requestCode, resultCode, data); 53 if (requestCode != LOCK_CHECK) { 54 return; 55 } 56 if (resultCode != Activity.RESULT_OK) { 57 finish(); 58 return; 59 } 60 Fragment fragment = new ChooseLockTypeFragment(); 61 Bundle bundle = fragment.getArguments(); 62 if (bundle == null) { 63 bundle = new Bundle(); 64 } 65 if (data != null) { 66 bundle.putParcelable(PasswordHelper.EXTRA_CURRENT_SCREEN_LOCK, 67 data.getParcelableExtra(PasswordHelper.EXTRA_CURRENT_SCREEN_LOCK)); 68 bundle.putInt(PasswordHelper.EXTRA_CURRENT_PASSWORD_QUALITY, 69 data.getIntExtra(PasswordHelper.EXTRA_CURRENT_PASSWORD_QUALITY, 70 DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED)); 71 } 72 fragment.setArguments(bundle); 73 launchFragment(fragment); 74 } 75 } 76