How to disable "air command" on Android devices?
Asked Answered
A

5

6

Hi, I've developed an application using a stylus (e.g., Samsung pen). As you know, when we click a button on the stylus, "Air command" (pop-up window) appears. My goal is "Overriding the air command into my custom functions"

First, I started with *SpenHoverListener" (supported by Samsung Spen SDK 5.0) and override the onHover function as follows.

private SpenHoverListener mHoverListener = new SpenHoverListener() {
    @Override
    public boolean onHover(View view, MotionEvent event) {
        Log.e("Test",""+event.getButtonState());
        updateHoverUI(event.getRawX(), event.getRawY(), event.getPressure(), event.getAction(), "Hover");
        return true;
    }
};

I can successfully monitor the button click event (BUTTON_STYLUS_PRIMARY => Button is clicked). HOWEVER, I cannot disable the air command.

Is there any way to disable the air command?

Best regards.

Auxiliaries answered 13/1, 2018 at 13:17 Comment(6)
have you tried overriding the onHoverButtonDown event for the Spen ? from the documentation it looks like this the event to override to stop air command as air command fires only when you press the button while hovering.Mensch
@kshishoo It was possible in previous Samsung SDK sdk2.3. (But I don't know whether overriding the onHoverButtonDown could overlap the air command feature or not). Anyway, sadly, Samsung SDK 5.0 remove the onHoverButtonDown interface. (it is deprecated.)Auxiliaries
so the only other solution (which is going to be very convoluted) is that you setup a Tasker task that senses the button press, looks for the air command activity, kills it if it finds it then does what you want to do in your app. (its going to be far easier if you could code your function to fire on a long button press that does not start air command)Mensch
@kshishoo I think monitoring whether air command appears or not is not that easy. To do that, we should dump recent activities from the activity stack (like => adb shell dumpsys activity recents), and parse the dumped result to detect air command periodically. Further, there would be some timing issues (when we check the dumped results).Auxiliaries
@kshishoo By the way, The point (the long button press doesn't trigger air command) is really helpful. Thanks :)Auxiliaries
happy to help :)Mensch
C
4

Preamble

It was possible in previous note models and tablets to disable the Air command.
On Marshmallow (version 6) there's no such toggle.
To turn off the Air command feature of the Samsung Galaxy Note 4 (at release):

Go to Settings > Controls.
Tap on S Pen.
Tap on Air Command.
Disable Air Command.

The Air command (packagecom.samsung.android.service.aircommand) is implemented via a system service.

Code

Notionally You cannot programmatically remove/disable this Air service (permissions) and as a system service it seems to have first dibs on the hardware events (you get them later/also and it's too late to stop Air if it is active). That being said Greenify does it so I sought out other options and found Brevent. This is totally free source code it the GitHub (AS 3), I'm playing with it right now (be aware it contains C code so NDK required if you want to build it, or see ->). Brevent Play Store

air command is grayed out in Galaxy Note 5

For the users here this graying out is a problem, for you it might be a solution.

Here are some choice comments:

Some owners reported that air command in Galaxy Note 5 was grayed out. The cause of grayed out Galaxy Note 5 air command is usually due to some accessibility settings (Go to Accessibility and switch on Voice Assistant ?). Actually, when you enabled such accessibility settings, there were the warning message on air command. But most of time, nobody reads it.

I have a galaxy note 5 and everything was fine until the device suggest me to update its android software from 5.1.1 to 6.0.1

I have Note 5 and the Air command stopped working after I installed Norton Antivirus.

Greenify

For your own personal use you can use the 'free' app:
(Android version 6+, even without root!) Greenify to disable the Air Command Service (to disable system apps/services you need to make a small "donation" and the function is described as "experimental").

Caz answered 16/1, 2018 at 14:45 Comment(3)
Sadly, The Samsung Galaxy Note 5 (Android 7.0) doesn't support the function to disable the air command. // By the way, you mentioned: "Greenify" (looks like an application making a battery last longer) can disable the air command. In here, how do they (Greenify) program the function (disabling the air command)? you said there's no way to remove the air command service programmatically.Auxiliaries
R.E. "Greenify" :(try it and see if it works! then you will know the scope of the problem at least) it SHOULD NOT be possible to remove a system service from an un-rooted android app (you need kernel system calls), I think Google don't intend you to do it, BUT "Oasis Feng" of Greenify maybe found a some way of doing it that he is keeping secret. It may be a vulnerability he is exploiting. One of the things he uses is "device admin enabled" (DevicePolicyManager). See thisCaz
Greenify apparently uses the android command "am" to stop an application. It will no longer start during phone boot, respond to registered intents or be triggered by alarms from the system. Code: # am force-stop com.samsung.android.service.aircommand # am start com.samsung.android.service.aircommand See hereCaz
D
1

How to disable “air command” on Android devices?

As far as I know, you cannot programmatically disable it on an unrooted device; I've tried other methods and even using Greenify (payed the donation package of Greenify, obviously) and it didn't solve the problem, what worked for me (Samsung Galaxy Tab A SM-P580 WIFI) was to actually uninstall the application.
  1. Made a backup of the app
    adb pull /system/priv-app/AirCommand/AirCommand.apk %USERPROFILE%\Desktop\aircommand.apk

  2. Uninstalled the app
    adb shell pm uninstall -k --user current com.samsung.android.service.aircommand

  3. (Optional) If you want to get it back you can install it again with adb
    adb install %USERPROFILE%\Desktop\aircommand.apk

So this is how I disabled Air Command on an Android device, hope this helps anyone looking into this.

Have great day!

Detective answered 27/1, 2021 at 21:16 Comment(1)
Thanks. This adb shell pm uninstall -k --user current com.samsung.android.service.aircommand works for me instead of pm disable com.samsung.android.service.aircommand - that doesn't work.Empyrean
F
0

Just change the return type to false. This will launch your method and will communicate to the System that hover failed; and hence will not trigger the Air View.

private SpenHoverListener mHoverListener = new SpenHoverListener() {
    @Override
    public boolean onHover(View view, MotionEvent event) {
        Log.e("Test",""+event.getButtonState());
        updateHoverUI(event.getRawX(), event.getRawY(), event.getPressure(), event.getAction(), "Hover");
        return false;
    }
};
Flocculent answered 23/1, 2018 at 11:29 Comment(2)
Thanks for a comment. But it doesn't work. "return false" means "I will not transfer events to child views". Since the air command is already processed in the upper layer, it doesn't affect anything.Auxiliaries
Hi, did you find please any solution? I am working on adventure game and I like to use spen button for something else.Floristic
C
0

With ADB or a superuser shell, you can also do that as follows:

pm disable com.samsung.android.service.aircommand

To enable it back, do the same but disableenable.

Contagion answered 30/8, 2019 at 11:9 Comment(0)
E
0

None of the above mentionned solution worked for me (Android 9 on Galaxy Tab S3). In particular I didn't succeed to disable Air Command with ADB as hotkey suggests. However this lead me to the next command in ADB shell:

pm uninstall -k --user 0 com.samsung.android.service.aircommand

Removing (without rooting) is more radical than disabling. However this is what I was actually looking for when I was driven to the present page, and I didn't find it anywhere else. So I guess it might be usefull to share it...

Eiser answered 3/5, 2020 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.