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.datatypes; 18 19 import android.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.util.List; 24 import java.util.Set; 25 26 /** Identifier for exercise types, as returned by {@link ExerciseSegment#getSegmentType()}. */ 27 public final class ExerciseSegmentType { 28 29 /** Use this type if the type of the exercise segment is not known. */ 30 public static final int EXERCISE_SEGMENT_TYPE_UNKNOWN = 0; 31 32 /** Use this type for barbel shoulder press. */ 33 public static final int EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS = 1; 34 35 /** Use this type for bench sit up. */ 36 public static final int EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP = 2; 37 38 /** Use this type for biking. */ 39 public static final int EXERCISE_SEGMENT_TYPE_BIKING = 3; 40 41 /** Use this type for stationary biking. */ 42 public static final int EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY = 4; 43 44 /** Use this type for left arm dumbbell curl. */ 45 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM = 5; 46 47 /** Use this type for right arm dumbbell curl. */ 48 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM = 6; 49 50 /** Use this type for right arm dumbbell front raise. */ 51 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE = 7; 52 53 /** Use this type for dumbbell lateral raises. */ 54 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE = 8; 55 56 /** Use this type for left arm triceps extensions. */ 57 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM = 9; 58 59 /** Use this type for right arm triceps extensions. */ 60 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM = 10; 61 62 /** Use this type for two arms triceps extensions. */ 63 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM = 11; 64 65 /** Use this type for elliptical workout. */ 66 public static final int EXERCISE_SEGMENT_TYPE_ELLIPTICAL = 12; 67 68 /** Use this type for forward twists. */ 69 public static final int EXERCISE_SEGMENT_TYPE_FORWARD_TWIST = 13; 70 71 /** Use this type for pilates. */ 72 public static final int EXERCISE_SEGMENT_TYPE_PILATES = 14; 73 74 /** Use this type for rowing machine workout. */ 75 public static final int EXERCISE_SEGMENT_TYPE_ROWING_MACHINE = 15; 76 77 /** Use this type for running. */ 78 public static final int EXERCISE_SEGMENT_TYPE_RUNNING = 16; 79 80 /** Use this type for treadmill running. */ 81 public static final int EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL = 17; 82 83 /** Use this type for stair climbing. */ 84 public static final int EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING = 18; 85 86 /** Use this type for stair climbing machine. */ 87 public static final int EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE = 19; 88 89 /** Use this type for stretching. */ 90 public static final int EXERCISE_SEGMENT_TYPE_STRETCHING = 20; 91 92 /** Use this type for swimming in open water. */ 93 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER = 21; 94 95 /** Use this type for swimming in the pool. */ 96 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_POOL = 22; 97 98 /** Use this type for upper twists. */ 99 public static final int EXERCISE_SEGMENT_TYPE_UPPER_TWIST = 23; 100 101 /** Use this type for walking. */ 102 public static final int EXERCISE_SEGMENT_TYPE_WALKING = 24; 103 104 /** Use this type for wheelchair. */ 105 public static final int EXERCISE_SEGMENT_TYPE_WHEELCHAIR = 25; 106 107 /** Use this type for arm curls. */ 108 public static final int EXERCISE_SEGMENT_TYPE_ARM_CURL = 26; 109 110 /** Use this type for back extensions. */ 111 public static final int EXERCISE_SEGMENT_TYPE_BACK_EXTENSION = 27; 112 113 /** Use this type for ball slams. */ 114 public static final int EXERCISE_SEGMENT_TYPE_BALL_SLAM = 28; 115 116 /** Use this type for bench presses. */ 117 public static final int EXERCISE_SEGMENT_TYPE_BENCH_PRESS = 29; 118 119 /** Use this type for burpees. */ 120 public static final int EXERCISE_SEGMENT_TYPE_BURPEE = 30; 121 122 /** Use this type for crunches. */ 123 public static final int EXERCISE_SEGMENT_TYPE_CRUNCH = 31; 124 125 /** Use this type for deadlifts. */ 126 public static final int EXERCISE_SEGMENT_TYPE_DEADLIFT = 32; 127 128 /** Use this type for double arms triceps extensions. */ 129 public static final int EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION = 33; 130 131 /** Use this type for dumbbells rows. */ 132 public static final int EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW = 34; 133 134 /** Use this type for front raises. */ 135 public static final int EXERCISE_SEGMENT_TYPE_FRONT_RAISE = 35; 136 137 /** Use this type for hip thrusts. */ 138 public static final int EXERCISE_SEGMENT_TYPE_HIP_THRUST = 36; 139 140 /** Use this type for hula-hoops. */ 141 public static final int EXERCISE_SEGMENT_TYPE_HULA_HOOP = 37; 142 143 /** Use this type for jumping jacks. */ 144 public static final int EXERCISE_SEGMENT_TYPE_JUMPING_JACK = 38; 145 146 /** Use this type for jump rope. */ 147 public static final int EXERCISE_SEGMENT_TYPE_JUMP_ROPE = 39; 148 149 /** Use this type for kettlebell swings. */ 150 public static final int EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING = 40; 151 152 /** Use this type for lateral raises. */ 153 public static final int EXERCISE_SEGMENT_TYPE_LATERAL_RAISE = 41; 154 155 /** Use this type for lat pull-downs. */ 156 public static final int EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN = 42; 157 158 /** Use this type for leg curls. */ 159 public static final int EXERCISE_SEGMENT_TYPE_LEG_CURL = 43; 160 161 /** Use this type for leg extensions. */ 162 public static final int EXERCISE_SEGMENT_TYPE_LEG_EXTENSION = 44; 163 164 /** Use this type for leg presses. */ 165 public static final int EXERCISE_SEGMENT_TYPE_LEG_PRESS = 45; 166 167 /** Use this type for leg raises. */ 168 public static final int EXERCISE_SEGMENT_TYPE_LEG_RAISE = 46; 169 170 /** Use this type for lunges. */ 171 public static final int EXERCISE_SEGMENT_TYPE_LUNGE = 47; 172 173 /** Use this type for mountain climber. */ 174 public static final int EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER = 48; 175 176 /** Use this type for plank. */ 177 public static final int EXERCISE_SEGMENT_TYPE_PLANK = 49; 178 179 /** Use this type for pull-ups. */ 180 public static final int EXERCISE_SEGMENT_TYPE_PULL_UP = 50; 181 182 /** Use this type for punches. */ 183 public static final int EXERCISE_SEGMENT_TYPE_PUNCH = 51; 184 185 /** Use this type for shoulder press. */ 186 public static final int EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS = 52; 187 188 /** Use this type for single arm triceps extension. */ 189 public static final int EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION = 53; 190 191 /** Use this type for sit-ups. */ 192 public static final int EXERCISE_SEGMENT_TYPE_SIT_UP = 54; 193 194 /** Use this type for squats. */ 195 public static final int EXERCISE_SEGMENT_TYPE_SQUAT = 55; 196 197 /** Use this type for freestyle swimming. */ 198 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE = 56; 199 200 /** Use this type for backstroke swimming. */ 201 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE = 57; 202 203 /** Use this type for breaststroke swimming. */ 204 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE = 58; 205 206 /** Use this type for butterfly swimming. */ 207 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY = 59; 208 209 /** Use this type for mixed swimming. */ 210 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED = 60; 211 212 /** Use this type if other swimming styles are not suitable. */ 213 public static final int EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER = 61; 214 215 /** Use this type for high intensity training. */ 216 public static final int EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING = 62; 217 218 /** Use this type for weightlifting. */ 219 public static final int EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING = 63; 220 221 /** Use this type for other workout. */ 222 public static final int EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT = 64; 223 224 /** Use this type for yoga. */ 225 public static final int EXERCISE_SEGMENT_TYPE_YOGA = 65; 226 227 /** Use this type for the rest. */ 228 public static final int EXERCISE_SEGMENT_TYPE_REST = 66; 229 230 /** Use this type for the pause. */ 231 public static final int EXERCISE_SEGMENT_TYPE_PAUSE = 67; 232 ExerciseSegmentType()233 private ExerciseSegmentType() {} 234 235 /** @hide */ 236 @IntDef({ 237 EXERCISE_SEGMENT_TYPE_UNKNOWN, 238 EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS, 239 EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP, 240 EXERCISE_SEGMENT_TYPE_BIKING, 241 EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY, 242 EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM, 243 EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM, 244 EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE, 245 EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE, 246 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM, 247 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM, 248 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM, 249 EXERCISE_SEGMENT_TYPE_FORWARD_TWIST, 250 EXERCISE_SEGMENT_TYPE_ELLIPTICAL, 251 EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING, 252 EXERCISE_SEGMENT_TYPE_PILATES, 253 EXERCISE_SEGMENT_TYPE_ROWING_MACHINE, 254 EXERCISE_SEGMENT_TYPE_RUNNING, 255 EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL, 256 EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING, 257 EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE, 258 EXERCISE_SEGMENT_TYPE_STRETCHING, 259 EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER, 260 EXERCISE_SEGMENT_TYPE_SWIMMING_POOL, 261 EXERCISE_SEGMENT_TYPE_UPPER_TWIST, 262 EXERCISE_SEGMENT_TYPE_WALKING, 263 EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING, 264 EXERCISE_SEGMENT_TYPE_WHEELCHAIR, 265 EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT, 266 EXERCISE_SEGMENT_TYPE_YOGA, 267 EXERCISE_SEGMENT_TYPE_ARM_CURL, 268 EXERCISE_SEGMENT_TYPE_BACK_EXTENSION, 269 EXERCISE_SEGMENT_TYPE_BALL_SLAM, 270 EXERCISE_SEGMENT_TYPE_BENCH_PRESS, 271 EXERCISE_SEGMENT_TYPE_BURPEE, 272 EXERCISE_SEGMENT_TYPE_CRUNCH, 273 EXERCISE_SEGMENT_TYPE_DEADLIFT, 274 EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION, 275 EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW, 276 EXERCISE_SEGMENT_TYPE_FRONT_RAISE, 277 EXERCISE_SEGMENT_TYPE_HIP_THRUST, 278 EXERCISE_SEGMENT_TYPE_HULA_HOOP, 279 EXERCISE_SEGMENT_TYPE_JUMPING_JACK, 280 EXERCISE_SEGMENT_TYPE_JUMP_ROPE, 281 EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING, 282 EXERCISE_SEGMENT_TYPE_LATERAL_RAISE, 283 EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN, 284 EXERCISE_SEGMENT_TYPE_LEG_CURL, 285 EXERCISE_SEGMENT_TYPE_LEG_EXTENSION, 286 EXERCISE_SEGMENT_TYPE_LEG_PRESS, 287 EXERCISE_SEGMENT_TYPE_LEG_RAISE, 288 EXERCISE_SEGMENT_TYPE_LUNGE, 289 EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER, 290 EXERCISE_SEGMENT_TYPE_PLANK, 291 EXERCISE_SEGMENT_TYPE_PULL_UP, 292 EXERCISE_SEGMENT_TYPE_PUNCH, 293 EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS, 294 EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION, 295 EXERCISE_SEGMENT_TYPE_SIT_UP, 296 EXERCISE_SEGMENT_TYPE_SQUAT, 297 EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE, 298 EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE, 299 EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE, 300 EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY, 301 EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED, 302 EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER, 303 EXERCISE_SEGMENT_TYPE_REST, 304 EXERCISE_SEGMENT_TYPE_PAUSE, 305 }) 306 @Retention(RetentionPolicy.SOURCE) 307 public @interface ExerciseSegmentTypes {} 308 309 /** 310 * Exercise segments types which are excluded from exercise session duration. 311 * 312 * @hide 313 */ 314 public static final List<Integer> DURATION_EXCLUDE_TYPES = 315 List.of( 316 ExerciseSegmentType.EXERCISE_SEGMENT_TYPE_PAUSE, 317 ExerciseSegmentType.EXERCISE_SEGMENT_TYPE_REST); 318 319 // Update this set when add new type or deprecate existing type. 320 private static final Set<Integer> VALID_TYPES = 321 Set.of( 322 EXERCISE_SEGMENT_TYPE_UNKNOWN, 323 EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS, 324 EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP, 325 EXERCISE_SEGMENT_TYPE_BIKING, 326 EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY, 327 EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM, 328 EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM, 329 EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE, 330 EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE, 331 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM, 332 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM, 333 EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM, 334 EXERCISE_SEGMENT_TYPE_FORWARD_TWIST, 335 EXERCISE_SEGMENT_TYPE_ELLIPTICAL, 336 EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING, 337 EXERCISE_SEGMENT_TYPE_PILATES, 338 EXERCISE_SEGMENT_TYPE_ROWING_MACHINE, 339 EXERCISE_SEGMENT_TYPE_RUNNING, 340 EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL, 341 EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING, 342 EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE, 343 EXERCISE_SEGMENT_TYPE_STRETCHING, 344 EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER, 345 EXERCISE_SEGMENT_TYPE_SWIMMING_POOL, 346 EXERCISE_SEGMENT_TYPE_UPPER_TWIST, 347 EXERCISE_SEGMENT_TYPE_WALKING, 348 EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING, 349 EXERCISE_SEGMENT_TYPE_WHEELCHAIR, 350 EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT, 351 EXERCISE_SEGMENT_TYPE_YOGA, 352 EXERCISE_SEGMENT_TYPE_ARM_CURL, 353 EXERCISE_SEGMENT_TYPE_BACK_EXTENSION, 354 EXERCISE_SEGMENT_TYPE_BALL_SLAM, 355 EXERCISE_SEGMENT_TYPE_BENCH_PRESS, 356 EXERCISE_SEGMENT_TYPE_BURPEE, 357 EXERCISE_SEGMENT_TYPE_CRUNCH, 358 EXERCISE_SEGMENT_TYPE_DEADLIFT, 359 EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION, 360 EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW, 361 EXERCISE_SEGMENT_TYPE_FRONT_RAISE, 362 EXERCISE_SEGMENT_TYPE_HIP_THRUST, 363 EXERCISE_SEGMENT_TYPE_HULA_HOOP, 364 EXERCISE_SEGMENT_TYPE_JUMPING_JACK, 365 EXERCISE_SEGMENT_TYPE_JUMP_ROPE, 366 EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING, 367 EXERCISE_SEGMENT_TYPE_LATERAL_RAISE, 368 EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN, 369 EXERCISE_SEGMENT_TYPE_LEG_CURL, 370 EXERCISE_SEGMENT_TYPE_LEG_EXTENSION, 371 EXERCISE_SEGMENT_TYPE_LEG_PRESS, 372 EXERCISE_SEGMENT_TYPE_LEG_RAISE, 373 EXERCISE_SEGMENT_TYPE_LUNGE, 374 EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER, 375 EXERCISE_SEGMENT_TYPE_PLANK, 376 EXERCISE_SEGMENT_TYPE_PULL_UP, 377 EXERCISE_SEGMENT_TYPE_PUNCH, 378 EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS, 379 EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION, 380 EXERCISE_SEGMENT_TYPE_SIT_UP, 381 EXERCISE_SEGMENT_TYPE_SQUAT, 382 EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE, 383 EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE, 384 EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE, 385 EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY, 386 EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED, 387 EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER, 388 EXERCISE_SEGMENT_TYPE_REST, 389 EXERCISE_SEGMENT_TYPE_PAUSE); 390 391 /** 392 * Returns whether given segment type is known by current module version, throws exception if 393 * the type is negative. 394 * 395 * @hide 396 */ isKnownSegmentType(int segmentType)397 public static boolean isKnownSegmentType(int segmentType) { 398 if (segmentType < 0) { 399 throw new IllegalArgumentException("Exercise segment type must be non negative."); 400 } 401 402 return VALID_TYPES.contains(segmentType); 403 } 404 } 405