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 android.safetycenter; 18 19 import android.safetycenter.IOnSafetyCenterDataChangedListener; 20 import android.safetycenter.SafetyCenterData; 21 import android.safetycenter.SafetyEvent; 22 import android.safetycenter.SafetySourceData; 23 import android.safetycenter.SafetySourceErrorDetails; 24 import android.safetycenter.config.SafetyCenterConfig; 25 import java.util.List; 26 27 /** 28 * AIDL Interface for communicating with the Safety Center, which consolidates UI for security and 29 * privacy features on the device. 30 * 31 * These APIs are intended to be used by the following clients: 32 * <ul> 33 * <li>Safety sources represented in Safety Center UI 34 * <li>Dependents on the state of Safety Center UI 35 * <li>Managers of Safety Center UI 36 * </ul> 37 * 38 * @hide 39 */ 40 interface ISafetyCenterManager { 41 /** Returns whether the Safety Center feature is enabled. */ isSafetyCenterEnabled()42 boolean isSafetyCenterEnabled(); 43 44 /** 45 * Sets the latest SafetySourceData for the given safetySourceId and user to be displayed in 46 * SafetyCenter UI. 47 */ setSafetySourceData( String sourceId, in SafetySourceData safetySourceData, in SafetyEvent safetyEvent, String packageName, int userId)48 void setSafetySourceData( 49 String sourceId, 50 in SafetySourceData safetySourceData, 51 in SafetyEvent safetyEvent, 52 String packageName, 53 int userId); 54 55 /** Returns the latest SafetySourceData set for the given safetySourceId and user. */ getSafetySourceData( String safetySourceId, String packageName, int userId)56 SafetySourceData getSafetySourceData( 57 String safetySourceId, 58 String packageName, 59 int userId); 60 61 /** 62 * Notifies the SafetyCenter of an error related to a given safety source. 63 * 64 * <p>Safety sources should use this API to notify SafetyCenter when SafetyCenter requested or 65 * expected them to perform an action or provide data, but they were unable to do so. 66 */ reportSafetySourceError( String safetySourceId, in SafetySourceErrorDetails safetySourceErrorDetails, String packageName, int userId)67 void reportSafetySourceError( 68 String safetySourceId, 69 in SafetySourceErrorDetails safetySourceErrorDetails, 70 String packageName, 71 int userId); 72 73 /** Requests safety sources to set their latest SafetySourceData for Safety Center. */ refreshSafetySources(int refreshReason, int userId)74 void refreshSafetySources(int refreshReason, int userId); 75 76 /** 77 * Requests a specific subset of safety sources to set their latest SafetySourceData for 78 * Safety Center. 79 */ refreshSpecificSafetySources(int refreshReason, int userId, in List<String> safetySourceIds)80 void refreshSpecificSafetySources(int refreshReason, int userId, in List<String> safetySourceIds); 81 82 /** Returns the current SafetyCenterConfig, if available. */ getSafetyCenterConfig()83 SafetyCenterConfig getSafetyCenterConfig(); 84 85 /** 86 * Returns the current SafetyCenterData, assembled from the SafetySourceData from all sources. 87 */ getSafetyCenterData(String packageName, int userId)88 SafetyCenterData getSafetyCenterData(String packageName, int userId); 89 addOnSafetyCenterDataChangedListener( IOnSafetyCenterDataChangedListener listener, String packageName, int userId)90 void addOnSafetyCenterDataChangedListener( 91 IOnSafetyCenterDataChangedListener listener, 92 String packageName, 93 int userId); 94 removeOnSafetyCenterDataChangedListener( IOnSafetyCenterDataChangedListener listener, int userId)95 void removeOnSafetyCenterDataChangedListener( 96 IOnSafetyCenterDataChangedListener listener, 97 int userId); 98 99 /** 100 * Dismiss a Safety Center issue and prevent it affecting the overall safety status. 101 */ dismissSafetyCenterIssue(String issueId, int userId)102 void dismissSafetyCenterIssue(String issueId, int userId); 103 104 /** Executes the specified Safety Center issue action on the specified Safety Center issue. */ executeSafetyCenterIssueAction( String safetyCenterIssueId, String safetyCenterIssueActionId, int userId)105 void executeSafetyCenterIssueAction( 106 String safetyCenterIssueId, 107 String safetyCenterIssueActionId, 108 int userId); 109 110 /** 111 * Clears all SafetySourceData (set by safety sources using setSafetySourceData) for testing. 112 * 113 * <p>Note: This API serves to facilitate CTS testing and should not be used for other purposes. 114 */ clearAllSafetySourceDataForTests()115 void clearAllSafetySourceDataForTests(); 116 117 /** 118 * Overrides the SafetyCenterConfig for testing. 119 * 120 * <p>When set, the overridden SafetyCenterConfig will be used instead of the 121 * SafetyCenterConfig parsed from the XML file to read configured safety sources. 122 * 123 * <p>Note: This API serves to facilitate CTS testing and should not be used to configure safety 124 * sources dynamically for production. Once used for testing, the override should be cleared. 125 * 126 * See clearSafetyCenterConfigForTests. 127 */ setSafetyCenterConfigForTests(in SafetyCenterConfig safetyCenterConfig)128 void setSafetyCenterConfigForTests(in SafetyCenterConfig safetyCenterConfig); 129 130 /** 131 * Clears the override of the SafetyCenterConfig set for testing. 132 * 133 * <p>Note: This API serves to facilitate CTS testing and should not be used for other purposes. 134 * 135 * See setSafetyCenterConfigForTests(SafetyCenterConfig). 136 */ clearSafetyCenterConfigForTests()137 void clearSafetyCenterConfigForTests(); 138 }