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 android.health.connect.migration; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 27 /** 28 * Represents the state of the Health Connect UI as Data Migration is happening. 29 * 30 * @hide 31 */ 32 public final class HealthConnectMigrationUiState implements Parcelable { 33 34 /** 35 * Starting UI state for the migration process. No UI messaging should happen. 36 * 37 * @hide 38 */ 39 public static final int MIGRATION_UI_STATE_IDLE = 0; 40 41 /** 42 * Migration ready to start. No UI messaging should happen. 43 * 44 * @hide 45 */ 46 public static final int MIGRATION_UI_STATE_ALLOWED_MIGRATOR_DISABLED = 1; 47 48 /** 49 * Migration ready to start but the migrator package became unresponsive to the broadcast. UI 50 * messaging: Integration Paused. 51 * 52 * @hide 53 */ 54 public static final int MIGRATION_UI_STATE_ALLOWED_NOT_STARTED = 2; 55 56 /** 57 * Migration was in progress but the migrator package becamse unresponsive to the broadcast, the 58 * IN_PROGRESS state timed out and the new state is ALLOWED. UI messaging: Integration Paused. 59 * 60 * @hide 61 */ 62 public static final int MIGRATION_UI_STATE_ALLOWED_PAUSED = 3; 63 64 /** 65 * Migration was in progress but the migrator package stopped handling the SHOW_MIGRATION_INFO 66 * intent. The IN_PROGRESS state timed out and the new state is ALLOWED. UI messaging: 67 * Integration Cancelled. 68 * 69 * @hide 70 */ 71 public static final int MIGRATION_UI_STATE_ALLOWED_ERROR = 4; 72 73 /** 74 * Migration is in progress. UI messaging: Integration in Progress. 75 * 76 * @hide 77 */ 78 public static final int MIGRATION_UI_STATE_IN_PROGRESS = 5; 79 80 /** 81 * Migration needs the migrator package to be upgraded. UI messaging: App upgrade needed. 82 * 83 * @hide 84 */ 85 public static final int MIGRATION_UI_STATE_APP_UPGRADE_REQUIRED = 6; 86 87 /** 88 * Migration needs the module to be upgraded. UI messaging: Module upgrade needed. 89 * 90 * @hide 91 */ 92 public static final int MIGRATION_UI_STATE_MODULE_UPGRADE_REQUIRED = 7; 93 94 /** 95 * Migration completed after startMigration() was called at least once. UI messaging: 96 * Integration complete. 97 * 98 * @hide 99 */ 100 public static final int MIGRATION_UI_STATE_COMPLETE = 8; 101 102 /** 103 * Migration completed from the IDLE state due to timeout. No UI messaging should happen. 104 * 105 * @hide 106 */ 107 public static final int MIGRATION_UI_STATE_COMPLETE_IDLE = 9; 108 109 /** 110 * An unknown migration UI state. 111 * 112 * @hide 113 */ 114 public static final int MIGRATION_UI_STATE_UNKNOWN = 10; 115 116 private final @Type int mMigrationUiState; 117 getHealthConnectMigrationUiState()118 public @Type int getHealthConnectMigrationUiState() { 119 return mMigrationUiState; 120 } 121 HealthConnectMigrationUiState(@ype int migrationUiState)122 public HealthConnectMigrationUiState(@Type int migrationUiState) { 123 this.mMigrationUiState = migrationUiState; 124 } 125 126 @Override describeContents()127 public int describeContents() { 128 return 0; 129 } 130 131 @Override writeToParcel(@onNull Parcel dest, int flags)132 public void writeToParcel(@NonNull Parcel dest, int flags) { 133 dest.writeInt(mMigrationUiState); 134 } 135 136 @NonNull 137 public static final Creator<HealthConnectMigrationUiState> CREATOR = 138 new Creator<>() { 139 @Override 140 public HealthConnectMigrationUiState createFromParcel(Parcel in) { 141 return new HealthConnectMigrationUiState(in); 142 } 143 144 @Override 145 public HealthConnectMigrationUiState[] newArray(int size) { 146 return new HealthConnectMigrationUiState[size]; 147 } 148 }; 149 HealthConnectMigrationUiState(Parcel in)150 private HealthConnectMigrationUiState(Parcel in) { 151 mMigrationUiState = in.readInt(); 152 } 153 154 /** @hide */ 155 @Retention(RetentionPolicy.SOURCE) 156 @IntDef({ 157 MIGRATION_UI_STATE_IDLE, 158 MIGRATION_UI_STATE_ALLOWED_MIGRATOR_DISABLED, 159 MIGRATION_UI_STATE_ALLOWED_NOT_STARTED, 160 MIGRATION_UI_STATE_ALLOWED_PAUSED, 161 MIGRATION_UI_STATE_ALLOWED_ERROR, 162 MIGRATION_UI_STATE_IN_PROGRESS, 163 MIGRATION_UI_STATE_APP_UPGRADE_REQUIRED, 164 MIGRATION_UI_STATE_MODULE_UPGRADE_REQUIRED, 165 MIGRATION_UI_STATE_COMPLETE, 166 MIGRATION_UI_STATE_COMPLETE_IDLE, 167 MIGRATION_UI_STATE_UNKNOWN 168 }) 169 public @interface Type {} 170 } 171