1 package android.health.connect.aidl; 2 3 import android.content.AttributionSource; 4 import android.health.connect.aidl.ActivityDatesRequestParcel; 5 import android.health.connect.aidl.AggregateDataRequestParcel; 6 import android.health.connect.aidl.IAggregateRecordsResponseCallback; 7 import android.health.connect.changelog.ChangeLogTokenRequest; 8 import android.health.connect.changelog.ChangeLogsRequest; 9 import android.health.connect.aidl.DeleteUsingFiltersRequestParcel; 10 import android.health.connect.aidl.IAccessLogsResponseCallback; 11 import android.health.connect.aidl.IChangeLogsResponseCallback; 12 import android.health.connect.aidl.IDataStagingFinishedCallback; 13 import android.health.connect.aidl.IEmptyResponseCallback; 14 import android.health.connect.aidl.IGetChangeLogTokenCallback; 15 import android.health.connect.aidl.IGetPriorityResponseCallback; 16 import android.health.connect.aidl.IGetHealthConnectMigrationUiStateCallback; 17 import android.health.connect.aidl.IGetHealthConnectDataStateCallback; 18 import android.health.connect.aidl.RecordsParcel; 19 import android.health.connect.aidl.IMigrationCallback; 20 import android.health.connect.migration.MigrationEntityParcel; 21 import android.health.connect.aidl.IApplicationInfoResponseCallback; 22 import android.health.connect.aidl.IEmptyResponseCallback; 23 import android.health.connect.aidl.IInsertRecordsResponseCallback; 24 import android.health.connect.aidl.RecordsParcel; 25 import android.health.connect.aidl.UpdatePriorityRequestParcel; 26 import android.health.connect.aidl.IReadRecordsResponseCallback; 27 import android.health.connect.aidl.IActivityDatesResponseCallback; 28 import android.health.connect.aidl.IRecordTypeInfoResponseCallback; 29 import android.health.connect.aidl.ReadRecordsRequestParcel; 30 import android.health.connect.migration.MigrationEntity; 31 import android.health.connect.restore.BackupFileNamesSet; 32 import android.health.connect.restore.StageRemoteDataRequest; 33 34 import android.os.UserHandle; 35 36 import java.util.List; 37 38 /** 39 * Interface for {@link com.android.health.connect.HealthConnectManager} 40 * {@hide} 41 */ 42 interface IHealthConnectService { grantHealthPermission(String packageName, String permissionName, in UserHandle user)43 void grantHealthPermission(String packageName, String permissionName, in UserHandle user); revokeHealthPermission(String packageName, String permissionName, String reason, in UserHandle user)44 void revokeHealthPermission(String packageName, String permissionName, String reason, in UserHandle user); revokeAllHealthPermissions(String packageName, String reason, in UserHandle user)45 void revokeAllHealthPermissions(String packageName, String reason, in UserHandle user); getGrantedHealthPermissions(String packageName, in UserHandle user)46 List<String> getGrantedHealthPermissions(String packageName, in UserHandle user); 47 48 /* @hide */ getHistoricalAccessStartDateInMilliseconds(String packageName, in UserHandle user)49 long getHistoricalAccessStartDateInMilliseconds(String packageName, in UserHandle user); 50 51 /** 52 * Inserts {@code records} into the HealthConnect database. 53 * 54 * @param attributionSource attribution source for the data. 55 * @param recordsParcel represents records to be inserted. 56 * @param callback Callback to receive result of performing this operation. 57 */ insertRecords( in AttributionSource attributionSource, in RecordsParcel recordsParcel, in IInsertRecordsResponseCallback callback)58 void insertRecords( 59 in AttributionSource attributionSource, 60 in RecordsParcel recordsParcel, 61 in IInsertRecordsResponseCallback callback); 62 63 /** 64 * Returns aggregation results based on the {@code request} into the HealthConnect database. 65 * 66 * @param attributionSource attribution source for the data. 67 * @param request represents the request using which the aggregation is to be performed. 68 * @param callback Callback to receive result of performing this operation. 69 */ aggregateRecords( in AttributionSource attributionSource, in AggregateDataRequestParcel request, in IAggregateRecordsResponseCallback callback)70 void aggregateRecords( 71 in AttributionSource attributionSource, 72 in AggregateDataRequestParcel request, 73 in IAggregateRecordsResponseCallback callback); 74 75 /** 76 * Reads from the HealthConnect database. 77 * 78 * @param attributionSource attribution source for the data. 79 * @param request represents the request to be read. 80 * @param callback Callback to receive result of performing this operation. 81 */ readRecords( in AttributionSource attributionSource, in ReadRecordsRequestParcel request, in IReadRecordsResponseCallback callback)82 void readRecords( 83 in AttributionSource attributionSource, 84 in ReadRecordsRequestParcel request, 85 in IReadRecordsResponseCallback callback); 86 87 /** 88 * Updates {@param records} in the HealthConnect database. 89 * 90 * @param attributionSource attribution source for the data. 91 * @param recordsParcel represents records to be updated. 92 * @param callback Callback to receive result of performing this operation. 93 */ updateRecords( in AttributionSource attributionSource, in RecordsParcel recordsParcel, in IEmptyResponseCallback callback)94 void updateRecords( 95 in AttributionSource attributionSource, 96 in RecordsParcel recordsParcel, 97 in IEmptyResponseCallback callback); 98 99 /** 100 * @param packageName calling package name 101 * @param request token request 102 * @return a token that can be used with {@code getChanges(token)} to fetch the upsert and 103 * delete changes corresponding to {@code request} 104 */ getChangeLogToken( in AttributionSource attributionSource, in ChangeLogTokenRequest request, in IGetChangeLogTokenCallback callback)105 void getChangeLogToken( 106 in AttributionSource attributionSource, 107 in ChangeLogTokenRequest request, 108 in IGetChangeLogTokenCallback callback); 109 110 /** 111 * @param attributionSource attribution source for the data. 112 * @param token request token from {@code getChangeLogToken} 113 */ getChangeLogs( in AttributionSource attributionSource, in ChangeLogsRequest token, in IChangeLogsResponseCallback callback)114 void getChangeLogs( 115 in AttributionSource attributionSource, 116 in ChangeLogsRequest token, 117 in IChangeLogsResponseCallback callback); 118 119 /** 120 * @param attributionSource attribution source for the data. 121 * @param request Delete request using the mentioned filters 122 * @param callback Callback to receive result of performing this operation 123 */ deleteUsingFilters( in AttributionSource attributionSource, in DeleteUsingFiltersRequestParcel request, in IEmptyResponseCallback callback)124 void deleteUsingFilters( 125 in AttributionSource attributionSource, 126 in DeleteUsingFiltersRequestParcel request, 127 in IEmptyResponseCallback callback); 128 129 /** 130 * @param attributionSource attribution source for the data. 131 * @param request Delete request using the mentioned filters 132 * @param callback Callback to receive result of performing this operation 133 */ deleteUsingFiltersForSelf( in AttributionSource attributionSource, in DeleteUsingFiltersRequestParcel request, in IEmptyResponseCallback callback)134 void deleteUsingFiltersForSelf( 135 in AttributionSource attributionSource, 136 in DeleteUsingFiltersRequestParcel request, 137 in IEmptyResponseCallback callback); 138 139 /** 140 * @param packageName Calling package's name 141 * @param permissionCategory PermissionCategory corresponding to which priority is requested 142 * @param callback Callback to receive result of performing this operation 143 */ getCurrentPriority( String packageName, int permissionCategory, in IGetPriorityResponseCallback callback)144 void getCurrentPriority( 145 String packageName, 146 int permissionCategory, 147 in IGetPriorityResponseCallback callback); 148 149 /** 150 * @param packageName Calling package's name 151 * @param request Delete request using the mentioned filters 152 * @param callback Callback to receive result of performing this operation 153 */ updatePriority( String packageName, in UpdatePriorityRequestParcel request, in IEmptyResponseCallback callback)154 void updatePriority( 155 String packageName, 156 in UpdatePriorityRequestParcel request, 157 in IEmptyResponseCallback callback); 158 159 /** Sets record rention period for HC DB */ setRecordRetentionPeriodInDays( int days, in UserHandle userHandle, in IEmptyResponseCallback callback)160 void setRecordRetentionPeriodInDays( 161 int days, 162 in UserHandle userHandle, 163 in IEmptyResponseCallback callback); 164 165 /** Gets record rention period for HC DB */ getRecordRetentionPeriodInDays(in UserHandle userHandle)166 int getRecordRetentionPeriodInDays(in UserHandle userHandle); 167 168 /** 169 * Returns information, represented by {@code ApplicationInfoResponse}, for all the 170 * packages that have contributed to the health connect DB. 171 * 172 * @param callback Callback to receive result of performing this operation. 173 */ getContributorApplicationsInfo(in IApplicationInfoResponseCallback callback)174 void getContributorApplicationsInfo(in IApplicationInfoResponseCallback callback); 175 176 /** Returns information for each RecordType like health permission category, record category and 177 * contributing packages. 178 * @param callback Callback to receive result of performing this operation. 179 */ queryAllRecordTypesInfo(in IRecordTypeInfoResponseCallback callback)180 void queryAllRecordTypesInfo(in IRecordTypeInfoResponseCallback callback); 181 182 /** 183 * @param packageName name of the package reading access logs 184 * @param callback Callback to receive result of performing this operation 185 */ queryAccessLogs( String packageName, in IAccessLogsResponseCallback callback)186 void queryAccessLogs( 187 String packageName, 188 in IAccessLogsResponseCallback callback); 189 190 /** 191 * Returns a list of unique dates for which at least one record type has at least one entry. 192 * 193 * @param recordTypes List of record types classes for which to get the activity dates. 194 * @param callback Callback to receive the result of performing this operation. 195 * {@hide} 196 */ getActivityDates( in ActivityDatesRequestParcel recordTypes, in IActivityDatesResponseCallback callback)197 void getActivityDates( 198 in ActivityDatesRequestParcel recordTypes, 199 in IActivityDatesResponseCallback callback); 200 201 /** 202 * Marks the start of the migration. 203 * 204 * @param packageName calling package name 205 * @param callback Callback to receive a result or an error encountered while performing this 206 * operation. 207 */ startMigration(String packageName, in IMigrationCallback callback)208 void startMigration(String packageName, in IMigrationCallback callback); 209 210 /** 211 * Marks the end of the migration. 212 * 213 * @param packageName calling package name 214 * @param callback Callback to receive a result or an error encountered while performing this 215 * operation. 216 */ finishMigration(String packageName, in IMigrationCallback callback)217 void finishMigration(String packageName, in IMigrationCallback callback); 218 219 /** 220 * Writes given entities to the module database. 221 * 222 * @param packageName calling package name 223 * @param entities List of {@link MigrationEntity} to migrate. 224 * @param callback Callback to receive a result or an error encountered while performing this 225 * operation. 226 */ writeMigrationData( String packageName, in MigrationEntityParcel parcel, in IMigrationCallback callback)227 void writeMigrationData( 228 String packageName, 229 in MigrationEntityParcel parcel, 230 in IMigrationCallback callback); 231 232 /** 233 * @param packageName calling package name 234 * @param callback Callback to receive a result or an error encountered while performing this 235 * operation. 236 */ insertMinDataMigrationSdkExtensionVersion( String packageName, int requiredSdkExtension, in IMigrationCallback callback)237 void insertMinDataMigrationSdkExtensionVersion( 238 String packageName, 239 int requiredSdkExtension, 240 in IMigrationCallback callback); 241 242 /** 243 * Stages all HealthConnect remote data and returns any errors in a callback. Errors encountered 244 * for all the files are shared in the provided callback. 245 * 246 * @param pfdsByFileName The map of file names and their {@link ParcelFileDescriptor}s. 247 * @param executor The {@link Executor} on which to invoke the callback. 248 * @param callback The callback which will receive the outcome of this call. 249 * @throws NullPointerException if null is passed for any of the required {@link NonNull} 250 * parameters. 251 * @hide 252 */ stageAllHealthConnectRemoteData(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle, in IDataStagingFinishedCallback callback)253 void stageAllHealthConnectRemoteData(in StageRemoteDataRequest stageRemoteDataRequest, 254 in UserHandle userHandle, in IDataStagingFinishedCallback callback); 255 256 /** 257 * Copies all HealthConnect backup data in the passed FDs. 258 * 259 * <p>The shared data should later be sent for cloud backup or to another device for backup. 260 * 261 * <p>We are responsible for closing the original file descriptors. The caller must not close 262 * the FD before that. 263 * 264 * @param pfdsByFileName The map of file names and their {@link ParcelFileDescriptor}s. 265 * @hide 266 */ getAllDataForBackup(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle)267 void getAllDataForBackup(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle); 268 269 /** 270 * Shares the names of all HealthConnect backup files 271 * 272 * @hide 273 */ getAllBackupFileNames(in boolean forDeviceToDevice)274 BackupFileNamesSet getAllBackupFileNames(in boolean forDeviceToDevice); 275 276 /** 277 * Deletes all previously staged HealthConnect data from the disk. 278 * For testing purposes only. 279 * 280 * @hide 281 */ deleteAllStagedRemoteData(in UserHandle userHandle)282 void deleteAllStagedRemoteData(in UserHandle userHandle); 283 284 /** 285 * Updates the download state of the Health Connect data. 286 * 287 * @param downloadState The download state which needs to be purely one of: 288 * {@link HealthConnectManager#CLOUD_DOWNLOAD_STARTED}, {@link 289 * HealthConnectManager#CLOUD_DOWNLOAD_RETRY}, {@link 290 * HealthConnectManager#CLOUD_DOWNLOAD_FAILED}, {@link 291 * HealthConnectManager#CLOUD_DOWNLOAD_COMPLETE} 292 * @hide 293 */ updateDataDownloadState(int downloadState)294 void updateDataDownloadState(int downloadState); 295 296 /** 297 * Asynchronously returns the current state of the Health Connect data as it goes through the Data-Restore and/or the Data-Migration process. 298 * 299 * <p>See also {@link HealthConnectDataState} object describing the HealthConnect state. 300 * 301 * @param callback The callback which will receive the current {@link HealthConnectDataState}. 302 * 303 * @hide 304 */ getHealthConnectDataState(in IGetHealthConnectDataStateCallback callback)305 void getHealthConnectDataState(in IGetHealthConnectDataStateCallback callback); 306 307 /** 308 * Asynchronously returns the current UI state of Health Connect as it goes through the Data-Migration process. 309 * 310 * <p>See also {@link HealthConnectMigrationUiState} object describing the HealthConnect UI state. 311 * 312 * @param callback The callback which will receive the current {@link HealthConnectMigrationUiState}. 313 * 314 * @hide 315 */ getHealthConnectMigrationUiState(in IGetHealthConnectMigrationUiStateCallback callback)316 void getHealthConnectMigrationUiState(in IGetHealthConnectMigrationUiStateCallback callback); 317 } 318