1 /*
2  * Copyright (C) 2006 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;
18 
19 import android.annotation.UnsupportedAppUsage;
20 import android.os.Message;
21 
22 /** @hide */
23 public class AsyncResult
24 {
25 
26     /*************************** Instance Variables **************************/
27 
28     // Expect either exception or result to be null
29     @UnsupportedAppUsage
30     public Object userObj;
31     @UnsupportedAppUsage
32     public Throwable exception;
33     @UnsupportedAppUsage
34     public Object result;
35 
36     /***************************** Class Methods *****************************/
37 
38     /** Saves and sets m.obj */
39     @UnsupportedAppUsage
40     public static AsyncResult
forMessage(Message m, Object r, Throwable ex)41     forMessage(Message m, Object r, Throwable ex)
42     {
43         AsyncResult ret;
44 
45         ret = new AsyncResult (m.obj, r, ex);
46 
47         m.obj = ret;
48 
49         return ret;
50     }
51 
52     /** Saves and sets m.obj */
53     @UnsupportedAppUsage
54     public static AsyncResult
forMessage(Message m)55     forMessage(Message m)
56     {
57         AsyncResult ret;
58 
59         ret = new AsyncResult (m.obj, null, null);
60 
61         m.obj = ret;
62 
63         return ret;
64     }
65 
66     /** please note, this sets m.obj to be this */
67     @UnsupportedAppUsage
68     public
AsyncResult(Object uo, Object r, Throwable ex)69     AsyncResult (Object uo, Object r, Throwable ex)
70     {
71         userObj = uo;
72         result = r;
73         exception = ex;
74     }
75 }
76