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 | |
Artur Satayev | afdb23a | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
| 21 | /** @hide */ |
| 22 | public class AsyncResult |
| 23 | { |
| 24 | |
| 25 | /*************************** Instance Variables **************************/ |
| 26 | |
| 27 | // Expect either exception or result to be null |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 28 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | public Object userObj; |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 30 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | public Throwable exception; |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 32 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | public Object result; |
| 34 | |
| 35 | /***************************** Class Methods *****************************/ |
| 36 | |
| 37 | /** Saves and sets m.obj */ |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 38 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | public static AsyncResult |
| 40 | forMessage(Message m, Object r, Throwable ex) |
| 41 | { |
| 42 | AsyncResult ret; |
| 43 | |
| 44 | ret = new AsyncResult (m.obj, r, ex); |
| 45 | |
| 46 | m.obj = ret; |
| 47 | |
| 48 | return ret; |
| 49 | } |
| 50 | |
| 51 | /** Saves and sets m.obj */ |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 52 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | public static AsyncResult |
| 54 | forMessage(Message m) |
| 55 | { |
| 56 | AsyncResult ret; |
| 57 | |
| 58 | ret = new AsyncResult (m.obj, null, null); |
| 59 | |
| 60 | m.obj = ret; |
| 61 | |
| 62 | return ret; |
| 63 | } |
| 64 | |
| 65 | /** please note, this sets m.obj to be this */ |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 66 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | public |
| 68 | AsyncResult (Object uo, Object r, Throwable ex) |
| 69 | { |
| 70 | userObj = uo; |
| 71 | result = r; |
| 72 | exception = ex; |
| 73 | } |
| 74 | } |