Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbde425e authored by Patrick Scott's avatar Patrick Scott
Browse files

Use the Display orientation rather than the accelerometer.

Register to receive configuration changes and query the Display rotation as that
will reflect both device orientation and an open keyboard.

Bug: 2219138
Change-Id: Ibd6119ae0c7d473e1a9ede3af24bb4b584c9db71
parent 1c9f1c63
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@
package android.webkit;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -31,7 +34,7 @@ import android.provider.OpenableColumns;
import android.util.Log;
import android.util.TypedValue;
import android.view.Surface;
import android.view.WindowOrientationListener;
import android.view.WindowManager;

import junit.framework.Assert;

@@ -73,8 +76,10 @@ class BrowserFrame extends Handler {
    // Attached Javascript interfaces
    private Map<String, Object> mJSInterfaceMap;

    // WindowManager to obtain the Display configuration.
    private WindowManager mWindowManager;
    // Orientation listener
    private WindowOrientationListener mOrientationListener;
    private BroadcastReceiver mOrientationListener;

    // message ids
    // a message posted when a frame loading is completed
@@ -153,9 +158,15 @@ class BrowserFrame extends Handler {
            Log.v(LOGTAG, "BrowserFrame constructor: this=" + this);
        }

        mOrientationListener = new WindowOrientationListener(context) {
        mWindowManager = (WindowManager) context.getSystemService(
                Context.WINDOW_SERVICE);
        mOrientationListener = new BroadcastReceiver() {
            @Override
                public void onOrientationChanged(int orientation) {
            public void onReceive(Context context, Intent intent) {
                if (Intent.ACTION_CONFIGURATION_CHANGED.equals(
                        intent.getAction())) {
                    int orientation =
                            mWindowManager.getDefaultDisplay().getOrientation();
                    switch (orientation) {
                        case Surface.ROTATION_90:
                            orientation = 90;
@@ -174,9 +185,12 @@ class BrowserFrame extends Handler {
                    }
                    sendMessage(
                            obtainMessage(ORIENTATION_CHANGED, orientation, 0));

                }
            }
        };
        mOrientationListener.enable();
        context.registerReceiver(mOrientationListener,
                new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
    }

    /**
@@ -383,7 +397,7 @@ class BrowserFrame extends Handler {
     * Destroy all native components of the BrowserFrame.
     */
    public void destroy() {
        mOrientationListener.disable();
        mContext.unregisterReceiver(mOrientationListener);
        nativeDestroyFrame();
        mBlockMessages = true;
        removeCallbacksAndMessages(null);