Merge "Added SynchronousUserSwitchObserver"
This commit is contained in:
committed by
Android (Google) Code Review
commit
79aeb92f4d
48
core/java/android/app/SynchronousUserSwitchObserver.java
Normal file
48
core/java/android/app/SynchronousUserSwitchObserver.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package android.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
|
||||
/**
|
||||
* Base class for synchronous implementations of {@link IUserSwitchObserver}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract class SynchronousUserSwitchObserver extends IUserSwitchObserver.Stub {
|
||||
/**
|
||||
* Calls {@link #onUserSwitching(int)} and notifies {@code reply} by calling
|
||||
* {@link IRemoteCallback#sendResult(Bundle)}.
|
||||
*/
|
||||
@Override
|
||||
public final void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException {
|
||||
try {
|
||||
onUserSwitching(newUserId);
|
||||
} finally {
|
||||
if (reply != null) {
|
||||
reply.sendResult(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous version of {@link IUserSwitchObserver#onUserSwitching(int, IRemoteCallback)}
|
||||
*/
|
||||
public abstract void onUserSwitching(int newUserId) throws RemoteException;
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package com.android.systemui.statusbar.phone;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlarmManager.AlarmClockInfo;
|
||||
import android.app.IUserSwitchObserver;
|
||||
import android.app.StatusBarManager;
|
||||
import android.app.SynchronousUserSwitchObserver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -28,7 +28,6 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Handler;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -378,17 +377,11 @@ public class PhoneStatusBarPolicy implements Callback {
|
||||
}
|
||||
}
|
||||
|
||||
private final IUserSwitchObserver.Stub mUserSwitchListener =
|
||||
new IUserSwitchObserver.Stub() {
|
||||
private final SynchronousUserSwitchObserver mUserSwitchListener =
|
||||
new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
||||
public void onUserSwitching(int newUserId) throws RemoteException {
|
||||
mUserInfoController.reloadUserInfo();
|
||||
if (reply != null) {
|
||||
try {
|
||||
reply.sendResult(null);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,11 +43,11 @@ import android.app.ActivityManagerNative;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.IUserSwitchObserver;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.SynchronousUserSwitchObserver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
@@ -80,7 +80,6 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.Message;
|
||||
import android.os.Parcel;
|
||||
import android.os.Process;
|
||||
@@ -788,18 +787,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
int userId = 0;
|
||||
try {
|
||||
ActivityManagerNative.getDefault().registerUserSwitchObserver(
|
||||
new IUserSwitchObserver.Stub() {
|
||||
new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
||||
public void onUserSwitching(int newUserId)
|
||||
throws RemoteException {
|
||||
synchronized(mMethodMap) {
|
||||
switchUserLocked(newUserId);
|
||||
}
|
||||
if (reply != null) {
|
||||
try {
|
||||
reply.sendResult(null);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.IUserSwitchObserver;
|
||||
import android.app.SynchronousUserSwitchObserver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
@@ -45,7 +45,6 @@ import android.content.pm.UserInfo;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
@@ -102,18 +101,12 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
|
||||
int userId = UserHandle.USER_SYSTEM;
|
||||
try {
|
||||
ActivityManagerNative.getDefault().registerUserSwitchObserver(
|
||||
new IUserSwitchObserver.Stub() {
|
||||
new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
||||
public void onUserSwitching(int newUserId) throws RemoteException {
|
||||
synchronized(mSpellCheckerMap) {
|
||||
switchUserLocked(newUserId);
|
||||
}
|
||||
if (reply != null) {
|
||||
try {
|
||||
reply.sendResult(null);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,11 @@ package com.android.server.fingerprint;
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||
import android.app.ActivityManager.RunningTaskInfo;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.IUserSwitchObserver;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.SynchronousUserSwitchObserver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -38,7 +37,6 @@ import android.os.DeadObjectException;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SELinux;
|
||||
@@ -1134,17 +1132,11 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
||||
private void listenForUserSwitches() {
|
||||
try {
|
||||
ActivityManagerNative.getDefault().registerUserSwitchObserver(
|
||||
new IUserSwitchObserver.Stub() {
|
||||
new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
||||
public void onUserSwitching(int newUserId) throws RemoteException {
|
||||
mHandler.obtainMessage(MSG_USER_SWITCHING, newUserId, 0 /* unused */)
|
||||
.sendToTarget();
|
||||
if (reply != null) {
|
||||
try {
|
||||
reply.sendResult(null);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUserSwitchComplete(int newUserId) throws RemoteException {
|
||||
|
||||
Reference in New Issue
Block a user