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

Commit a5334e70 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Create OneHandedModeGesturalOverlay for navigation_bar_gesture_height"

parents 6412ec69 daa9a407
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,4 +44,7 @@
    <install-in-user-type package="com.android.internal.systemui.navbar.twobutton">
        <install-in user-type="FULL" />
    </install-in-user-type>
    <install-in-user-type package="com.android.internal.systemui.onehanded.gestural">
        <install-in user-type="FULL" />
    </install-in-user-type>
</config>
+54 −1
Original line number Diff line number Diff line
@@ -16,16 +16,23 @@

package com.android.systemui.onehanded;

import static android.os.UserHandle.USER_CURRENT;
import static android.view.Display.DEFAULT_DISPLAY;

import android.content.Context;
import android.content.om.IOverlayManager;
import android.content.om.OverlayInfo;
import android.database.ContentObserver;
import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;

import androidx.annotation.VisibleForTesting;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.Dependency;
@@ -47,10 +54,13 @@ import javax.inject.Singleton;
@Singleton
public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dumpable {
    private static final String TAG = "OneHandedUI";
    private static final String ONE_HANDED_MODE_GESTURAL_OVERLAY =
            "com.android.internal.systemui.onehanded.gestural";

    private final OneHandedManagerImpl mOneHandedManager;
    private final CommandQueue mCommandQueue;
    private final Handler mMainHandler = new Handler(Looper.getMainLooper());
    private final IOverlayManager mOverlayManager;
    private final OneHandedSettingsUtil mSettingUtil;
    private final OneHandedTimeoutHandler mTimeoutHandler;
    private final ScreenLifecycle mScreenLifecycle;
@@ -66,6 +76,8 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum
            if (mOneHandedManager != null) {
                mOneHandedManager.setOneHandedEnabled(enabled);
            }

            setEnabledGesturalOverlay(enabled);
        }
    };

@@ -132,6 +144,8 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum
        mSettingUtil = settingsUtil;
        mTimeoutHandler = OneHandedTimeoutHandler.get();
        mScreenLifecycle = screenLifecycle;
        mOverlayManager = IOverlayManager.Stub.asInterface(
                ServiceManager.getService(Context.OVERLAY_SERVICE));
    }

    @Override
@@ -144,9 +158,26 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum
        setupScreenObserver();
        setupSettingObservers();
        setupTimeoutListener();
        setupGesturalOverlay();
        updateSettings();
    }

    private void setupGesturalOverlay() {
        if (!OneHandedSettingsUtil.getSettingsOneHandedModeEnabled(mContext.getContentResolver())) {
            return;
        }

        OverlayInfo info = null;
        try {
            info = mOverlayManager.getOverlayInfo(ONE_HANDED_MODE_GESTURAL_OVERLAY, USER_CURRENT);
        } catch (RemoteException e) { /* Do nothing */ }

        if (info != null && !info.isEnabled()) {
            // Enable the default gestural one handed overlay.
            setEnabledGesturalOverlay(true);
        }
    }

    private void setupTimeoutListener() {
        mTimeoutHandler.registerTimeoutListener(timeoutTime -> {
            OneHandedEvents.writeEvent(OneHandedEvents.EVENT_ONE_HANDED_TRIGGER_TIMEOUT_OUT);
@@ -218,6 +249,15 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum
        }
    }

    @VisibleForTesting
    private void setEnabledGesturalOverlay(boolean enabled) {
        try {
            mOverlayManager.setEnabled(ONE_HANDED_MODE_GESTURAL_OVERLAY, enabled, USER_CURRENT);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Trigger one handed more
     */
@@ -252,5 +292,18 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum
        if (mSettingUtil != null) {
            mSettingUtil.dump(pw, innerPrefix, mContext.getContentResolver());
        }

        if (mOverlayManager != null) {
            OverlayInfo info = null;
            try {
                info = mOverlayManager.getOverlayInfo(ONE_HANDED_MODE_GESTURAL_OVERLAY,
                        USER_CURRENT);
            } catch (RemoteException e) { /* Do nothing */ }

            if (info != null && !info.isEnabled()) {
                pw.print(innerPrefix + "OverlayInfo=");
                pw.println(info);
            }
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ LOCAL_REQUIRED_MODULES := \
	NavigationBarModeGesturalOverlayNarrowBack \
	NavigationBarModeGesturalOverlayWideBack \
	NavigationBarModeGesturalOverlayExtraWideBack \
        OneHandedModeGesturalOverlay \
	preinstalled-packages-platform-overlays.xml

include $(BUILD_PHONY_PACKAGE)
+28 −0
Original line number Diff line number Diff line
#
#  Copyright 2020, 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.
#

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_RRO_THEME := OneHandedModeGestural


LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res

LOCAL_PACKAGE_NAME := OneHandedModeGesturalOverlay
LOCAL_SDK_VERSION := current

include $(BUILD_RRO_PACKAGE)
+28 −0
Original line number Diff line number Diff line
<!--
/**
 * Copyright (c) 2020, 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.
 */
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.internal.systemui.onehanded.gestural"
        android:versionCode="1"
        android:versionName="1.0">
    <overlay android:targetPackage="android"
        android:category="com.android.internal.one_handed_mode"
        android:priority="2"/>
    <!-- To override dimen in NavigationBarModeGesturalOverlay, priority should be higher -->

    <application android:label="@string/one_handed_mode_title" android:hasCode="false"/>
</manifest>
Loading