Loading core/java/android/webkit/DeviceOrientationManager.java +13 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package android.webkit; /** * This class is simply a container for the methods used to configure WebKit's * mock DeviceOrientationClient for use in LayoutTests. * This class is simply a container for the methods used to implement DeviceOrientation, * including the mock DeviceOrientationClient for use in LayoutTests. * * This could be part of WebViewCore, but have moved it to its own class to * avoid bloat there. Loading @@ -26,6 +26,7 @@ package android.webkit; */ public final class DeviceOrientationManager { private WebViewCore mWebViewCore; private DeviceOrientationService mService; public DeviceOrientationManager(WebViewCore webViewCore) { mWebViewCore = webViewCore; Loading @@ -50,9 +51,19 @@ public final class DeviceOrientationManager { canProvideGamma, gamma); } public void onOrientationChange(Double alpha, Double beta, Double gamma) { nativeOnOrientationChange(mWebViewCore, alpha != null, alpha != null ? alpha.doubleValue() : 0.0, beta != null, beta != null ? beta.doubleValue() : 0.0, gamma != null, gamma != null ? gamma.doubleValue() : 0.0); } // Native functions private static native void nativeUseMock(WebViewCore webViewCore); private static native void nativeSetMockOrientation(WebViewCore webViewCore, boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma); private static native void nativeOnOrientationChange(WebViewCore webViewCore, boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma); } core/java/android/webkit/DeviceOrientationService.java 0 → 100755 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.webkit; import android.os.Handler; import android.webkit.DeviceOrientationManager; import java.lang.Runnable; final class DeviceOrientationService { private DeviceOrientationManager mManager; private boolean mIsRunning; private Handler mHandler; public DeviceOrientationService(DeviceOrientationManager manager) { mManager = manager; assert(mManager != null); } public void start() { mIsRunning = true; registerForSensors(); } public void stop() { mIsRunning = false; unregisterFromSensors(); } public void suspend() { if (mIsRunning) { unregisterFromSensors(); } } public void resume() { if (mIsRunning) { registerForSensors(); } } private void sendErrorEvent() { assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); if (mHandler == null) { mHandler = new Handler(); } mHandler.post(new Runnable() { @Override public void run() { assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); if (mIsRunning) { mManager.onOrientationChange(null, null, null); } } }); } private void registerForSensors() { // Send the error event for now. // FIXME: Implement. sendErrorEvent(); } private void unregisterFromSensors() { // FIXME: Implement. } } core/java/android/webkit/WebViewCore.java +9 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.KeyEvent; import android.view.SurfaceView; import android.view.View; import android.webkit.DeviceOrientationManager; import android.webkit.DeviceOrientationService; import java.util.ArrayList; import java.util.Collection; Loading Loading @@ -118,6 +119,7 @@ final class WebViewCore { private int mWebkitScrollY = 0; private DeviceOrientationManager mDeviceOrientationManager = new DeviceOrientationManager(this); private DeviceOrientationService mDeviceOrientationService; // The thread name used to identify the WebCore thread and for use in // debugging other classes that require operation within the WebCore thread. Loading Loading @@ -2500,6 +2502,13 @@ final class WebViewCore { canProvideGamma, gamma); } protected DeviceOrientationService getDeviceOrientationService() { if (mDeviceOrientationService == null) { mDeviceOrientationService = new DeviceOrientationService(mDeviceOrientationManager); } return mDeviceOrientationService; } private native void nativePause(); private native void nativeResume(); private native void nativeFreeMemory(); Loading Loading
core/java/android/webkit/DeviceOrientationManager.java +13 −2 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package android.webkit; /** * This class is simply a container for the methods used to configure WebKit's * mock DeviceOrientationClient for use in LayoutTests. * This class is simply a container for the methods used to implement DeviceOrientation, * including the mock DeviceOrientationClient for use in LayoutTests. * * This could be part of WebViewCore, but have moved it to its own class to * avoid bloat there. Loading @@ -26,6 +26,7 @@ package android.webkit; */ public final class DeviceOrientationManager { private WebViewCore mWebViewCore; private DeviceOrientationService mService; public DeviceOrientationManager(WebViewCore webViewCore) { mWebViewCore = webViewCore; Loading @@ -50,9 +51,19 @@ public final class DeviceOrientationManager { canProvideGamma, gamma); } public void onOrientationChange(Double alpha, Double beta, Double gamma) { nativeOnOrientationChange(mWebViewCore, alpha != null, alpha != null ? alpha.doubleValue() : 0.0, beta != null, beta != null ? beta.doubleValue() : 0.0, gamma != null, gamma != null ? gamma.doubleValue() : 0.0); } // Native functions private static native void nativeUseMock(WebViewCore webViewCore); private static native void nativeSetMockOrientation(WebViewCore webViewCore, boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma); private static native void nativeOnOrientationChange(WebViewCore webViewCore, boolean canProvideAlpha, double alpha, boolean canProvideBeta, double beta, boolean canProvideGamma, double gamma); }
core/java/android/webkit/DeviceOrientationService.java 0 → 100755 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.webkit; import android.os.Handler; import android.webkit.DeviceOrientationManager; import java.lang.Runnable; final class DeviceOrientationService { private DeviceOrientationManager mManager; private boolean mIsRunning; private Handler mHandler; public DeviceOrientationService(DeviceOrientationManager manager) { mManager = manager; assert(mManager != null); } public void start() { mIsRunning = true; registerForSensors(); } public void stop() { mIsRunning = false; unregisterFromSensors(); } public void suspend() { if (mIsRunning) { unregisterFromSensors(); } } public void resume() { if (mIsRunning) { registerForSensors(); } } private void sendErrorEvent() { assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); if (mHandler == null) { mHandler = new Handler(); } mHandler.post(new Runnable() { @Override public void run() { assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName()); if (mIsRunning) { mManager.onOrientationChange(null, null, null); } } }); } private void registerForSensors() { // Send the error event for now. // FIXME: Implement. sendErrorEvent(); } private void unregisterFromSensors() { // FIXME: Implement. } }
core/java/android/webkit/WebViewCore.java +9 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.KeyEvent; import android.view.SurfaceView; import android.view.View; import android.webkit.DeviceOrientationManager; import android.webkit.DeviceOrientationService; import java.util.ArrayList; import java.util.Collection; Loading Loading @@ -118,6 +119,7 @@ final class WebViewCore { private int mWebkitScrollY = 0; private DeviceOrientationManager mDeviceOrientationManager = new DeviceOrientationManager(this); private DeviceOrientationService mDeviceOrientationService; // The thread name used to identify the WebCore thread and for use in // debugging other classes that require operation within the WebCore thread. Loading Loading @@ -2500,6 +2502,13 @@ final class WebViewCore { canProvideGamma, gamma); } protected DeviceOrientationService getDeviceOrientationService() { if (mDeviceOrientationService == null) { mDeviceOrientationService = new DeviceOrientationService(mDeviceOrientationManager); } return mDeviceOrientationService; } private native void nativePause(); private native void nativeResume(); private native void nativeFreeMemory(); Loading