16005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov/* 26005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Copyright (C) 2015 The Android Open Source Project 36005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * 46005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Licensed under the Apache License, Version 2.0 (the "License"); 56005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * you may not use this file except in compliance with the License. 66005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * You may obtain a copy of the License at 76005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * 86005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * http://www.apache.org/licenses/LICENSE-2.0 96005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * 106005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Unless required by applicable law or agreed to in writing, software 116005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * distributed under the License is distributed on an "AS IS" BASIS, 126005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * See the License for the specific language governing permissions and 146005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * limitations under the License 156005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov */ 166005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov 176005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolovpackage android.app; 186005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov 196005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolovimport android.os.Bundle; 206005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolovimport android.os.IRemoteCallback; 216005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolovimport android.os.RemoteException; 226005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov 236005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov/** 246005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Base class for synchronous implementations of {@link IUserSwitchObserver} 256005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * 266005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * @hide 276005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov */ 282c4522cc1bf3a3d0178688427a33b860ddfe4bbaSudheer Shankapublic abstract class SynchronousUserSwitchObserver extends UserSwitchObserver { 296005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov /** 306005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Calls {@link #onUserSwitching(int)} and notifies {@code reply} by calling 316005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * {@link IRemoteCallback#sendResult(Bundle)}. 326005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov */ 336005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov @Override 346005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov public final void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { 356005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov try { 366005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov onUserSwitching(newUserId); 376005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov } finally { 386005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov if (reply != null) { 396005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov reply.sendResult(null); 406005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov } 416005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov } 426005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov } 436005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov 446005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov /** 456005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov * Synchronous version of {@link IUserSwitchObserver#onUserSwitching(int, IRemoteCallback)} 466005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov */ 476005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov public abstract void onUserSwitching(int newUserId) throws RemoteException; 486005b3f87b063ee7ab7e8877a6a8c90b480f3341Fyodor Kupolov} 49