手機連接 USB 時如何防止通知和圖示彈出?

手機連接 USB 時如何防止通知和圖示彈出?

情況:當手機連接到 USB 時出現無關的通知和彈出視窗。
區別狀況:USB電源管理故障、網路卡管理故障。
支援:通知、彈出視窗和 dmesg 警告大多在電源狀態達到最高時出現,但當電源狀態百分比保持恆定時變得相當穩定。

當我透過 USB 將手機連接到筆記型電腦時,檔案管理器會不斷開啟(圖 1 和 2)。左側欄中還有彈出圖示(圖 3)。網路共享時也會經常出現網路連線開啟/關閉通知(圖 4 和 5)。劣質電纜會增加這些煩惱的發生頻率。所有類型的通知每分鐘可能會出現多次。當電池達到高功率狀態時,它們的速率會增加,但當電池充滿電時,它們的速率會保持穩定。

  • 我做wjandrea的提議 gsettings set org.gnome.desktop.media-handling automount-open false解決automount-open問題及其dmesg | tail狀態這裡

當裝置僅連接到筆記型電腦時,您會看到大約 10-30 個錯誤視窗(圖 1 和 2),並且手機右側圖示來回彈出(圖 3)

在此輸入影像描述

在此輸入影像描述

在此輸入影像描述

  • 我執行 wjandrea 的第二個建議gsettings set org.gnome.desktop.media-handling automount false。然而,三星手機的圖示開始一次又一次地在左側欄中彈出。這種情況主要發生在我的筆記型電腦充滿電時,因此這可能是電源管理中的問題。它的dmesg | tail狀態是這裡(另請參見圖 3),這是第一次發生,而且主要是在我的筆記型電腦達到最大電池狀態時發生。

這裡是第二個 dmesg 的子集

