• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 
17 package com.google.android.startop.iorap;
18 
19 import com.google.android.startop.iorap.ITaskListener;
20 
21 import com.google.android.startop.iorap.PackageEvent;
22 import com.google.android.startop.iorap.AppLaunchEvent;
23 import com.google.android.startop.iorap.AppIntentEvent;
24 import com.google.android.startop.iorap.SystemServiceEvent;
25 import com.google.android.startop.iorap.SystemServiceUserEvent;
26 import com.google.android.startop.iorap.RequestId;
27 
28 /**
29 * IIOrap is a client interface to the input/output readahead and pin daemon (iorapd).
30 *
31 * The aim is to speed-up the cold start-up time of certain use-cases like application startup
32 * by utilizing trace-based pinning or readahead.
33 *
34 * Programatically, the behavior of iorapd should be treated like a black box. There is no
35 * "correctness", but only performance. By sending the right events at the appropriate time,
36 * we can squeeze more performance out of the system.
37 *
38 * If some events are not appropriately wired up, system performance may (temporarily) degrade.
39 *
40 * {@hide} */
41 oneway interface IIorap {
42    /**
43     * Set an ITaskListener which will be used to deliver notifications of in-progress/completition
44     * for the onXEvent method calls below this.<br /><br />
45     *
46     * iorapd does all the work asynchronously and may deliver one or more onProgress events after
47     * the event begins to be processed. It will always send back one onComplete that is considered
48     * terminal.<br /><br />
49     *
50     * onProgress/onComplete are matched to the original event by the requestId. Once an onComplete
51     * occurs for any given requestId, no further callbacks with the same requestId will occur.
52     * It is illegal for the caller to reuse the same requestId on different invocations of IIorap.
53     * <br /><br />
54     *
55     * onXEvent(id1) must be well-ordered w.r.t. onXEvent(id2), the assumption is that later
56     * calls happen-after earlier calls and that id2 > id1. Decreasing request IDs will
57     * immediately get rejected.
58     * <br /><br />
59     *
60     * Sequence diagram of stereotypical successful event delivery and response notification:
61     *
62     * <pre>
63     *
64     *           ┌─────────────┐                ┌──────┐
65     *           │system_server│                │iorapd│
66     *           └──────┬──────┘                └──┬───┘
67     *                  Request [01]: onSomeEvent ┌┴┐
68     *                  │────────────────────────>│ │
69     *                  │                         │ │
70     *                  │                         │ │  ╔════════════════════════╗
71     *                  │                         │ │  ║start processing event ░║
72     *                  │                         │ │  ╚════════════════════════╝
73     *                  │                         │ │
74     * ╔═══════╤════════╪═════════════════════════╪═╪══════════════════════════════╗
75     * ║ LOOP  │  1 or more times                 │ │                              ║
76     * ╟───────┘        │                         │ │                              ║
77     * ║                │Request [01]: onProgress │ │                              ║
78     * ║                │<────────────────────────│ │                              ║
79     * ║                │                         │ │                              ║
80     * ║                │                         │ │────┐                         ║
81     * ║                │                         │ │    │ workload in progress    ║
82     * ║                │                         │ │<───┘                         ║
83     * ╚════════════════╪═════════════════════════╪═╪══════════════════════════════╝
84     *                  │                         └┬┘
85     *                  .                          .
86     *                  .                          .
87     *                  .                          .
88     *                  .                          .
89     *                  .                          .
90     *                  │                         ┌┴┐  ╔═════════════════════════╗
91     *                  │                         │ │  ║finish processing event ░║
92     *                  │                         │ │  ╚═════════════════════════╝
93     *                  │Request [01]: onComplete │ │
94     *                  │<────────────────────────│ │
95     *           ┌──────┴──────┐                ┌─└┬┘──┐
96     *           │system_server│                │iorapd│
97     *           └─────────────┘                └──────┘
98     *
99     * </pre> <!-- system/iorap/docs/binder/IIorap_setTaskListener.plantuml -->
100     */
setTaskListener(ITaskListener listener)101     void setTaskListener(ITaskListener listener);
102 
103     // All callbacks will be done via the ITaskListener.
104     // The RequestId passed in is the same RequestId sent back via the ITaskListener.
105     // See above for more details.
106 
107     // Note: For each ${Type}Event, see the ${Type}Event.java for more documentation
108     // in frameworks/base/startop/src/com/google/android/startop/iorap/${Type}Event.java
109 
110     // void onActivityHintEvent(in RequestId request, in ActivityHintEvent event);
onAppLaunchEvent(in RequestId request, in AppLaunchEvent event)111     void onAppLaunchEvent(in RequestId request, in AppLaunchEvent event);
onPackageEvent(in RequestId request, in PackageEvent event)112     void onPackageEvent(in RequestId request, in PackageEvent event);
onAppIntentEvent(in RequestId request, in AppIntentEvent event)113     void onAppIntentEvent(in RequestId request, in AppIntentEvent event);
onSystemServiceEvent(in RequestId request, in SystemServiceEvent event)114     void onSystemServiceEvent(in RequestId request, in SystemServiceEvent event);
onSystemServiceUserEvent(in RequestId request, in SystemServiceUserEvent event)115     void onSystemServiceUserEvent(in RequestId request, in SystemServiceUserEvent event);
116 }
117