1 /* 2 * Copyright 2024 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 androidx.xr.runtime.internal 18 19 import androidx.annotation.RestrictTo 20 21 /** 22 * XR Runtime spatial capabilities. 23 * 24 * @param capabilities the set of capabilities enabled for the platform. 25 */ 26 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) 27 public class SpatialCapabilities(public val capabilities: Int) { 28 29 /** Spatial Capabilities for SceneCore Platform. */ 30 @Retention(AnnotationRetention.SOURCE) 31 public annotation class SpatialCapability { 32 public companion object { 33 public const val SPATIAL_CAPABILITY_UI: Int = 1.shl(0) 34 public const val SPATIAL_CAPABILITY_3D_CONTENT: Int = 1.shl(1) 35 public const val SPATIAL_CAPABILITY_PASSTHROUGH_CONTROL: Int = 1.shl(2) 36 public const val SPATIAL_CAPABILITY_APP_ENVIRONMENT: Int = 1.shl(3) 37 public const val SPATIAL_CAPABILITY_SPATIAL_AUDIO: Int = 1.shl(4) 38 public const val SPATIAL_CAPABILITY_EMBED_ACTIVITY: Int = 1.shl(5) 39 } 40 } 41 hasCapabilitynull42 public fun hasCapability(@SpatialCapability capability: Int): Boolean = 43 (capabilities and capability) != 0 44 45 public companion object { 46 /** The activity can spatialize itself by e.g. adding a spatial panel. */ 47 public const val SPATIAL_CAPABILITY_UI: Int = 1.shl(0) 48 49 /** The activity can create 3D contents. */ 50 public const val SPATIAL_CAPABILITY_3D_CONTENT: Int = 1.shl(1) 51 52 /** The activity can enable or disable passthrough. */ 53 public const val SPATIAL_CAPABILITY_PASSTHROUGH_CONTROL: Int = 1.shl(2) 54 55 /** The activity can set its own environment. */ 56 public const val SPATIAL_CAPABILITY_APP_ENVIRONMENT: Int = 1.shl(3) 57 58 /** The activity can use spatial audio. */ 59 public const val SPATIAL_CAPABILITY_SPATIAL_AUDIO: Int = 1.shl(4) 60 61 /** The activity can spatially embed another activity. */ 62 public const val SPATIAL_CAPABILITY_EMBED_ACTIVITY: Int = 1.shl(5) 63 } 64 } 65