From b81b1447d2cfa9dc5bcc02c8a1b7193400a97ab6 Mon Sep 17 00:00:00 2001 From: Cyril Mottier Date: Sat, 6 Feb 2010 00:36:40 +0100 Subject: Default RotateDrawable's pivot set to (50%, 50%) In order to define the pivot in an XML-instanciated RotateDrawable, android:pivotX and android:pivotY had to be set in your XML. Forgetting to set those attributes ended up in a NullPointerException (tv = null) that were caught by the Resources.getDrawable() method (caught as an Exception). As a result a not-very-accurate message was logged: "Resource not found ...". Defining a default pivot value seems like a great fix. Some other fixes would be to modify the documentation or notify the user with a better explanation than "Resource not found ...". --- .../android/graphics/drawable/RotateDrawable.java | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java index c4a7822..2083e05 100644 --- a/graphics/java/android/graphics/drawable/RotateDrawable.java +++ b/graphics/java/android/graphics/drawable/RotateDrawable.java @@ -204,13 +204,27 @@ public class RotateDrawable extends Drawable implements Drawable.Callback { com.android.internal.R.styleable.RotateDrawable_visible); TypedValue tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotX); - boolean pivotXRel = tv.type == TypedValue.TYPE_FRACTION; - float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + boolean pivotXRel; + float pivotX; + if (tv == null) { + pivotXRel = true; + pivotX = 0.5f; + } else { + pivotXRel = tv.type == TypedValue.TYPE_FRACTION; + pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + } tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotY); - boolean pivotYRel = tv.type == TypedValue.TYPE_FRACTION; - float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); - + boolean pivotYRel; + float pivotY; + if (tv == null) { + pivotYRel = true; + pivotY = 0.5f; + } else { + pivotYRel = tv.type == TypedValue.TYPE_FRACTION; + pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + } + float fromDegrees = a.getFloat( com.android.internal.R.styleable.RotateDrawable_fromDegrees, 0.0f); float toDegrees = a.getFloat( -- cgit v1.1 From 27f3de6bac93140452ce131cbbd8c6df33e25a94 Mon Sep 17 00:00:00 2001 From: Chander S Pechetty Date: Wed, 10 Feb 2010 22:14:00 +0530 Subject: Fixs the incorrect message for SecurityException when injecting a Key, Pointer and Trackball events into the UI across applications, the corresponding methods throw SecurityException with incorrect permission message. INJECT EVENT permission should be INJECT_EVENTS --- services/java/com/android/server/WindowManagerService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 327cd72..b87ad32 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -5285,7 +5285,7 @@ public class WindowManagerService extends IWindowManager.Stub switch (result) { case INJECT_NO_PERMISSION: throw new SecurityException( - "Injecting to another application requires INJECT_EVENT permission"); + "Injecting to another application requires INJECT_EVENTS permission"); case INJECT_SUCCEEDED: return true; } @@ -5313,7 +5313,7 @@ public class WindowManagerService extends IWindowManager.Stub switch (result) { case INJECT_NO_PERMISSION: throw new SecurityException( - "Injecting to another application requires INJECT_EVENT permission"); + "Injecting to another application requires INJECT_EVENTS permission"); case INJECT_SUCCEEDED: return true; } @@ -5341,7 +5341,7 @@ public class WindowManagerService extends IWindowManager.Stub switch (result) { case INJECT_NO_PERMISSION: throw new SecurityException( - "Injecting to another application requires INJECT_EVENT permission"); + "Injecting to another application requires INJECT_EVENTS permission"); case INJECT_SUCCEEDED: return true; } -- cgit v1.1