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.MedicalIdFiltersParcel; 28 import android.health.connect.aidl.IReadMedicalResourcesResponseCallback; 29 import android.health.connect.aidl.IActivityDatesResponseCallback; 30 import android.health.connect.aidl.IRecordTypeInfoResponseCallback; 31 import android.health.connect.aidl.ReadRecordsRequestParcel; 32 import android.health.connect.exportimport.IImportStatusCallback; 33 import android.health.connect.exportimport.IQueryDocumentProvidersCallback; 34 import android.health.connect.exportimport.IScheduledExportStatusCallback; 35 import android.health.connect.exportimport.ScheduledExportSettings; 36 import android.health.connect.migration.MigrationEntity; 37 import android.health.connect.restore.BackupFileNamesSet; 38 import android.health.connect.restore.StageRemoteDataRequest; 39 import android.net.Uri; 40 41 import android.os.UserHandle; 42 43 import java.util.List; 44 import java.util.Map; 45 46 /** 47 * Interface for {@link com.android.health.connect.HealthConnectManager} 48 * {@hide} 49 */ 50 interface IHealthConnectService { grantHealthPermission(String packageName, String permissionName, in UserHandle user)51 void grantHealthPermission(String packageName, String permissionName, in UserHandle user); revokeHealthPermission(String packageName, String permissionName, String reason, in UserHandle user)52 void revokeHealthPermission(String packageName, String permissionName, String reason, in UserHandle user); revokeAllHealthPermissions(String packageName, String reason, in UserHandle user)53 void revokeAllHealthPermissions(String packageName, String reason, in UserHandle user); getGrantedHealthPermissions(String packageName, in UserHandle user)54 List<String> getGrantedHealthPermissions(String packageName, in UserHandle user); 55 56 /** 57 * Returns a Map<String, Integer> from a permission name to permission flags. 58 * @hide 59 */ getHealthPermissionsFlags(String packageName, in UserHandle user, in List<String> permissions)60 Map getHealthPermissionsFlags(String packageName, in UserHandle user, in List<String> permissions); 61 62 /** 63 * @hide 64 */ setHealthPermissionsUserFixedFlagValue(String packageName, in UserHandle user, in List<String> permissions, boolean value)65 void setHealthPermissionsUserFixedFlagValue(String packageName, in UserHandle user, in List<String> permissions, boolean value); 66 67 /* @hide */ getHistoricalAccessStartDateInMilliseconds(String packageName, in UserHandle user)68 long getHistoricalAccessStartDateInMilliseconds(String packageName, in UserHandle user); 69 70 /** 71 * Inserts {@code records} into the HealthConnect database. 72 * 73 * @param attributionSource attribution source for the data. 74 * @param recordsParcel represents records to be inserted. 75 * @param callback Callback to receive result of performing this operation. 76 */ insertRecords( in AttributionSource attributionSource, in RecordsParcel recordsParcel, in IInsertRecordsResponseCallback callback)77 void insertRecords( 78 in AttributionSource attributionSource, 79 in RecordsParcel recordsParcel, 80 in IInsertRecordsResponseCallback callback); 81 82 /** 83 * Returns aggregation results based on the {@code request} into the HealthConnect database. 84 * 85 * @param attributionSource attribution source for the data. 86 * @param request represents the request using which the aggregation is to be performed. 87 * @param callback Callback to receive result of performing this operation. 88 */ aggregateRecords( in AttributionSource attributionSource, in AggregateDataRequestParcel request, in IAggregateRecordsResponseCallback callback)89 void aggregateRecords( 90 in AttributionSource attributionSource, 91 in AggregateDataRequestParcel request, 92 in IAggregateRecordsResponseCallback callback); 93 94 /** 95 * Reads from the HealthConnect database. 96 * 97 * @param attributionSource attribution source for the data. 98 * @param request represents the request to be read. 99 * @param callback Callback to receive result of performing this operation. 100 */ readRecords( in AttributionSource attributionSource, in ReadRecordsRequestParcel request, in IReadRecordsResponseCallback callback)101 void readRecords( 102 in AttributionSource attributionSource, 103 in ReadRecordsRequestParcel request, 104 in IReadRecordsResponseCallback callback); 105 106 /** 107 * Updates {@param records} in the HealthConnect database. 108 * 109 * @param attributionSource attribution source for the data. 110 * @param recordsParcel represents records to be updated. 111 * @param callback Callback to receive result of performing this operation. 112 */ updateRecords( in AttributionSource attributionSource, in RecordsParcel recordsParcel, in IEmptyResponseCallback callback)113 void updateRecords( 114 in AttributionSource attributionSource, 115 in RecordsParcel recordsParcel, 116 in IEmptyResponseCallback callback); 117 118 /** 119 * @param packageName calling package name 120 * @param request token request 121 * @return a token that can be used with {@code getChanges(token)} to fetch the upsert and 122 * delete changes corresponding to {@code request} 123 */ getChangeLogToken( in AttributionSource attributionSource, in ChangeLogTokenRequest request, in IGetChangeLogTokenCallback callback)124 void getChangeLogToken( 125 in AttributionSource attributionSource, 126 in ChangeLogTokenRequest request, 127 in IGetChangeLogTokenCallback callback); 128 129 /** 130 * @param attributionSource attribution source for the data. 131 * @param token request token from {@code getChangeLogToken} 132 */ getChangeLogs( in AttributionSource attributionSource, in ChangeLogsRequest token, in IChangeLogsResponseCallback callback)133 void getChangeLogs( 134 in AttributionSource attributionSource, 135 in ChangeLogsRequest token, 136 in IChangeLogsResponseCallback callback); 137 138 /** 139 * @param attributionSource attribution source for the data. 140 * @param request Delete request using the mentioned filters 141 * @param callback Callback to receive result of performing this operation 142 */ deleteUsingFilters( in AttributionSource attributionSource, in DeleteUsingFiltersRequestParcel request, in IEmptyResponseCallback callback)143 void deleteUsingFilters( 144 in AttributionSource attributionSource, 145 in DeleteUsingFiltersRequestParcel request, 146 in IEmptyResponseCallback callback); 147 148 /** 149 * @param attributionSource attribution source for the data. 150 * @param request Delete request using the mentioned filters 151 * @param callback Callback to receive result of performing this operation 152 */ deleteUsingFiltersForSelf( in AttributionSource attributionSource, in DeleteUsingFiltersRequestParcel request, in IEmptyResponseCallback callback)153 void deleteUsingFiltersForSelf( 154 in AttributionSource attributionSource, 155 in DeleteUsingFiltersRequestParcel request, 156 in IEmptyResponseCallback callback); 157 158 /** 159 * @param packageName Calling package's name 160 * @param permissionCategory PermissionCategory corresponding to which priority is requested 161 * @param callback Callback to receive result of performing this operation 162 */ getCurrentPriority( String packageName, int permissionCategory, in IGetPriorityResponseCallback callback)163 void getCurrentPriority( 164 String packageName, 165 int permissionCategory, 166 in IGetPriorityResponseCallback callback); 167 168 /** 169 * @param packageName Calling package's name 170 * @param request Delete request using the mentioned filters 171 * @param callback Callback to receive result of performing this operation 172 */ updatePriority( String packageName, in UpdatePriorityRequestParcel request, in IEmptyResponseCallback callback)173 void updatePriority( 174 String packageName, 175 in UpdatePriorityRequestParcel request, 176 in IEmptyResponseCallback callback); 177 178 /** Sets record rention period for HC DB */ setRecordRetentionPeriodInDays( int days, in UserHandle userHandle, in IEmptyResponseCallback callback)179 void setRecordRetentionPeriodInDays( 180 int days, 181 in UserHandle userHandle, 182 in IEmptyResponseCallback callback); 183 184 /** Gets record rention period for HC DB */ getRecordRetentionPeriodInDays(in UserHandle userHandle)185 int getRecordRetentionPeriodInDays(in UserHandle userHandle); 186 187 /** 188 * Returns information, represented by {@code ApplicationInfoResponse}, for all the 189 * packages that have contributed to the health connect DB. 190 * 191 * @param callback Callback to receive result of performing this operation. 192 */ getContributorApplicationsInfo(in IApplicationInfoResponseCallback callback)193 void getContributorApplicationsInfo(in IApplicationInfoResponseCallback callback); 194 195 /** Returns information for each RecordType like health permission category, record category and 196 * contributing packages. 197 * @param callback Callback to receive result of performing this operation. 198 */ queryAllRecordTypesInfo(in IRecordTypeInfoResponseCallback callback)199 void queryAllRecordTypesInfo(in IRecordTypeInfoResponseCallback callback); 200 201 /** 202 * @param packageName name of the package reading access logs 203 * @param callback Callback to receive result of performing this operation 204 */ queryAccessLogs( String packageName, in IAccessLogsResponseCallback callback)205 void queryAccessLogs( 206 String packageName, 207 in IAccessLogsResponseCallback callback); 208 209 /** 210 * Returns a list of unique dates for which at least one record type has at least one entry. 211 * 212 * @param recordTypes List of record types classes for which to get the activity dates. 213 * @param callback Callback to receive the result of performing this operation. 214 * {@hide} 215 */ getActivityDates( in ActivityDatesRequestParcel recordTypes, in IActivityDatesResponseCallback callback)216 void getActivityDates( 217 in ActivityDatesRequestParcel recordTypes, 218 in IActivityDatesResponseCallback callback); 219 220 /** 221 * Marks the start of the migration. 222 * 223 * @param packageName calling package name 224 * @param callback Callback to receive a result or an error encountered while performing this 225 * operation. 226 */ startMigration(String packageName, in IMigrationCallback callback)227 void startMigration(String packageName, in IMigrationCallback callback); 228 229 /** 230 * Marks the end of the migration. 231 * 232 * @param packageName calling package name 233 * @param callback Callback to receive a result or an error encountered while performing this 234 * operation. 235 */ finishMigration(String packageName, in IMigrationCallback callback)236 void finishMigration(String packageName, in IMigrationCallback callback); 237 238 /** 239 * Writes given entities to the module database. 240 * 241 * @param packageName calling package name 242 * @param entities List of {@link MigrationEntity} to migrate. 243 * @param callback Callback to receive a result or an error encountered while performing this 244 * operation. 245 */ writeMigrationData( String packageName, in MigrationEntityParcel parcel, in IMigrationCallback callback)246 void writeMigrationData( 247 String packageName, 248 in MigrationEntityParcel parcel, 249 in IMigrationCallback callback); 250 251 /** 252 * @param packageName calling package name 253 * @param callback Callback to receive a result or an error encountered while performing this 254 * operation. 255 */ insertMinDataMigrationSdkExtensionVersion( String packageName, int requiredSdkExtension, in IMigrationCallback callback)256 void insertMinDataMigrationSdkExtensionVersion( 257 String packageName, 258 int requiredSdkExtension, 259 in IMigrationCallback callback); 260 261 /** 262 * Stages all HealthConnect remote data and returns any errors in a callback. Errors encountered 263 * for all the files are shared in the provided callback. 264 * 265 * @param pfdsByFileName The map of file names and their {@link ParcelFileDescriptor}s. 266 * @param executor The {@link Executor} on which to invoke the callback. 267 * @param callback The callback which will receive the outcome of this call. 268 * @throws NullPointerException if null is passed for any of the required {@link NonNull} 269 * parameters. 270 * @hide 271 */ stageAllHealthConnectRemoteData(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle, in IDataStagingFinishedCallback callback)272 void stageAllHealthConnectRemoteData(in StageRemoteDataRequest stageRemoteDataRequest, 273 in UserHandle userHandle, in IDataStagingFinishedCallback callback); 274 275 /** 276 * Copies all HealthConnect backup data in the passed FDs. 277 * 278 * <p>The shared data should later be sent for cloud backup or to another device for backup. 279 * 280 * <p>We are responsible for closing the original file descriptors. The caller must not close 281 * the FD before that. 282 * 283 * @param pfdsByFileName The map of file names and their {@link ParcelFileDescriptor}s. 284 * @hide 285 */ getAllDataForBackup(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle)286 void getAllDataForBackup(in StageRemoteDataRequest stageRemoteDataRequest, in UserHandle userHandle); 287 288 /** 289 * Shares the names of all HealthConnect backup files 290 * 291 * @hide 292 */ getAllBackupFileNames(in boolean forDeviceToDevice)293 BackupFileNamesSet getAllBackupFileNames(in boolean forDeviceToDevice); 294 295 /** 296 * Deletes all previously staged HealthConnect data from the disk. 297 * For testing purposes only. 298 * 299 * @hide 300 */ deleteAllStagedRemoteData(in UserHandle userHandle)301 void deleteAllStagedRemoteData(in UserHandle userHandle); 302 303 /** 304 * Updates the download state of the Health Connect data. 305 * 306 * @param downloadState The download state which needs to be purely one of: 307 * {@link HealthConnectManager#CLOUD_DOWNLOAD_STARTED}, {@link 308 * HealthConnectManager#CLOUD_DOWNLOAD_RETRY}, {@link 309 * HealthConnectManager#CLOUD_DOWNLOAD_FAILED}, {@link 310 * HealthConnectManager#CLOUD_DOWNLOAD_COMPLETE} 311 * @hide 312 */ updateDataDownloadState(int downloadState)313 void updateDataDownloadState(int downloadState); 314 315 /** 316 * Asynchronously returns the current state of the Health Connect data as it goes through the Data-Restore and/or the Data-Migration process. 317 * 318 * <p>See also {@link HealthConnectDataState} object describing the HealthConnect state. 319 * 320 * @param callback The callback which will receive the current {@link HealthConnectDataState}. 321 * 322 * @hide 323 */ getHealthConnectDataState(in IGetHealthConnectDataStateCallback callback)324 void getHealthConnectDataState(in IGetHealthConnectDataStateCallback callback); 325 326 /** 327 * Asynchronously returns the current UI state of Health Connect as it goes through the Data-Migration process. 328 * 329 * <p>See also {@link HealthConnectMigrationUiState} object describing the HealthConnect UI state. 330 * 331 * @param callback The callback which will receive the current {@link HealthConnectMigrationUiState}. 332 * 333 * @hide 334 */ getHealthConnectMigrationUiState(in IGetHealthConnectMigrationUiStateCallback callback)335 void getHealthConnectMigrationUiState(in IGetHealthConnectMigrationUiStateCallback callback); 336 337 /** 338 * Configures the settings for the scheduled export of Health Connect data. 339 * 340 * @param settings Settings to use for the scheduled export. Use null to clear the settings. 341 * 342 * @hide 343 */ configureScheduledExport(in @ullable ScheduledExportSettings settings, in UserHandle userHandle)344 void configureScheduledExport(in @nullable ScheduledExportSettings settings, in UserHandle userHandle); 345 346 /** 347 * Gets the period in days between scheduled exports of Health Connect data. 348 * 349 * @hide 350 */ getScheduledExportPeriodInDays(in UserHandle userHandle)351 int getScheduledExportPeriodInDays(in UserHandle userHandle); 352 353 /** 354 * Queries the document providers available to be used for export/import. 355 * 356 * @hide 357 */ queryDocumentProviders(in UserHandle userHandle, in IQueryDocumentProvidersCallback callback)358 void queryDocumentProviders(in UserHandle userHandle, in IQueryDocumentProvidersCallback callback); 359 360 /** 361 * Gets the status of the currently scheduled export. 362 * 363 * @hide 364 */ getScheduledExportStatus(in UserHandle userHandle, in IScheduledExportStatusCallback callback)365 void getScheduledExportStatus(in UserHandle userHandle, in IScheduledExportStatusCallback callback); 366 367 /** 368 * Allows setting lower rate limits in tests. 369 * 370 * @hide 371 */ setLowerRateLimitsForTesting(in boolean enabled)372 void setLowerRateLimitsForTesting(in boolean enabled); 373 374 /** 375 * Gets the status of the ongoing data import. 376 * 377 * @hide 378 */ getImportStatus(in UserHandle userHandle, in IImportStatusCallback callback)379 void getImportStatus(in UserHandle userHandle, in IImportStatusCallback callback); 380 381 /** 382 * Imports the given compressed database file. 383 * 384 * @hide 385 */ runImport(in UserHandle userHandle, in Uri file)386 void runImport(in UserHandle userHandle, in Uri file); 387 388 /** 389 * Reads from the HealthConnect database. 390 * 391 * @param attributionSource attribution source for the data. 392 * @param medicalIdFiltersParcel represents the ids to be read. 393 * @param callback Callback to receive result of performing this operation. 394 */ readMedicalResources( in AttributionSource attributionSource, in MedicalIdFiltersParcel medicalIdFiltersParcel, in IReadMedicalResourcesResponseCallback callback)395 void readMedicalResources( 396 in AttributionSource attributionSource, 397 in MedicalIdFiltersParcel medicalIdFiltersParcel, 398 in IReadMedicalResourcesResponseCallback callback); 399 } 400