• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 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.os.storage;
18 
19 import android.os.Binder;
20 import android.os.IBinder;
21 import android.os.IInterface;
22 import android.os.Parcel;
23 import android.os.RemoteException;
24 
25 /**
26  * Callback class for receiving events related to shutdown.
27  *
28  * @hide - For internal consumption only.
29  */
30 public interface IMountShutdownObserver extends IInterface {
31     /** Local-side IPC implementation stub class. */
32     public static abstract class Stub extends Binder implements IMountShutdownObserver {
33         private static final java.lang.String DESCRIPTOR = "IMountShutdownObserver";
34 
35         /** Construct the stub at attach it to the interface. */
Stub()36         public Stub() {
37             this.attachInterface(this, DESCRIPTOR);
38         }
39 
40         /**
41          * Cast an IBinder object into an IMountShutdownObserver interface,
42          * generating a proxy if needed.
43          */
asInterface(IBinder obj)44         public static IMountShutdownObserver asInterface(IBinder obj) {
45             if ((obj == null)) {
46                 return null;
47             }
48             IInterface iin = (IInterface) obj.queryLocalInterface(DESCRIPTOR);
49             if (((iin != null) && (iin instanceof IMountShutdownObserver))) {
50                 return ((IMountShutdownObserver) iin);
51             }
52             return new IMountShutdownObserver.Stub.Proxy(obj);
53         }
54 
asBinder()55         public IBinder asBinder() {
56             return this;
57         }
58 
59         @Override
onTransact(int code, Parcel data, Parcel reply, int flags)60         public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
61                 throws RemoteException {
62             switch (code) {
63                 case INTERFACE_TRANSACTION: {
64                     reply.writeString(DESCRIPTOR);
65                     return true;
66                 }
67                 case TRANSACTION_onShutDownComplete: {
68                     data.enforceInterface(DESCRIPTOR);
69                     int statusCode;
70                     statusCode = data.readInt();
71                     this.onShutDownComplete(statusCode);
72                     reply.writeNoException();
73                     return true;
74                 }
75             }
76             return super.onTransact(code, data, reply, flags);
77         }
78 
79         private static class Proxy implements IMountShutdownObserver {
80             private IBinder mRemote;
81 
Proxy(IBinder remote)82             Proxy(IBinder remote) {
83                 mRemote = remote;
84             }
85 
asBinder()86             public IBinder asBinder() {
87                 return mRemote;
88             }
89 
getInterfaceDescriptor()90             public java.lang.String getInterfaceDescriptor() {
91                 return DESCRIPTOR;
92             }
93 
94             /**
95              * This method is called when the shutdown of MountService
96              * completed.
97              *
98              * @param statusCode indicates success or failure of the shutdown.
99              */
onShutDownComplete(int statusCode)100             public void onShutDownComplete(int statusCode) throws RemoteException {
101                 Parcel _data = Parcel.obtain();
102                 Parcel _reply = Parcel.obtain();
103                 try {
104                     _data.writeInterfaceToken(DESCRIPTOR);
105                     _data.writeInt(statusCode);
106                     mRemote.transact(Stub.TRANSACTION_onShutDownComplete, _data, _reply, 0);
107                     _reply.readException();
108                 } finally {
109                     _reply.recycle();
110                     _data.recycle();
111                 }
112             }
113         }
114 
115         static final int TRANSACTION_onShutDownComplete = (IBinder.FIRST_CALL_TRANSACTION + 0);
116     }
117 
118     /**
119      * This method is called when the shutdown of MountService completed.
120      *
121      * @param statusCode indicates success or failure of the shutdown.
122      */
onShutDownComplete(int statusCode)123     public void onShutDownComplete(int statusCode) throws RemoteException;
124 }
125