1 /* 2 * Copyright (C) 2024 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.brightness.domain.interactor 18 19 import com.android.settingslib.RestrictedLockUtils 20 import com.android.systemui.brightness.data.repository.BrightnessPolicyRepository 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.plugins.ActivityStarter 23 import com.android.systemui.utils.PolicyRestriction 24 import javax.inject.Inject 25 26 /** Interactor for enforcing the policy that may disallow brightness changing. */ 27 @SysUISingleton 28 class BrightnessPolicyEnforcementInteractor 29 @Inject 30 constructor( 31 brightnessPolicyRepository: BrightnessPolicyRepository, 32 private val activityStarter: ActivityStarter, 33 ) { 34 35 /** Brightness policy restriction for the current user. */ 36 val brightnessPolicyRestriction = brightnessPolicyRepository.restrictionPolicy 37 38 /** 39 * Starts the dialog with details about the current restriction for changing brightness. Should 40 * be triggered when a restricted user tries to change the brightness. 41 */ startAdminSupportDetailsDialognull42 fun startAdminSupportDetailsDialog(restriction: PolicyRestriction.Restricted) { 43 val intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent(restriction.admin) 44 activityStarter.postStartActivityDismissingKeyguard(intent, 0) 45 } 46 } 47