blob: 58a27015f2df8053ba86cc27d6a3197e745d569f [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.os;
18
Andrei Onea24ec3212019-03-15 17:35:05 +000019import android.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.os.Message;
21
22/** @hide */
23public class AsyncResult
24{
25
26 /*************************** Instance Variables **************************/
27
28 // Expect either exception or result to be null
Andrei Onea24ec3212019-03-15 17:35:05 +000029 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030 public Object userObj;
Andrei Onea24ec3212019-03-15 17:35:05 +000031 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032 public Throwable exception;
Andrei Onea24ec3212019-03-15 17:35:05 +000033 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034 public Object result;
35
36 /***************************** Class Methods *****************************/
37
38 /** Saves and sets m.obj */
Andrei Onea24ec3212019-03-15 17:35:05 +000039 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040 public static AsyncResult
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 */
Andrei Onea24ec3212019-03-15 17:35:05 +000053 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 public static AsyncResult
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 */
Andrei Onea24ec3212019-03-15 17:35:05 +000067 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 public
69 AsyncResult (Object uo, Object r, Throwable ex)
70 {
71 userObj = uo;
72 result = r;
73 exception = ex;
74 }
75}