[    5.788819] wl: module license 'MIXED/Proprietary' taints kernel.
[    5.788820] Disabling lock debugging due to kernel taint
[    5.789154] input: HDA Intel PCH Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card1/input8
[    5.797453] wl: module verification failed: signature and/or required key missing - tainting kernel
[    5.812002] input: HDA Intel HDMI HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:03.0/sound/card0/input9
[    5.812092] input: HDA Intel HDMI HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:03.0/sound/card0/input10
[    5.812165] input: HDA Intel HDMI HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:03.0/sound/card0/input11
[    5.981764] intel_rapl: Found RAPL domain package
[    5.981769] intel_rapl: Found RAPL domain core
[    5.981771] intel_rapl: Found RAPL domain uncore
[    5.981772] intel_rapl: Found RAPL domain dram
[    6.024117] wlan0: Broadcom BCM43a0 802.11 Hybrid Wireless Controller 6.30.223.248 (r487574)
[    6.030416] applesmc: key=561 fan=1 temp=33 index=33 acc=0 lux=2 kbd=1
[    6.050130] wl 0000:03:00.0 wlp3s0: renamed from wlan0
[    6.242168] Non-volatile memory driver v1.3
[    6.428191] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready
[    6.862799] input: bcm5974 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.2/input/input12
[    6.862926] usbcore: registered new interface driver bcm5974
[    7.053663] fuse init (API version 7.24)
[    7.329118] Bluetooth: Core ver 2.21
[    7.329540] NET: Registered protocol family 31
[    7.329543] Bluetooth: HCI device and connection manager initialized
[    7.329548] Bluetooth: HCI socket layer initialized
[    7.329551] Bluetooth: L2CAP socket layer initialized
[    7.329558] Bluetooth: SCO socket layer initialized
[    7.350445] usbcore: registered new interface driver btusb
[    7.355183] Bluetooth: hci0: BCM: chip id 73 build 0932
[    7.356184] Bluetooth: hci0: BCM: product 05ac:828f
[    7.372192] Bluetooth: hci0: BCM20702B0 Generic USB Class 1 @ 20 MHz
[    7.391321] usb 1-3.1: USB disconnect, device number 5
[    7.634631] usb 1-3.2: USB disconnect, device number 6
[    8.363517] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    8.363521] Bluetooth: BNEP filters: protocol multicast
[    8.363525] Bluetooth: BNEP socket layer initialized
[    8.377953] Bluetooth: RFCOMM TTY layer initialized
[    8.377960] Bluetooth: RFCOMM socket layer initialized
[    8.377965] Bluetooth: RFCOMM ver 1.11
[   78.943062] usb 1-1: USB disconnect, device number 2
[   79.308530] usb 1-1: new high-speed USB device number 8 using xhci_hcd
[   79.437071] usb 1-1: New USB device found, idVendor=04e8, idProduct=6863
[   79.437079] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   79.437083] usb 1-1: Product: SAMSUNG_Android
[   79.437086] usb 1-1: Manufacturer: SAMSUNG
[   79.437089] usb 1-1: SerialNumber: d068730a
[   79.978452] usbcore: registered new interface driver cdc_ether
[   79.981649] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, 02:57:00:57:38:37
[   79.981726] usbcore: registered new interface driver rndis_host
[   79.983854] rndis_host 1-1:1.0 enp0s20u1: renamed from usb0
[   80.011403] IPv6: ADDRCONF(NETDEV_UP): enp0s20u1: link is not ready
[ 1290.235637] usb 1-1: USB disconnect, device number 8
[ 1290.235777] rndis_host 1-1:1.0 enp0s20u1: unregister 'rndis_host' usb-0000:00:14.0-1, RNDIS device
[ 1290.591107] usb 1-1: new high-speed USB device number 9 using xhci_hcd
[ 1290.719964] usb 1-1: New USB device found, idVendor=04e8, idProduct=6863
[ 1290.719973] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1290.719977] usb 1-1: Product: SAMSUNG_Android
[ 1290.719981] usb 1-1: Manufacturer: SAMSUNG
[ 1290.719984] usb 1-1: SerialNumber: d068730a
[ 1290.722251] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, 02:57:00:57:38:37
[ 1291.255806] rndis_host 1-1:1.0 enp0s20u1: renamed from usb0
[ 1291.277892] IPv6: ADDRCONF(NETDEV_UP): enp0s20u1: link is not ready
[ 1870.316573] usb 1-1: USB disconnect, device number 9
[ 1870.316687] rndis_host 1-1:1.0 enp0s20u1: unregister 'rndis_host' usb-0000:00:14.0-1, RNDIS device
[ 1871.735777] usb 1-1: new high-speed USB device number 10 using xhci_hcd
[ 1871.865681] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 1871.865687] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1871.865690] usb 1-1: Product: SAMSUNG_Android
[ 1871.865692] usb 1-1: Manufacturer: SAMSUNG
[ 1871.865694] usb 1-1: SerialNumber: d068730a
[ 2265.887618] usb 1-1: USB disconnect, device number 10
[ 2268.395967] usb 1-1: new high-speed USB device number 11 using xhci_hcd
[ 2268.524992] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 2268.524998] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2268.525001] usb 1-1: Product: SAMSUNG_Android
[ 2268.525003] usb 1-1: Manufacturer: SAMSUNG
[ 2268.525005] usb 1-1: SerialNumber: d068730a
[ 2389.754208] usb 1-1: USB disconnect, device number 11
[ 2451.283233] usb 1-1: new high-speed USB device number 12 using xhci_hcd
[ 2451.412713] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 2451.412719] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2451.412722] usb 1-1: Product: SAMSUNG_Android
[ 2451.412725] usb 1-1: Manufacturer: SAMSUNG
[ 2451.412727] usb 1-1: SerialNumber: d068730a
[ 4253.278282] usb 1-1: USB disconnect, device number 12
[ 4254.096939] usb 1-1: new high-speed USB device number 13 using xhci_hcd
[ 4259.392860] usb 1-1: new high-speed USB device number 14 using xhci_hcd
[ 4259.522162] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 4259.522167] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4259.522170] usb 1-1: Product: SAMSUNG_Android
[ 4259.522173] usb 1-1: Manufacturer: SAMSUNG
[ 4259.522175] usb 1-1: SerialNumber: d068730a
[ 4259.731917] usb 1-1: USB disconnect, device number 14
[ 4260.068777] usb 1-1: new high-speed USB device number 15 using xhci_hcd
[ 4260.200384] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 4260.200389] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4260.200392] usb 1-1: Product: SAMSUNG_Android
[ 4260.200395] usb 1-1: Manufacturer: SAMSUNG
[ 4260.200397] usb 1-1: SerialNumber: d068730a
[ 4487.825779] usb 1-1: USB disconnect, device number 15
[ 4488.457511] usb 1-1: new high-speed USB device number 16 using xhci_hcd
[ 4488.643676] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 4488.643682] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4488.643685] usb 1-1: Product: SAMSUNG_Android
[ 4488.643687] usb 1-1: Manufacturer: SAMSUNG
[ 4488.643689] usb 1-1: SerialNumber: d068730a
[ 4507.592538] usb 1-1: USB disconnect, device number 16
[ 4507.929239] usb 1-1: new high-speed USB device number 17 using xhci_hcd
[ 4508.115547] usb 1-1: New USB device found, idVendor=04e8, idProduct=6860
[ 4508.115553] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4508.115556] usb 1-1: Product: SAMSUNG_Android
[ 4508.115558] usb 1-1: Manufacturer: SAMSUNG
[ 4508.115560] usb 1-1: SerialNumber: d068730a

