summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2013-03-22 16:11:08 -0700
committerJim Miller <jaggies@google.com>2013-04-26 14:34:21 -0700
commitc0b676dcc23baedb12946c3470d9fa9b02cb39e0 (patch)
treea0050fe524ddbbdd56bd81ea7c67b3a7dd248c69 /policy
parent69fd7bd660a3a2d1b4c260eee9bbc6868b47d0c4 (diff)
downloadframeworks_base-c0b676dcc23baedb12946c3470d9fa9b02cb39e0.zip
frameworks_base-c0b676dcc23baedb12946c3470d9fa9b02cb39e0.tar.gz
frameworks_base-c0b676dcc23baedb12946c3470d9fa9b02cb39e0.tar.bz2
Add keyguard background scrim and protection around keyguard APIs
With this change, the system process will put up a scrim in the event keyguard crashes to protect underlying content. It also adds permission checks to prevent unathorized access through the binder APIs. Cleaned up KeyguardTestActivity to build separately. Removed unused resources. Change-Id: I9e370c6bfb7dca68eae9eae304c815fb84a753d2
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java11
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java58
2 files changed, 59 insertions, 10 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 63584ac..41efaa5 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1722,7 +1722,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
}
mKeyguard = win;
- hideKeyguardScrim();
break;
case TYPE_KEYGUARD_SCRIM:
if (mKeyguardScrim != null) {
@@ -1742,7 +1741,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} else if (mKeyguard == win) {
Log.v(TAG, "Removing keyguard window (Did it crash?)");
mKeyguard = null;
- showKeyguardScrimLw();
+ mKeyguardDelegate.showScrim();
} else if (mKeyguardScrim == win) {
Log.v(TAG, "Removing keyguard scrim");
mKeyguardScrim = null;
@@ -1751,14 +1750,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
- private void showKeyguardScrimLw() {
- Log.v(TAG, "*** SHOWING KEYGUARD SCRIM ***");
- }
-
- private void hideKeyguardScrim() {
- Log.v(TAG, "*** HIDING KEYGUARD SCRIM ***");
- }
-
static final boolean PRINT_ANIM = false;
/** {@inheritDoc} */
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
index bf18b99..2bb94be 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardServiceDelegate.java
@@ -4,12 +4,17 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.ActivityInfo;
+import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import android.util.Slog;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
import android.view.WindowManagerPolicy.OnKeyguardExitResult;
import com.android.internal.policy.IKeyguardExitCallback;
@@ -29,6 +34,7 @@ public class KeyguardServiceDelegate {
private static final String TAG = "KeyguardServiceDelegate";
private static final boolean DEBUG = true;
protected KeyguardServiceWrapper mKeyguardService;
+ private View mScrim; // shown if keyguard crashes
private KeyguardState mKeyguardState = new KeyguardState();
/* package */ static final class KeyguardState {
@@ -64,6 +70,7 @@ public class KeyguardServiceDelegate {
if (mShowListener != null) {
mShowListener.onShown(windowToken);
}
+ hideScrim();
}
};
@@ -87,6 +94,7 @@ public class KeyguardServiceDelegate {
public KeyguardServiceDelegate(Context context, LockPatternUtils lockPatternUtils) {
Intent intent = new Intent();
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
+ mScrim = createScrim(context);
if (!context.bindServiceAsUser(intent, mKeyguardConnection,
Context.BIND_AUTO_CREATE, UserHandle.OWNER)) {
if (DEBUG) Log.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
@@ -102,7 +110,10 @@ public class KeyguardServiceDelegate {
mKeyguardService = new KeyguardServiceWrapper(
IKeyguardService.Stub.asInterface(service));
if (mKeyguardState.systemIsReady) {
+ // If the system is ready, it means keyguard crashed and restarted.
mKeyguardService.onSystemReady();
+ // This is used to hide the scrim once keyguard displays.
+ mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(null));
}
}
@@ -257,4 +268,51 @@ public class KeyguardServiceDelegate {
mKeyguardState.currentUser = newUserId;
}
+ private static final View createScrim(Context context) {
+ View view = new View(context);
+
+ int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
+ | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
+ | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
+ ;
+
+ final int stretch = ViewGroup.LayoutParams.MATCH_PARENT;
+ final int type = WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM;
+ WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ stretch, stretch, type, flags, PixelFormat.TRANSLUCENT);
+ lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
+ lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
+ lp.setTitle("KeyguardScrim");
+ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ wm.addView(view, lp);
+ view.setVisibility(View.GONE);
+ // Disable pretty much everything in statusbar until keyguard comes back and we know
+ // the state of the world.
+ view.setSystemUiVisibility(View.STATUS_BAR_DISABLE_HOME
+ | View.STATUS_BAR_DISABLE_BACK
+ | View.STATUS_BAR_DISABLE_RECENT
+ | View.STATUS_BAR_DISABLE_EXPAND
+ | View.STATUS_BAR_DISABLE_SEARCH);
+ return view;
+ }
+
+ public void showScrim() {
+ mScrim.post(new Runnable() {
+ @Override
+ public void run() {
+ mScrim.setVisibility(View.VISIBLE);
+ }
+ });
+ }
+
+ public void hideScrim() {
+ mScrim.post(new Runnable() {
+ @Override
+ public void run() {
+ mScrim.setVisibility(View.GONE);
+ }
+ });
+ }
+
}