"Fix camera widget scale-up regression." -> frameworks/base

lockhotness change-id: I69ccfa3a873943ab2e159d15937d5fb13f7acabd

Bug:7439300
Change-Id: I9e9eeae16b4e76d85a8145f3b198c22ad2e923e9
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java b/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
index 7d532bd..b38a9ed 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/CameraWidgetFrame.java
@@ -169,32 +169,45 @@
     }
 
     private void transitionToCamera() {
-        final View child = getChildAt(0);
         if (mTransitioning || mChallengeActive || mDown) return;
-        if (DEBUG) Log.d(TAG, "Transitioning to camera...");
+
         mTransitioning = true;
-        int startWidth = child.getWidth();
-        int startHeight = child.getHeight();
 
-        int finishWidth = getRootView().getWidth();
-        int finishHeight = getRootView().getHeight();
+        final View child = getChildAt(0);
+        final View root = getRootView();
 
-        float scaleX = (float) finishWidth / startWidth;
-        float scaleY = (float) finishHeight / startHeight;
+        final int startWidth = child.getWidth();
+        final int startHeight = child.getHeight();
 
-        float scale = Math.max(scaleX, scaleY);
-        final int screenCenter = getResources().getDisplayMetrics().heightPixels / 2;
+        final int finishWidth = root.getWidth();
+        final int finishHeight = root.getHeight();
+
+        final float scaleX = (float) finishWidth / startWidth;
+        final float scaleY = (float) finishHeight / startHeight;
+        final float scale = Math.round( Math.max(scaleX, scaleY) * 100) / 100f;
 
         final int[] loc = new int[2];
+        root.getLocationInWindow(loc);
+        final int finishCenter = loc[1] + finishHeight / 2;
+
         child.getLocationInWindow(loc);
-        final int childCenter = loc[1] + startHeight / 2;
+        final int startCenter = loc[1] + startHeight / 2;
+
+        if (DEBUG) Log.d(TAG, String.format("Transitioning to camera. " +
+                "(start=%sx%s, finish=%sx%s, scale=%s,%s, startCenter=%s, finishCenter=%s)",
+                startWidth, startHeight,
+                finishWidth, finishHeight,
+                scaleX, scaleY,
+                startCenter, finishCenter));
+
         animate()
             .scaleX(scale)
             .scaleY(scale)
-            .translationY(screenCenter - childCenter)
+            .translationY(finishCenter - startCenter)
             .setDuration(WIDGET_ANIMATION_DURATION)
             .withEndAction(mLaunchCameraRunnable)
             .start();
+
         mCallbacks.onLaunchingCamera();
     }