1 /* 2 * Copyright (C) 2023 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.privatespace.delete; 18 19 import android.content.Context; 20 import android.content.Intent; 21 22 import androidx.annotation.NonNull; 23 import androidx.preference.Preference; 24 25 import com.android.settings.core.BasePreferenceController; 26 27 /** Controller to delete the private space from the PS Settings page */ 28 public class DeletePrivateSpaceController extends BasePreferenceController { 29 private static final String TAG = "PrivateSpaceDeleteCtrl"; 30 DeletePrivateSpaceController(@onNull Context context, @NonNull String preferenceKey)31 public DeletePrivateSpaceController(@NonNull Context context, @NonNull String preferenceKey) { 32 super(context, preferenceKey); 33 } 34 35 @Override getAvailabilityStatus()36 public int getAvailabilityStatus() { 37 return android.os.Flags.allowPrivateProfile() 38 && android.multiuser.Flags.enablePrivateSpaceFeatures() 39 ? AVAILABLE 40 : UNSUPPORTED_ON_DEVICE; 41 } 42 43 @Override handlePreferenceTreeClick(@onNull Preference preference)44 public boolean handlePreferenceTreeClick(@NonNull Preference preference) { 45 if (mPreferenceKey.equals(preference.getKey())) { 46 startPrivateSpaceDeleteActivity(); 47 return true; 48 } 49 return false; 50 } 51 startPrivateSpaceDeleteActivity()52 private void startPrivateSpaceDeleteActivity() { 53 final Intent intent = new Intent(mContext, PrivateSpaceDeleteActivity.class); 54 mContext.startActivity(intent); 55 } 56 } 57