blob: 7db0ea1d545ba5b0b4774641494856f811162f01 [file] [log] [blame]
Wei Wang05003412021-04-01 10:44:29 -07001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.power;
18
Matt Buckley13843882022-09-15 22:32:56 +000019import android.hardware.power.SessionHint;
Wei Wang05003412021-04-01 10:44:29 -070020import android.hardware.power.WorkDuration;
21
22@VintfStability
Peiyong Linc7854592022-10-13 00:10:31 +000023interface IPowerHintSession {
Wei Wang05003412021-04-01 10:44:29 -070024 /**
25 * Updates the desired duration of a previously-created thread group.
26 *
27 * See {@link IPowerHintSession#createHintSession} for more information on how
28 * the desired duration will be used.
29 *
30 * @param targetDurationNanos the new desired duration in nanoseconds
31 */
Peiyong Linc7854592022-10-13 00:10:31 +000032 oneway void updateTargetWorkDuration(long targetDurationNanos);
Wei Wang05003412021-04-01 10:44:29 -070033
34 /**
35 * Reports the actual duration of a thread group.
36 *
37 * The system will attempt to adjust the core placement of the threads within
38 * the thread group and/or the frequency of the core on which they are run to bring
39 * the actual duration close to the target duration.
40 *
41 * @param actualDurationMicros how long the thread group took to complete its
42 * last task in nanoseconds
43 */
Peiyong Linc7854592022-10-13 00:10:31 +000044 oneway void reportActualWorkDuration(in WorkDuration[] durations);
Wei Wang05003412021-04-01 10:44:29 -070045
46 /**
Wei Wang12495d22021-04-06 19:43:00 -070047 * Pause the session when the application is not allowed to send hint in framework.
Wei Wang05003412021-04-01 10:44:29 -070048 */
Peiyong Linc7854592022-10-13 00:10:31 +000049 oneway void pause();
Wei Wang05003412021-04-01 10:44:29 -070050
51 /**
Wei Wang12495d22021-04-06 19:43:00 -070052 * Resume the session when the application is allowed to send hint in framework.
Wei Wang05003412021-04-01 10:44:29 -070053 */
Peiyong Linc7854592022-10-13 00:10:31 +000054 oneway void resume();
Wei Wang05003412021-04-01 10:44:29 -070055
56 /**
Wei Wang12495d22021-04-06 19:43:00 -070057 * Close the session to release resources.
Wei Wang05003412021-04-01 10:44:29 -070058 */
Peiyong Linc7854592022-10-13 00:10:31 +000059 oneway void close();
Matt Buckley13843882022-09-15 22:32:56 +000060
61 /**
62 * Gives information to the PowerHintSession about upcoming or unexpected
63 * changes in load to supplement the normal updateTarget/reportActual cycle.
64 *
65 * @param hint The hint to provide to the PowerHintSession
66 */
Peiyong Linc7854592022-10-13 00:10:31 +000067 oneway void sendHint(SessionHint hint);
68
69 /**
70 * Sets a list of threads to the power hint session. This operation will replace
71 * the current list of threads with the given list of threads. If there's already
72 * boost for the replaced threads, a reset must be performed for the replaced
73 * threads. Note that this is not an oneway method.
74 *
75 * @param threadIds The list of threads to be associated
76 * with this session.
77 *
78 * @throws ScopedAStatus Status of the operation. If status code is not
79 * STATUS_OK, getMessage() must be populated with the human-readable
80 * error message. If the list of thread ids is empty, EX_ILLEGAL_ARGUMENT
81 * must be thrown.
82 */
83 void setThreads(in int[] threadIds);
Wei Wang05003412021-04-01 10:44:29 -070084}