Home | History | Annotate | Download | only in servertransaction
      1 /*
      2  * Copyright 2017 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 android.app.servertransaction;
     18 
     19 import android.app.ClientTransactionHandler;
     20 import android.os.IBinder;
     21 
     22 /**
     23  * Base interface for individual requests from server to client.
     24  * Each of them can be prepared before scheduling and, eventually, executed.
     25  * @hide
     26  */
     27 public interface BaseClientRequest extends ObjectPoolItem {
     28 
     29     /**
     30      * Prepare the client request before scheduling.
     31      * An example of this might be informing about pending updates for some values.
     32      *
     33      * @param client Target client handler.
     34      * @param token  Target activity token.
     35      */
     36     default void preExecute(ClientTransactionHandler client, IBinder token) {
     37     }
     38 
     39     /**
     40      * Execute the request.
     41      * @param client Target client handler.
     42      * @param token Target activity token.
     43      * @param pendingActions Container that may have data pending to be used.
     44      */
     45     void execute(ClientTransactionHandler client, IBinder token,
     46             PendingTransactionActions pendingActions);
     47 
     48     /**
     49      * Perform all actions that need to happen after execution, e.g. report the result to server.
     50      * @param client Target client handler.
     51      * @param token Target activity token.
     52      * @param pendingActions Container that may have data pending to be used.
     53      */
     54     default void postExecute(ClientTransactionHandler client, IBinder token,
     55             PendingTransactionActions pendingActions) {
     56     }
     57 }
     58