Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.

Tent and wedge postures

On book-style foldable devices, you can enable support for tent and wedge modes.

Tent and wedge modes let you use the outer screen when the device is slightly open, as shown in the following figure:

Tent and wedge foldable postures

Figure 1. Tent and wedge foldable postures.

In the tent mode, the device is partially open, using both halves to support itself like a tent. In the wedge mode, the device is propped up on its right half, which lies flat on a surface.

Android 16 and higher supports this behavior by using BookStyleDeviceStatePolicy as your device state policy. This policy works on a foldable device with two screens in a book style, with the hinge located on the left side of the device when folded.

This policy keeps the outer screen on longer when unfolding under certain conditions, for example:

  • The right half of the device is mostly flat, indicating that the device is likely in wedge mode.
  • The device orientation is reverse landscape, indicating that it's likely in tent mode.
  • The screen orientation is landscape or reverse landscape.
  • There is an app holding a screen wakelock (preventing screen timeout).

The policy doesn't introduce a separate device state for tent or wedge posture; it keeps the closed state for a wider range of hinge angles under these specific conditions.

To fully support these heuristics, the device needs:

  • Hinge angle sensor reporting the angle between the two halves of the device
  • Accelerometer sensor on each (left and right) halves of the device

Configure tent or wedge mode

Follow these steps to enable tent and wedge mode support on your device:

  1. Create an implementation of DeviceStatePolicy.Provider that returns an instance of BookStyleDeviceStatePolicy. The instance must provide all the necessary dependencies, like sensor objects, to the BookStyleDeviceStatePolicy constructor.

    The following example shows an implementation:

    packagecom.example;
    publicclass MyDevicePolicyProviderimplementsDeviceStatePolicy.Provider{
    @Override
    publicDeviceStatePolicyinstantiate(@NonNullContextcontext){
    finalSensorManagersensorManager=context.getSystemService(SensorManager.class);
    finalSensorhingeAngleSensor=
    sensorManager.getDefaultSensor(Sensor.TYPE_HINGE_ANGLE,/* wakeUp= */true);
    finalList<Sensor>sensors=sensorManager.getSensorList(Sensor.TYPE_ALL);
    finalSensorhallSensor=CollectionUtils.find(sensors,
    (sensor)->Objects.equals(sensor.getStringType(),
    "com.example.hall_effect"));
    finalSensorrightAccelerometerSensor=CollectionUtils.find(sensors,
    (sensor)->Objects.equals(sensor.getName(),"Accelerometer 0"));
    finalSensorleftAccelerometerSensor=CollectionUtils.find(sensors,
    (sensor)->Objects.equals(sensor.getName(),"Accelerometer 1"));
    // You can pass a non-null value here to disable tent/wedge mode logic,
    // so the displays switch will always happen at the fixed hinge angle.
    // This might be useful, for example, when in a retail demo mode where
    // the hinge angle range of the device is limited.
    finalIntegercloseAngleDegrees=null;
    returnnewBookStyleDeviceStatePolicy(newFeatureFlagsImpl(),context,
    hingeAngleSensor,hallSensor,leftAccelerometerSensor,rightAccelerometerSensor,closeAngleDegrees);
    }
    }
    
  2. Add the policy provider to system server's classpath. Start by creating a library with the device state policy provider class that you created in the previous step.

    The following example shows a Soong Android.bp blueprint configuration:

    java_library{
    name:"my-device-services",
    installable:true,
    system_ext_specific:true,
    srcs:[
    "src/**/*.java"
    ],
    libs:[
    "services",
    ],
    }
    

    Then, to add this library to the system server, modify the device's makefile by adding the following lines:

    # Add system service libraries (they contain device-specific policies)
    PRODUCT_SYSTEM_SERVER_JARS+=\
    my-device-services
    PRODUCT_PACKAGES+=\
    my-device-services
    
  3. Update config_deviceSpecificDeviceStatePolicyProvider to the class name of your provider in the config.xml file, for example:

    <stringtranslatable="false"name="config_deviceSpecificDeviceStatePolicyProvider">com.example.MyDevicePolicyProvider</string>
    

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025年12月02日 UTC.