diff options
author | Steve Block <steveblock@google.com> | 2010-08-11 13:12:37 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-08-19 18:31:57 +0100 |
commit | c43565be90a3119da675571238de20583ca32400 (patch) | |
tree | c60f2c611e8a86863edf47875e72a659c6859f61 /core/java/android/webkit/DeviceOrientationService.java | |
parent | 05691455f59a442f67903b98378e060bbacd260b (diff) | |
download | frameworks_base-c43565be90a3119da675571238de20583ca32400.zip frameworks_base-c43565be90a3119da675571238de20583ca32400.tar.gz frameworks_base-c43565be90a3119da675571238de20583ca32400.tar.bz2 |
Implement DeviceOrientation
This patch provides all of the plumbing but only provides the error event,
used when we fail to connect to the device's sensors. Connection to the
sensors is coming in a later patch.
Change-Id: I322297d70570425b19917712e63e815651ceacc2
Diffstat (limited to 'core/java/android/webkit/DeviceOrientationService.java')
-rwxr-xr-x | core/java/android/webkit/DeviceOrientationService.java | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/core/java/android/webkit/DeviceOrientationService.java b/core/java/android/webkit/DeviceOrientationService.java new file mode 100755 index 0000000..07d3d2f --- /dev/null +++ b/core/java/android/webkit/DeviceOrientationService.java @@ -0,0 +1,81 @@ +/* + * 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. + } +} |