public interface

ExtensionInterface

 androidx.window.extensions.ExtensionInterface

Gradle dependencies

compile group: 'androidx.window', name: 'window-extensions', version: '1.0.0-alpha01'

  • groupId: androidx.window
  • artifactId: window-extensions
  • version: 1.0.0-alpha01

Artifact androidx.window:window-extensions:1.0.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Main Extension interface definition that will be used by the WindowManager library to get custom OEM-provided information that isn't covered by platform APIs.

This interface should be implemented by OEM and deployed to the target devices.

Summary

Methods
public ExtensionDeviceStategetDeviceState()

Get current device state.

public ExtensionWindowLayoutInfogetWindowLayoutInfo(IBinder windowToken)

Get current information about the display features present within the application window.

public voidonDeviceStateListenersChanged(boolean isEmpty)

Notify the extension that a device state change listener was updated.

public voidonWindowLayoutChangeListenerAdded(IBinder windowToken)

Notify extension that a listener for display feature layout changes was registered for the given window token.

public voidonWindowLayoutChangeListenerRemoved(IBinder windowToken)

Notify extension that a listener for display feature layout changes was removed for the given window token.

public voidsetExtensionCallback(ExtensionInterface.ExtensionCallback callback)

Register the support library as the callback for the extension.

Methods

public void setExtensionCallback(ExtensionInterface.ExtensionCallback callback)

Register the support library as the callback for the extension. This interface will be used to report all extension changes to the support library.

public ExtensionWindowLayoutInfo getWindowLayoutInfo(IBinder windowToken)

Get current information about the display features present within the application window.

public void onWindowLayoutChangeListenerAdded(IBinder windowToken)

Notify extension that a listener for display feature layout changes was registered for the given window token.

public void onWindowLayoutChangeListenerRemoved(IBinder windowToken)

Notify extension that a listener for display feature layout changes was removed for the given window token.

public ExtensionDeviceState getDeviceState()

Get current device state.

See also: ExtensionInterface.onDeviceStateListenersChanged(boolean)

public void onDeviceStateListenersChanged(boolean isEmpty)

Notify the extension that a device state change listener was updated.

Parameters:

isEmpty: flag indicating if the list of device state change listeners is empty.

Source

/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.window.extensions;

import android.os.IBinder;

import androidx.annotation.NonNull;

/**
 * Main Extension interface definition that will be used by the WindowManager library to get custom
 * OEM-provided information that isn't covered by platform APIs.
 *
 * <p>This interface should be implemented by OEM and deployed to the target devices.
 *
 * @see ExtensionProvider
 */
public interface ExtensionInterface {

    /**
     * Register the support library as the callback for the extension. This interface will be used
     * to report all extension changes to the support library.
     */
    void setExtensionCallback(@NonNull ExtensionCallback callback);

    /**
     * Get current information about the display features present within the application window.
     */
    @NonNull
    ExtensionWindowLayoutInfo getWindowLayoutInfo(@NonNull IBinder windowToken);

    /**
     * Notify extension that a listener for display feature layout changes was registered for the
     * given window token.
     */
    void onWindowLayoutChangeListenerAdded(@NonNull IBinder windowToken);

    /**
     * Notify extension that a listener for display feature layout changes was removed for the
     * given window token.
     */
    void onWindowLayoutChangeListenerRemoved(@NonNull IBinder windowToken);

    /**
     * Get current device state.
     * @see #onDeviceStateListenersChanged(boolean)
     */
    @NonNull
    ExtensionDeviceState getDeviceState();

    /**
     * Notify the extension that a device state change listener was updated.
     * @param isEmpty flag indicating if the list of device state change listeners is empty.
     */
    void onDeviceStateListenersChanged(boolean isEmpty);

    /**
     * Callback that will be registered with the WindowManager library, and that the extension
     * should use to report all state changes.
     */
    interface ExtensionCallback {
        /**
         * Called by extension when the device state changes.
         */
        void onDeviceStateChanged(@NonNull ExtensionDeviceState newDeviceState);

        /**
         * Called by extension when the feature layout inside the window changes.
         */
        void onWindowLayoutChanged(@NonNull IBinder windowToken,
                @NonNull ExtensionWindowLayoutInfo newLayout);
    }
}