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

Commit 87642f21 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor Committed by Mohammed Althaf T
Browse files

input: Introduce handling for SW_PEN_INSERTED



Co-authored-by: Rohit Sekhar's avatarRohit R Sekhar <merothh@e.email>
parent 78ccd5e3
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -866,6 +866,9 @@
    <!-- Used to launch a common app (FlipFlap) for devices with flip cover. -->
    <!-- Used to launch a common app (FlipFlap) for devices with flip cover. -->
    <protected-broadcast android:name="lineageos.intent.action.LID_STATE_CHANGED" />
    <protected-broadcast android:name="lineageos.intent.action.LID_STATE_CHANGED" />
    <!-- Used to handle states for devices with a stylus pen. -->
    <protected-broadcast android:name="lineageos.intent.action.PEN_INSERTED_STATE_CHANGED" />
    <!-- Used for long press power torch feature - automatic turn off on timeout -->
    <!-- Used for long press power torch feature - automatic turn off on timeout -->
    <protected-broadcast android:name="com.android.server.policy.PhoneWindowManager.ACTION_TORCH_OFF" />
    <protected-broadcast android:name="com.android.server.policy.PhoneWindowManager.ACTION_TORCH_OFF" />
+23 −0
Original line number Original line Diff line number Diff line
@@ -443,6 +443,9 @@ public class InputManagerService extends IInputManager.Stub
    /** Switch code: Microphone. When set, the mic is muted. */
    /** Switch code: Microphone. When set, the mic is muted. */
    public static final int SW_MUTE_DEVICE = 0x0e;
    public static final int SW_MUTE_DEVICE = 0x0e;


    /** Switch code: Stylus Pen. When set, the pen is inserted. */
    public static final int SW_PEN_INSERTED = 0x0f;

    public static final int SW_LID_BIT = 1 << SW_LID;
    public static final int SW_LID_BIT = 1 << SW_LID;
    public static final int SW_TABLET_MODE_BIT = 1 << SW_TABLET_MODE;
    public static final int SW_TABLET_MODE_BIT = 1 << SW_TABLET_MODE;
    public static final int SW_KEYPAD_SLIDE_BIT = 1 << SW_KEYPAD_SLIDE;
    public static final int SW_KEYPAD_SLIDE_BIT = 1 << SW_KEYPAD_SLIDE;
@@ -456,6 +459,8 @@ public class InputManagerService extends IInputManager.Stub
                                           | SW_VIDEOOUT_INSERT_BIT;
                                           | SW_VIDEOOUT_INSERT_BIT;
    public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER;
    public static final int SW_CAMERA_LENS_COVER_BIT = 1 << SW_CAMERA_LENS_COVER;
    public static final int SW_MUTE_DEVICE_BIT = 1 << SW_MUTE_DEVICE;
    public static final int SW_MUTE_DEVICE_BIT = 1 << SW_MUTE_DEVICE;
    public static final int SW_PEN_INSERTED_BIT = 1 << SW_PEN_INSERTED;



    // The following are layer numbers used for z-ordering the input overlay layers on the display.
    // The following are layer numbers used for z-ordering the input overlay layers on the display.
    // This is used for ordering layers inside {@code DisplayContent#getInputOverlayLayer()}.
    // This is used for ordering layers inside {@code DisplayContent#getInputOverlayLayer()}.
@@ -2546,6 +2551,24 @@ public class InputManagerService extends IInputManager.Stub


            setSensorPrivacy(Sensors.MICROPHONE, micMute);
            setSensorPrivacy(Sensors.MICROPHONE, micMute);
        }
        }

	if ((switchMask & SW_PEN_INSERTED_BIT) != 0) {
            final boolean penInserted = ((switchValues & SW_PEN_INSERTED_BIT) != 0);

            Intent intent = new Intent("lineageos.intent.action.PEN_INSERTED_STATE_CHANGED");
            intent.putExtra("state", penInserted);
            intent.setPackage("org.lineageos.settings.device");

	    if (DEBUG) {
                Slog.d(TAG, "Dispatching pen state intent: "
                    + intent.getAction() + ", state=" + penInserted
                    + ", switchValues=" + Integer.toHexString(switchValues)
                    + ", switchMask=" + Integer.toHexString(switchMask));
	    }

	    mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
	}

    }
    }


    // Set the sensor privacy state based on the hardware toggles switch states
    // Set the sensor privacy state based on the hardware toggles switch states