The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 29 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | public Object userObj; |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 31 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | public Throwable exception; |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 33 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | public Object result; |
| 35 | |
| 36 | /***************************** Class Methods *****************************/ |
| 37 | |
| 38 | /** Saves and sets m.obj */ |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 39 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | 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 Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 53 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | 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 Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 67 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | public |
| 69 | AsyncResult (Object uo, Object r, Throwable ex) |
| 70 | { |
| 71 | userObj = uo; |
| 72 | result = r; |
| 73 | exception = ex; |
| 74 | } |
| 75 | } |