• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.car.settings.security;
18 
19 import android.content.Intent;
20 import android.os.Bundle;
21 
22 import androidx.annotation.Nullable;
23 import androidx.fragment.app.Fragment;
24 
25 import com.android.car.settings.common.BaseCarSettingsActivity;
26 
27 /**
28  * Abstract base activity class for lock choosing activities.
29  */
30 public abstract class ChooseLockBaseActivity extends BaseCarSettingsActivity {
31 
32     /**
33      * Lock type fragment specified here will have {@link PasswordHelper.EXTRA_CURRENT_SCREEN_LOCK}
34      * added as an argument and then opened as the initial fragment.
35      */
getChooseLockFragment()36     protected abstract Fragment getChooseLockFragment();
37 
38     @Nullable
39     @Override
getInitialFragment()40     protected Fragment getInitialFragment() {
41         Intent intent = getIntent();
42         Fragment fragment = getChooseLockFragment();
43         Bundle args = fragment.getArguments();
44         if (args == null) {
45             args = new Bundle();
46         }
47         args.putParcelable(PasswordHelper.EXTRA_CURRENT_SCREEN_LOCK,
48                 intent.getParcelableExtra(PasswordHelper.EXTRA_CURRENT_SCREEN_LOCK));
49         fragment.setArguments(args);
50         return fragment;
51     }
52 }
53