Merge "Fix permissions on WindowManagerService.showAssistant()" into klp-dev
This commit is contained in:
@ -248,12 +248,6 @@ interface IWindowManager
|
||||
*/
|
||||
boolean isSafeModeEnabled();
|
||||
|
||||
/**
|
||||
* Tell keyguard to show the assistant (Intent.ACTION_ASSIST) after asking for the user's
|
||||
* credentials.
|
||||
*/
|
||||
void showAssistant();
|
||||
|
||||
/**
|
||||
* Sets the display magnification callbacks. These callbacks notify
|
||||
* the client for contextual changes related to display magnification.
|
||||
|
@ -1175,12 +1175,6 @@ public interface WindowManagerPolicy {
|
||||
*/
|
||||
public void dump(String prefix, PrintWriter writer, String[] args);
|
||||
|
||||
/**
|
||||
* Ask keyguard to invoke the assist intent after dismissing keyguard
|
||||
* {@link android.content.Intent#ACTION_ASSIST}
|
||||
*/
|
||||
public void showAssistant();
|
||||
|
||||
/**
|
||||
* Returns whether a given window type can be magnified.
|
||||
*
|
||||
|
@ -46,6 +46,7 @@ import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener;
|
||||
import com.android.systemui.statusbar.BaseStatusBar;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.StatusBarPanel;
|
||||
import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
|
||||
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
||||
|
||||
public class SearchPanelView extends FrameLayout implements
|
||||
@ -88,11 +89,7 @@ public class SearchPanelView extends FrameLayout implements
|
||||
|
||||
if (isKeyguardShowing) {
|
||||
// Have keyguard show the bouncer and launch the activity if the user succeeds.
|
||||
try {
|
||||
mWm.showAssistant();
|
||||
} catch (RemoteException e) {
|
||||
// too bad, so sad...
|
||||
}
|
||||
KeyguardTouchDelegate.getInstance(getContext()).showAssistant();
|
||||
onAnimationStarted();
|
||||
} else {
|
||||
// Otherwise, keyguard isn't showing so launch it from here.
|
||||
|
@ -23,7 +23,7 @@ import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.internal.policy.IKeyguardExitCallback;
|
||||
@ -41,7 +41,9 @@ public class KeyguardTouchDelegate {
|
||||
static final String KEYGUARD_PACKAGE = "com.android.keyguard";
|
||||
static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
|
||||
|
||||
IKeyguardService mService;
|
||||
private static KeyguardTouchDelegate sInstance;
|
||||
|
||||
private volatile IKeyguardService mService;
|
||||
|
||||
protected static final boolean DEBUG = false;
|
||||
protected static final String TAG = "KeyguardTouchDelegate";
|
||||
@ -49,83 +51,121 @@ public class KeyguardTouchDelegate {
|
||||
private final ServiceConnection mKeyguardConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.v(TAG, "Connected to keyguard");
|
||||
Slog.v(TAG, "Connected to keyguard");
|
||||
mService = IKeyguardService.Stub.asInterface(service);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
Log.v(TAG, "Disconnected from keyguard");
|
||||
Slog.v(TAG, "Disconnected from keyguard");
|
||||
mService = null;
|
||||
sInstance = null; // force reconnection if this goes away
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public KeyguardTouchDelegate(Context context) {
|
||||
private KeyguardTouchDelegate(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
|
||||
if (!context.bindServiceAsUser(intent, mKeyguardConnection,
|
||||
Context.BIND_AUTO_CREATE, UserHandle.OWNER)) {
|
||||
if (DEBUG) Log.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
|
||||
if (DEBUG) Slog.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
|
||||
} else {
|
||||
if (DEBUG) Log.v(TAG, "*** Keyguard started");
|
||||
if (DEBUG) Slog.v(TAG, "*** Keyguard started");
|
||||
}
|
||||
}
|
||||
|
||||
public static KeyguardTouchDelegate getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new KeyguardTouchDelegate(context);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
boolean secure = false;
|
||||
if (mService != null) {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
secure = mService.isSecure();
|
||||
return service.isSecure();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling keyguard.isSecure()!", e);
|
||||
Slog.e(TAG, "RemoteException calling keyguard.isSecure()!", e);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "isSecure(): NO SERVICE!");
|
||||
Slog.w(TAG, "isSecure(): NO SERVICE!");
|
||||
}
|
||||
return secure;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean dispatch(MotionEvent event) {
|
||||
if (mService != null) {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
mService.dispatch(event);
|
||||
service.dispatch(event);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
// What to do?
|
||||
Log.e(TAG, "RemoteException sending event to keyguard!", e);
|
||||
return false;
|
||||
Slog.e(TAG, "RemoteException sending event to keyguard!", e);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
Log.w(TAG, "dispatch(event): NO SERVICE!");
|
||||
Slog.w(TAG, "dispatch(event): NO SERVICE!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInputRestricted() {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isInputRestricted();
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG , "Remote Exception", e);
|
||||
}
|
||||
} else {
|
||||
Slog.w(TAG, "isInputRestricted(): NO SERVICE!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isShowingAndNotHidden() {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isShowingAndNotHidden();
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG , "Remote Exception", e);
|
||||
}
|
||||
} else {
|
||||
Slog.w(TAG, "isShowingAndNotHidden(): NO SERVICE!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void showAssistant() {
|
||||
if (mService != null) {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
mService.showAssistant();
|
||||
service.showAssistant();
|
||||
} catch (RemoteException e) {
|
||||
// What to do?
|
||||
Log.e(TAG, "RemoteException launching assistant!", e);
|
||||
Slog.e(TAG, "RemoteException launching assistant!", e);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "dispatch(event): NO SERVICE!");
|
||||
Slog.w(TAG, "showAssistant(event): NO SERVICE!");
|
||||
}
|
||||
}
|
||||
|
||||
public void launchCamera() {
|
||||
if (mService != null) {
|
||||
final IKeyguardService service = mService;
|
||||
if (service != null) {
|
||||
try {
|
||||
mService.launchCamera();
|
||||
service.launchCamera();
|
||||
} catch (RemoteException e) {
|
||||
// What to do?
|
||||
Log.e(TAG, "RemoteException launching camera!", e);
|
||||
Slog.e(TAG, "RemoteException launching camera!", e);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "dispatch(event): NO SERVICE!");
|
||||
Slog.w(TAG, "dispatch(event): NO SERVICE!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@ public class NavigationBarView extends LinearLayout {
|
||||
|
||||
// used to disable the camera icon in navbar when disabled by DPM
|
||||
private boolean mCameraDisabledByDpm;
|
||||
KeyguardTouchDelegate mKeyguardTouchDelegate;
|
||||
|
||||
private final OnTouchListener mCameraTouchListener = new OnTouchListener() {
|
||||
@Override
|
||||
@ -112,7 +111,7 @@ public class NavigationBarView extends LinearLayout {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return mKeyguardTouchDelegate.dispatch(event);
|
||||
return KeyguardTouchDelegate.getInstance(getContext()).dispatch(event);
|
||||
}
|
||||
};
|
||||
|
||||
@ -155,8 +154,6 @@ public class NavigationBarView extends LinearLayout {
|
||||
|
||||
mBarTransitions = new NavigationBarTransitions(this);
|
||||
|
||||
mKeyguardTouchDelegate = new KeyguardTouchDelegate(mContext);
|
||||
|
||||
mCameraDisabledByDpm = isCameraDisabledByDpm();
|
||||
watchForDevicePolicyChanges();
|
||||
}
|
||||
@ -341,7 +338,7 @@ public class NavigationBarView extends LinearLayout {
|
||||
final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
|
||||
final boolean disabledBecauseKeyguardSecure =
|
||||
(disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0
|
||||
&& mKeyguardTouchDelegate.isSecure();
|
||||
&& KeyguardTouchDelegate.getInstance(getContext()).isSecure();
|
||||
return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure;
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Can't get userId", e);
|
||||
@ -426,9 +423,9 @@ public class NavigationBarView extends LinearLayout {
|
||||
|
||||
protected void launchForAccessibilityClick(View v) {
|
||||
if (v == getCameraButton()) {
|
||||
mKeyguardTouchDelegate.launchCamera();
|
||||
KeyguardTouchDelegate.getInstance(getContext()).launchCamera();
|
||||
} else if (v == getSearchLight()) {
|
||||
mKeyguardTouchDelegate.showAssistant();
|
||||
KeyguardTouchDelegate.getInstance(getContext()).showAssistant();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5126,11 +5126,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
setLastInputMethodWindowLw(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAssistant() {
|
||||
mKeyguardDelegate.showAssistant();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMagnifyWindow(int windowType) {
|
||||
switch (windowType) {
|
||||
|
@ -181,11 +181,7 @@ public class KeyguardServiceWrapper implements IKeyguardService {
|
||||
}
|
||||
|
||||
public void showAssistant() {
|
||||
try {
|
||||
mService.showAssistant();
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG , "Remote Exception", e);
|
||||
}
|
||||
// Not used by PhoneWindowManager
|
||||
}
|
||||
|
||||
public void dispatch(MotionEvent event) {
|
||||
|
@ -10142,16 +10142,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return mSafeMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAssistant() {
|
||||
// TODO: What permission?
|
||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
mPolicy.showAssistant();
|
||||
}
|
||||
|
||||
void dumpPolicyLocked(PrintWriter pw, String[] args, boolean dumpAll) {
|
||||
pw.println("WINDOW MANAGER POLICY STATE (dumpsys window policy)");
|
||||
mPolicy.dump(" ", pw, args);
|
||||
|
@ -457,11 +457,6 @@ public class IWindowManagerImpl implements IWindowManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAssistant() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder getFocusedWindowToken() {
|
||||
// TODO Auto-generated method stub
|
||||
|
Reference in New Issue
Block a user