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

Commit 3f50a39b authored by Daniel Erat's avatar Daniel Erat
Browse files

Add more methods to IPowerManager.

Add the full list of transaction IDs from IPowerManager.aidl
to IPowerManager.h and make BpPowerManager support calling
goToSleep, reboot, shutdown, and crash. These are currently
needed by or likely to be needed by Brillo.

Bug: 22122485
Change-Id: I19abd3587c9d53b28ec150210e07f97517ee4ff4
parent 28b1d678
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -36,6 +36,18 @@ public:
        RELEASE_WAKE_LOCK            = IBinder::FIRST_CALL_TRANSACTION + 2,
        UPDATE_WAKE_LOCK_UIDS        = IBinder::FIRST_CALL_TRANSACTION + 3,
        POWER_HINT                   = IBinder::FIRST_CALL_TRANSACTION + 4,
        UPDATE_WAKE_LOCK_SOURCE      = IBinder::FIRST_CALL_TRANSACTION + 5,
        IS_WAKE_LOCK_LEVEL_SUPPORTED = IBinder::FIRST_CALL_TRANSACTION + 6,
        USER_ACTIVITY                = IBinder::FIRST_CALL_TRANSACTION + 7,
        WAKE_UP                      = IBinder::FIRST_CALL_TRANSACTION + 8,
        GO_TO_SLEEP                  = IBinder::FIRST_CALL_TRANSACTION + 9,
        NAP                          = IBinder::FIRST_CALL_TRANSACTION + 10,
        IS_INTERACTIVE               = IBinder::FIRST_CALL_TRANSACTION + 11,
        IS_POWER_SAVE_MODE           = IBinder::FIRST_CALL_TRANSACTION + 12,
        SET_POWER_SAVE_MODE          = IBinder::FIRST_CALL_TRANSACTION + 13,
        REBOOT                       = IBinder::FIRST_CALL_TRANSACTION + 14,
        SHUTDOWN                     = IBinder::FIRST_CALL_TRANSACTION + 15,
        CRASH                        = IBinder::FIRST_CALL_TRANSACTION + 16,
    };

    DECLARE_META_INTERFACE(PowerManager);
@@ -50,8 +62,11 @@ public:
    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags, bool isOneWay = false) = 0;
    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids,
            bool isOneWay = false) = 0;
    // oneway in the .aidl
    virtual status_t powerHint(int hintId, int data) = 0;
    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags) = 0;
    virtual status_t reboot(bool confirm, const String16& reason, bool wait) = 0;
    virtual status_t shutdown(bool confirm, const String16& reason, bool wait) = 0;
    virtual status_t crash(const String16& message) = 0;
};

// ----------------------------------------------------------------------------
+38 −0
Original line number Diff line number Diff line
@@ -95,6 +95,44 @@ public:
        // This FLAG_ONEWAY is in the .aidl, so there is no way to disable it
        return remote()->transact(POWER_HINT, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
        data.writeInt64(event_time_ms);
        data.writeInt32(reason);
        data.writeInt32(flags);
        return remote()->transact(GO_TO_SLEEP, data, &reply, 0);
    }

    virtual status_t reboot(bool confirm, const String16& reason, bool wait)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
        data.writeInt32(confirm);
        data.writeString16(reason);
        data.writeInt32(wait);
        return remote()->transact(REBOOT, data, &reply, 0);
    }

    virtual status_t shutdown(bool confirm, const String16& reason, bool wait)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
        data.writeInt32(confirm);
        data.writeString16(reason);
        data.writeInt32(wait);
        return remote()->transact(SHUTDOWN, data, &reply, 0);
    }

    virtual status_t crash(const String16& message)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
        data.writeString16(message);
        return remote()->transact(CRASH, data, &reply, 0);
    }
};

IMPLEMENT_META_INTERFACE(PowerManager, "android.os.IPowerManager");