1 /*
2  * Copyright (C) 2017 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.settings.development;
18 
19 import android.content.Context;
20 
21 import androidx.annotation.Nullable;
22 import androidx.preference.Preference;
23 
24 import com.android.settings.core.PreferenceControllerMixin;
25 import com.android.settingslib.core.lifecycle.Lifecycle;
26 import com.android.settingslib.development.AbstractLogpersistPreferenceController;
27 
28 public class LogPersistPreferenceController extends AbstractLogpersistPreferenceController
29         implements PreferenceControllerMixin {
30 
31     private final DevelopmentSettingsDashboardFragment mFragment;
32 
LogPersistPreferenceController(Context context, DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle)33     public LogPersistPreferenceController(Context context,
34             DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle) {
35         super(context, lifecycle);
36 
37         mFragment = fragment;
38     }
39 
40     @Override
showConfirmationDialog(@ullable Preference preference)41     public void showConfirmationDialog(@Nullable Preference preference) {
42         DisableLogPersistWarningDialog.show(mFragment);
43     }
44 
45     @Override
dismissConfirmationDialog()46     public void dismissConfirmationDialog() {
47         // intentional no-op
48     }
49 
50     @Override
isConfirmationDialogShowing()51     public boolean isConfirmationDialogShowing() {
52         return false;
53     }
54 
55     @Override
updateState(Preference preference)56     public void updateState(Preference preference) {
57         updateLogpersistValues();
58     }
59 
60     @Override
onDeveloperOptionsSwitchDisabled()61     protected void onDeveloperOptionsSwitchDisabled() {
62         super.onDeveloperOptionsSwitchDisabled();
63         writeLogpersistOption(null /* new value */, true);
64     }
65 
onDisableLogPersistDialogConfirmed()66     public void onDisableLogPersistDialogConfirmed() {
67         setLogpersistOff(true);
68         updateLogpersistValues();
69     }
70 
onDisableLogPersistDialogRejected()71     public void onDisableLogPersistDialogRejected() {
72         updateLogpersistValues();
73     }
74 }
75