在此輸入影像描述

在此輸入影像描述

其他建議

  • 斯尼謝爾。第一天就有效。我會在下週告訴你它是如何運作的。

    > sudo -i 
    > sed 's/LABEL="libmtp_usb_rules"/LABEL="libmtp_usb_rules"\n\n#Masi, ignore my phone\nATTR{idVendor}=="04e8", ATTR{idProduct}=="6863", GOTO="libmtp_rules_end"/g' /lib/udev/rules.d/69-libmtp.rules | sudo tee /etc/udev/rules.d/69-libmtp.rules \
    udevadm control --reload-rules
    
    # TODO for long time monitoring
    

手機:淡馬錫非官方三星 Galaxy S4 gt-i9506唯讀記憶體帶有足夠補丁的 CyanogenMod 13
Ubuntu 版本:16.04
Linux 核心:4.4 和 4.6
Linux 核心選項:wl
Bash:4.3.42(1)-release (x86_64-pc-linux-gnu)
筆記型電腦:2013 年中期 Macbook Air
USB :兩個USB3 連接埠(高達 5 Gbps)(這裡官方規格)
網卡驅動程式:非免費Broadcom-sta-dkms(看這裡)
手機中的 VPN:NordVPN US udp 伺服器
當 wifi 連接到路由器防火牆時,筆記型電腦中的 VPN:NordVPN EE udp 伺服器

  • 支援 1:電源狀態的負變化 (-1%) 與通知相關。
  • 支援 2:不穩定的網路連線會消耗大量電力 (\Delta P = 1%)。
  • 支援 3:受 VPN 保護的網路連線顯著減少通知量。

答案1

dconf是在這種情況下檢查的地方。

dconf 是一個低階配置系統和設定管理。其主要目的是在尚未配置儲存系統的平台上為 GSettings 和 KSettings 提供後端。這取決於 GLib。它是 GNOME 3 的一部分,是 GConf 的替代品。 ~維基百科

為此,您需要安裝dconf 編輯器如下:

sudo apt-get update
sudo apt-get install dconf-tools

打開dconf 編輯器,

Alt+F2

或者

應用程式 > 系統工具 > dconf 編輯器

現在在 dconf 編輯器的側邊欄中

org > gnome > 桌面 > 媒體處理

取消選取自動掛載打開選項。

以下是 16.04 中 dconf-editor 的螢幕截圖:

16.04 中的 dconf 編輯器

答案2

@Dhaval-Simaria 答案的 CLI 版本:

gsettings set org.gnome.desktop.media-handling automount-open false

請注意,Ubuntu 附帶gsettings;它不需要安裝。


編輯更新資訊:由於錯誤訊息報告安裝失敗,請嘗試停用自動安裝:

gsettings set org.gnome.desktop.media-handling automount false

答案3

如果您運行 Xubuntu,這真的很容易,因為它有一個配置面板來選擇自動掛載行為。只需轉到“設定”>“硬體”>“可移動磁碟機和媒體”,然後取消勾選相關選項:

在此輸入影像描述

答案4

您應該查看 udev 規則。使用它們,您可以阻止一台裝置而不影響任何其他 USB 裝置。您可以透過在 中建立檔案來定義自己的 udev 規則/etc/udev/rules.d/,例如 /etc/udev/rules.d/51-block-phone-mount.rules

現在找到裝置的 idVendor 和 idProduct。這些很好用,因為它們對於產品來說大多是唯一的,因此您可以使用它們來識別 udev 規則中的裝置。

列出您使用的 USB 裝置lsusb並取得以下內容:

Bus 002 Device 002: ID 8087:8002 Intel Corp.  
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub  
Bus 001 Device 002: ID 8087:800a Intel Corp.  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub  
Bus 004 Device 002: ID 0424:2660 Standard Microsystems Corp.  
Bus 004 Device 003: ID 03f0:0024 Hewlett-Packard KU-0316 Keyboard  
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

相關部分是總線和設備,例如總線004和設備003 sudo lsusb -vs 004:003 | grep -E 'idProduct|idVendor'

idVendor           0x03f0 Hewlett-Packard  
idProduct          0x0024 KU-0316 Keyboard

這意味著您/etc/udev/rules.d/51-block-phone-mount.rules需要插入以下內容:

#Phone automount block  
SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0024", ATTR{authorized}="0"

您可以立即嘗試,只需重新插入手機並檢查它是否有效。

相關內容