Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1930893e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "APIForQueryingHapticsExist"

* changes:
  Add API in RingtoneManager to query if files contain haptic channels.
  Add key for haptic channel count.
parents 38076cdc ad225205
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -25054,6 +25054,7 @@ package android.media {
    field public static final String KEY_FRAME_RATE = "frame-rate";
    field public static final String KEY_GRID_COLUMNS = "grid-cols";
    field public static final String KEY_GRID_ROWS = "grid-rows";
    field public static final String KEY_HAPTIC_CHANNEL_COUNT = "haptic-channel-count";
    field public static final String KEY_HDR10_PLUS_INFO = "hdr10-plus-info";
    field public static final String KEY_HDR_STATIC_INFO = "hdr-static-info";
    field public static final String KEY_HEIGHT = "height";
@@ -26344,6 +26345,8 @@ package android.media {
    method public android.net.Uri getRingtoneUri(int);
    method public boolean getStopPreviousRingtone();
    method public static android.net.Uri getValidRingtoneUri(android.content.Context);
    method public boolean hasHapticChannels(int);
    method public static boolean hasHapticChannels(@NonNull android.net.Uri);
    method public int inferStreamType();
    method public static boolean isDefault(android.net.Uri);
    method @Nullable public static android.content.res.AssetFileDescriptor openDefaultRingtoneUri(@NonNull android.content.Context, @NonNull android.net.Uri) throws java.io.FileNotFoundException;
+15 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.MediaSessionLegacyHelper;
import android.media.session.MediaSessionManager;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
@@ -5441,6 +5442,20 @@ public class AudioManager {
        sAudioAudioVolumeGroupChangedHandler.unregisterListener(callback);
    }

    /**
     * Return if an asset contains haptic channels or not.
     * @param uri the {@link Uri} of the asset.
     * @return true if the assert contains haptic channels.
     * @hide
     */
    public static boolean hasHapticChannels(Uri uri) {
        try {
            return getService().hasHapticChannels(uri);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    //---------------------------------------------------------
    // Inner classes
    //--------------------
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.media.audiopolicy.AudioProductStrategies;
import android.media.audiopolicy.AudioVolumeGroups;
import android.media.audiopolicy.IAudioPolicyCallback;
import android.media.projection.IMediaProjection;
import android.net.Uri;

/**
 * {@hide}
@@ -250,6 +251,8 @@ interface IAudioService {

    int removeUidDeviceAffinity(in IAudioPolicyCallback pcb, in int uid);

    boolean hasHapticChannels(in Uri uri);

    // WARNING: read warning at top of file, new methods that need to be used by native
    // code via IAudioManager.h need to be added to the top section.
}
+6 −0
Original line number Diff line number Diff line
@@ -874,6 +874,12 @@ public final class MediaFormat {
     */
    public static final String KEY_IS_FORCED_SUBTITLE = "is-forced-subtitle";

    /**
     * A key describing the number of haptic channels in an audio format.
     * The associated value is an integer.
     */
    public static final String KEY_HAPTIC_CHANNEL_COUNT = "haptic-channel-count";

    /** @hide */
    public static final String KEY_IS_TIMED_TEXT = "is-timed-text";

+22 −0
Original line number Diff line number Diff line
@@ -1097,6 +1097,28 @@ public class RingtoneManager {
        return afd;
    }

    /**
     * Returns if the {@link Ringtone} at the given position in the
     * {@link Cursor} contains haptic channels.
     *
     * @param position The position (in the {@link Cursor}) of the ringtone.
     * @return true if the ringtone contains haptic channels.
     */
    public boolean hasHapticChannels(int position) {
        return hasHapticChannels(getRingtoneUri(position));
    }

    /**
     * Returns if the {@link Ringtone} from a given sound URI contains
     * haptic channels or not.
     *
     * @param ringtoneUri The {@link Uri} of a sound or ringtone.
     * @return true if the ringtone contains haptic channels.
     */
    public static boolean hasHapticChannels(@NonNull Uri ringtoneUri) {
        return AudioManager.hasHapticChannels(ringtoneUri);
    }

    /**
     * Creates a {@link android.media.MediaScannerConnection} to scan a ringtone file and add its
     * information to the internal database.
Loading