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

Commit 4046d32c authored by Matt Buckley's avatar Matt Buckley Committed by Android (Google) Code Review
Browse files

Merge "Revert "Revert "Add HAL method to return SupportInfo object for ..."" into main

parents 87a18c25 607720e6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,4 +43,5 @@ interface IPower {
  android.hardware.power.IPowerHintSession createHintSessionWithConfig(in int tgid, in int uid, in int[] threadIds, in long durationNanos, in android.hardware.power.SessionTag tag, out android.hardware.power.SessionConfig config);
  android.hardware.power.ChannelConfig getSessionChannel(in int tgid, in int uid);
  oneway void closeSessionChannel(in int tgid, in int uid);
  android.hardware.power.SupportInfo getSupportInfo();
}
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.power;
@VintfStability
parcelable SupportInfo {
  boolean usesSessions;
  long boosts;
  long modes;
  long sessionHints;
  long sessionModes;
  long sessionTags;
}
+11 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.hardware.power.IPowerHintSession;
import android.hardware.power.Mode;
import android.hardware.power.SessionConfig;
import android.hardware.power.SessionTag;
import android.hardware.power.SupportInfo;

@VintfStability
interface IPower {
@@ -144,4 +145,14 @@ interface IPower {
     * @param   uid The UID to be associated with this channel.
     */
    oneway void closeSessionChannel(in int tgid, in int uid);

    /**
     * Called to get detailed information on the support status of various PowerHAL
     * features, such as hint sessions and specific boosts.
     *
     * @return  a SupportInfo giving detailed support information, or
     *          EX_UNSUPPORTED_OPERATION if detailed support checking is itself
     *          not supported.
     */
    SupportInfo getSupportInfo();
}
+73 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 android.hardware.power;

import android.hardware.power.Boost;
import android.hardware.power.Mode;
import android.hardware.power.SessionHint;
import android.hardware.power.SessionMode;

/**
 * Tells clients the status of various PowerHAL features in a single call.
 * SupportInfo consists of several bitsets, where each bit from the left
 * corresponds to the support status of that same value of that enum index.
 *
 * For "Boost", having the first bit set would mean "INTERACTION"
 * boost is supported, having the second bit set would mean
 * "DISPLAY_UPDATE_IMMINENT" is supported, and so on. The expectation
 * is that a client should be able to index the bitset like
 * "(supportInfo.boosts >> Boost::AUDIO_LAUNCH) % 2" and it should return
 * the support value of Boost::AUDIO_LAUNCH. This pattern is the same for
 * all four support bitsets.
 */
@VintfStability
parcelable SupportInfo {
    /**
     * Boolean representing whether hint sessions are supported on this device
     */
    boolean usesSessions;

    /**
     * The set of "Boost" enum values that are supported by this device
     * Each bit should correspond to a value of the "Boost.aidl" enum
     */
    long boosts;

    /**
     * The set of "Mode" enum values that are supported by this device
     * Each bit should correspond to a value of the "Mode.aidl" enum
     */
    long modes;

    /**
     * The set of "SessionHint" enum values that are supported by this device
     * Each bit should correspond to a value of the "SessionHint.aidl" enum
     */
    long sessionHints;

    /**
     * The set of "SessionMode" enum values that are supported by this device
     * Each bit should correspond to a value of the "SessionMode.aidl" enum
     */
    long sessionModes;

    /**
     * The set of "SessionTag" enum values that are supported by this device
     * Each bit should correspond to a value of the "SessionTag.aidl" enum
     */
    long sessionTags;
}
+25 −1
Original line number Diff line number Diff line
@@ -41,6 +41,11 @@ const std::vector<Boost> BOOST_RANGE{ndk::enum_range<Boost>().begin(),
                                     ndk::enum_range<Boost>().end()};
const std::vector<Mode> MODE_RANGE{ndk::enum_range<Mode>().begin(), ndk::enum_range<Mode>().end()};

template <class T>
constexpr size_t enum_size() {
    return static_cast<size_t>(*(ndk::enum_range<T>().end() - 1)) + 1;
}

ScopedAStatus Power::setMode(Mode type, bool enabled) {
    LOG(VERBOSE) << "Power setMode: " << static_cast<int32_t>(type) << " to: " << enabled;
    return ScopedAStatus::ok();
@@ -105,11 +110,30 @@ ndk::ScopedAStatus Power::closeSessionChannel(int32_t, int32_t) {
    return ndk::ScopedAStatus::ok();
}

ScopedAStatus Power::getHintSessionPreferredRate(int64_t* outNanoseconds) {
ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t* outNanoseconds) {
    *outNanoseconds = std::chrono::nanoseconds(1ms).count();
    return ScopedAStatus::ok();
}

template <class E>
int64_t bitsForEnum() {
    return static_cast<int64_t>(std::bitset<enum_size<E>()>().set().to_ullong());
}

ndk::ScopedAStatus Power::getSupportInfo(SupportInfo* _aidl_return) {
    static SupportInfo supportInfo = {
            .usesSessions = false,
            .modes = bitsForEnum<Mode>(),
            .boosts = bitsForEnum<Boost>(),
            .sessionHints = 0,
            .sessionModes = 0,
            .sessionTags = 0,
    };
    // Copy the support object into the binder
    *_aidl_return = supportInfo;
    return ndk::ScopedAStatus::ok();
}

}  // namespace example
}  // namespace impl
}  // namespace power
Loading