• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.app;
18 
19 import android.os.Bundle;
20 import android.os.IRemoteCallback;
21 import android.os.RemoteException;
22 
23 /**
24  * Base class for synchronous implementations of {@link IUserSwitchObserver}
25  *
26  * @hide
27  */
28 public abstract class SynchronousUserSwitchObserver extends UserSwitchObserver {
29     /**
30      * Calls {@link #onUserSwitching(int)} and notifies {@code reply} by calling
31      * {@link IRemoteCallback#sendResult(Bundle)}.
32      */
33     @Override
onUserSwitching(int newUserId, IRemoteCallback reply)34     public final void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException {
35         try {
36             onUserSwitching(newUserId);
37         } finally {
38             if (reply != null) {
39                 reply.sendResult(null);
40             }
41         }
42     }
43 
44     /**
45      * Synchronous version of {@link IUserSwitchObserver#onUserSwitching(int, IRemoteCallback)}
46      */
onUserSwitching(int newUserId)47     public abstract void onUserSwitching(int newUserId) throws RemoteException;
48 }
49