@@ -24,7 +24,6 @@ import androidx.xr.runtime.Config
2424import androidx.xr.runtime.HandJointType
2525import androidx.xr.runtime.Session
2626import androidx.xr.runtime.SessionConfigureConfigurationNotSupported
27- import androidx.xr.runtime.SessionConfigurePermissionsNotGranted
2827import androidx.xr.runtime.SessionConfigureSuccess
2928import androidx.xr.runtime.math.Pose
3029import androidx.xr.runtime.math.Quaternion
@@ -35,18 +34,17 @@ import androidx.xr.scenecore.scene
3534import kotlinx.coroutines.flow.Flow
3635import kotlinx.coroutines.launch
3736
38- @Suppress(" RestrictedApi" ) // b/416288516 - session.config and session.configure() are incorrectly restricted
3937fun ComponentActivity.configureSession (session : Session ) {
4038 // [START androidxr_arcore_hand_configure]
4139 val newConfig = session.config.copy(
42- handTracking = Config .HandTrackingMode .Enabled
40+ handTracking = Config .HandTrackingMode .BOTH
4341 )
4442 when (val result = session.configure(newConfig)) {
4543 is SessionConfigureConfigurationNotSupported ->
4644 TODO (/* Some combinations of configurations are not valid. Handle this failure case. */ )
47- is SessionConfigurePermissionsNotGranted ->
48- TODO (/* The required permissions in result.permissions have not been granted. */ )
4945 is SessionConfigureSuccess -> TODO (/* Success! */ )
46+ else ->
47+ TODO (/* A different unhandled exception was thrown. */ )
5048 }
5149 // [END androidxr_arcore_hand_configure]
5250}
@@ -71,8 +69,8 @@ fun ComponentActivity.collectHands(session: Session) {
7169fun secondaryHandDetection (activity : Activity , session : Session ) {
7270 fun detectGesture (handState : Flow <Hand .State >) {}
7371 // [START androidxr_arcore_hand_handedness]
74- val handedness = Hand .getHandedness (activity.contentResolver)
75- val secondaryHand = if (handedness == Hand .Handedness .LEFT ) Hand .right(session) else Hand .left(session)
72+ val handedness = Hand .getPrimaryHandSide (activity.contentResolver)
73+ val secondaryHand = if (handedness == Hand .HandSide .LEFT ) Hand .right(session) else Hand .left(session)
7674 val handState = secondaryHand?.state ? : return
7775 detectGesture(handState)
7876 // [END androidxr_arcore_hand_handedness]
@@ -86,7 +84,7 @@ fun ComponentActivity.renderPlanetAtHandPalm(leftHandState: Hand.State) {
8684
8785 // the down direction points in the same direction as the palm
8886 val angle = Vector3 .angleBetween(palmPose.rotation * Vector3 .Down , Vector3 .Up )
89- palmEntity.setHidden (angle > Math .toRadians(40.0 ))
87+ palmEntity.setEnabled (angle > Math .toRadians(40.0 ))
9088
9189 val transformedPose =
9290 session.scene.perceptionSpace.transformPoseTo(
@@ -107,7 +105,7 @@ fun ComponentActivity.renderPlanetAtFingerTip(rightHandState: Hand.State) {
107105
108106 // the forward direction points towards the finger tip.
109107 val angle = Vector3 .angleBetween(tipPose.rotation * Vector3 .Forward , Vector3 .Up )
110- indexFingerEntity.setHidden (angle > Math .toRadians(40.0 ))
108+ indexFingerEntity.setEnabled (angle > Math .toRadians(40.0 ))
111109
112110 val transformedPose =
113111 session.scene.perceptionSpace.transformPoseTo(
0 commit comments