2026年1月4日 星期日

Privacy Policy for M365 BLE App


**Last Updated: January 4, 2026**


## Introduction


M365 BLE App ("we", "our", or "the App") is committed to protecting your privacy. This Privacy Policy explains how we collect, use, and safeguard your information when you use our mobile application.


## Information We Collect


### 1. Device Information

- **Bluetooth Device Data**: We collect information about nearby Bluetooth Low Energy (BLE) devices, including device names, MAC addresses, and signal strength (RSSI) for the purpose of connecting to compatible electric scooters.

- **Device Binding Information**: When you register/bind a scooter, we store encrypted device credentials locally on your device.


### 2. Location Information

- **Approximate Location**: We request location permissions solely to enable Bluetooth scanning, as required by Android OS. We do NOT track, store, or transmit your geographic location to any servers.


### 3. Scooter Telemetry Data

- **Vehicle Data**: Speed, battery level, odometer readings, and motor status are collected from connected scooters for display purposes only.


## How We Use Your Information


We use the collected information exclusively to:

- Enable Bluetooth connection to your electric scooter

- Display real-time vehicle status and statistics

- Store device pairing information locally for reconnection


## Data Storage and Security


- **Local Storage Only**: All data is stored locally on your device using Android's encrypted storage (EncryptedSharedPreferences).

- **No Cloud Transmission**: We do NOT transmit any personal data, location data, or device information to external servers.

- **No Third-Party Sharing**: We do NOT share, sell, or transfer your data to any third parties.


## Permissions Required


| Permission | Purpose |

|------------|---------|

| Bluetooth | Connect to BLE-enabled scooters |

| Location | Required by Android for BLE scanning (not used for tracking) |

| Internet | Optional: Future firmware update features only |


## Data Retention


- Device binding credentials are stored until you manually disconnect/unbind the device or uninstall the app.

- No usage history or telemetry data is permanently stored.


## Your Rights


You have the right to:

- **Delete**: Uninstall the app to remove all locally stored data

- **Revoke Permissions**: Disable Bluetooth/Location permissions in Android settings at any time


## Children's Privacy


This App is not intended for children under 13 years of age. We do not knowingly collect personal information from children.


## Changes to This Policy


We may update this Privacy Policy from time to time. Changes will be reflected in the "Last Updated" date above.


## Contact Us


If you have questions about this Privacy Policy, please contact us at:


**Email**: [your-email@example.com]  

**GitHub**: [your-github-repo-url]


---


© 2026 M365 BLE App. All rights reserved.

2025年6月12日 星期四

Azure 上 Ubuntu 22.04 遠端桌面 (XRDP) 完全設定與故障排除指南



Azure 上 Ubuntu 22.04 遠端桌面 (XRDP) 完全設定與故障排除指南

前言

在雲端主機上設定一個穩定、高效的圖形化遠端桌面,是許多開發者與系統管理員的共同需求。然而,在 Ubuntu 22.04 LTS 上設定 XRDP 服務時,由於其預設的桌面環境 (GNOME) 與 XRDP 的相容性問題,以及層層的權限設定,使用者時常會陷入「純色畫面」、「連線失敗」等各種疑難雜症的泥淖中。

本篇文章將完整記錄一次從零開始,在 Azure 平台上建立一台 Ubuntu 22.04 虛擬機,並透過分析一系列真實的錯誤日誌,逐步診斷並最終成功設定 XRDP 遠端桌面的全過程。這是一份實戰指南,也是一份詳盡的除錯筆記。

第一階段:環境準備 - 建立 Azure 虛擬機

我們的目標是建立一個乾淨的測試環境。

  1. 登入 Azure 入口網站:前往 portal.azure.com
  2. 建立虛擬機
    • 映像 (作業系統):選擇 Ubuntu Desktop 22.04 LTS。選擇 "Desktop" 版本至關重要,因其內建圖形介面。
    • 驗證類型:可選擇「密碼」或更安全的「SSH 公開金鑰」。
    • 輸入連接埠規則:在網路設定中,務必同時允許 SSH (22)RDP (3389) 的傳入流量。

第二階段:安裝與初始設定

環境準備好後,我們透過 SSH 登入主機,安裝必要的軟體。

  1. SSH 連線:使用 ssh <使用者名稱>@<VM的公用IP位址> 登入指令列介面。
  2. 安裝核心套件:我們選擇安裝相容性極佳的 XFCE 作為桌面環境,並安裝 xrdp 及其 xorgxrdp 後端。
    Bash
    sudo apt update && sudo apt upgrade -y
    sudo apt install -y xfce4 xfce4-goodies xrdp xorgxrdp
    

第三階段:史詩級的故障排除之旅

在完成初始安裝後,真正的挑戰才剛開始。我們遭遇了一系列的典型錯誤,並根據日誌逐一擊破。

問題一:登入後只有純色畫面 (藍/綠畫面)

  • 症狀:RDP 客戶端成功輸入帳號密碼,但只看到一個純色的背景,沒有任何桌面圖示或選單。
  • 診斷:這是最常見的問題,代表 xrdp 服務已驗證使用者,但無法成功啟動桌面環境。根本原因通常是 Ubuntu 預設的 GNOME 桌面與 xrdp 的工作階段管理有衝突。
  • 解決方案:明確告訴 xrdp 在使用者登入時,要啟動我們已安裝好的 XFCE 桌面。
    Bash
    # 為指定使用者建立 .xsession 設定檔
    echo "xfce4-session" > /home/your_username/.xsession
    

問題二:「login failed for display 0」

  • 症狀:RDP 的 Connection Log 視窗顯示此錯誤。
  • 日誌分析xrdp-sesman.log 中沒有太多線索,但這是典型的權限問題
  • 診斷:執行 ls -la /home/your_username/.xsession 後發現,因為前一步驟使用了 sudo,導致 .xsession 檔案的擁有者變成了 root。當 xrdp 以普通使用者身分嘗試讀取這個檔案時,因權限不足而失敗。
  • 解決方案:將檔案的擁有權交還給使用者本人。
    Bash
    sudo chown your_username:your_username /home/your_username/.xsession
    

問題三:「VNC error - problem connecting」

  • 症狀:錯誤訊息從 Xorg 相關變成了 VNC 相關。
  • 日誌分析xrdp-sesman.log 中出現 starting Xvnc session...Error ... No such file or directory
  • 診斷:這表示 xrdp 因為某些原因無法使用 Xorg 模式,轉而嘗試其備用方案——VNC 模式。但由於系統上並未安裝 VNC 伺服器 (如 tightvncserver),所以這個備用方案也失敗了。
  • 解決方案:與其去安裝 VNC,不如強制 xrdp 使用我們想要的 Xorg 模式。我們透過修改 xrdp.ini,新增一個專用的 XFCE 登入選項。
    1. 編輯 /etc/xrdp/xrdp.ini
    2. 在檔案末尾新增以下區塊:
      Ini, TOML
      [XFCE]
      name=XFCE Desktop
      lib=libxup.so
      username=ask
      password=ask
      ip=127.0.0.1
      port=-1
      code=20
      
    3. 重啟服務後,在 RDP 登入畫面的 "Session" 下拉選單中選擇 "XFCE Desktop"。

問題四:「Window manager ... exited quickly」與最終的綠畫面

  • 症狀:即使強制使用 Xorg 模式,登入後依然是綠色畫面。
  • 日誌分析xrdp-sesman.log 給出了決定性的線索:Window manager ... exited quickly (0 secs) (視窗管理員在0秒內就崩潰退出) 和 X server ... returned exit code 1 (X 伺服器錯誤退出)。同時,使用者的 ~/.xsession-errors 檔案甚至來不及生成。
  • 診斷:所有 xrdp 層面的設定都已正確。問題出在系統層面:Ubuntu 預設的啟動腳本 (/etc/xrdp/startwm.sh) 在啟動 XFCE 時產生了衝突,同時 X Server 的啟動權限 (/etc/X11/Xwrapper.config) 過於嚴格,不允許遠端使用者啟動。
  • 最終解決方案
    1. 提升權限:將使用者加入 ssl-cert 群組,並修改 /etc/X11/Xwrapper.config,將 allowed_users=console 改為 allowed_users=anybody
    2. 簡化腳本:備份後,用一個極度簡化、功能單一的腳本完全覆寫 /etc/xrdp/startwm.sh 的內容,確保它只做一件事:啟動 XFCE。
      Bash
      #!/bin/sh
      unset DBUS_SESSION_BUS_ADDRESS
      unset XDG_RUNTIME_DIR
      /usr/bin/startxfce4
      
    3. 賦予權限sudo chmod +x /etc/xrdp/startwm.sh
    4. 重啟 VMsudo reboot

第四階段:成功登入與總結

在完成上述所有步驟後,遠端桌面連線終於成功,並顯示了穩定、流暢的 XFCE 桌面環境。

這次的除錯過程告訴我們,在 Linux 系統上設定服務時:

  • 日誌是最好的朋友:仔細閱讀 /var/log/xrdp-sesman.log 是解決問題的關鍵。
  • 權限是萬惡之源:從檔案擁有者 (chown) 到系統策略 (Xwrapper.config),大部分問題都與權限有關。
  • 化繁為簡:當預設設定過於複雜並導致問題時,用一個簡單、明確的自訂設定來取代它,往往是最佳路徑。
  • 選擇相容性好的套件組合:在 Ubuntu 上,XRDP + XFCE 已被證明是比預設 GNOME 更穩定的遠端桌面方案。

附錄:全新 VM 一鍵安裝指令碼

如果您需要建立一台全新的 VM,以下指令碼整合了所有最終的解決方案,可以讓您在一個乾淨的系統上快速完成所有設定。

Bash
#!/bin/bash

# --- 1. 更新系統並安裝所有必要軟體 ---
echo "Updating and reinstalling packages..."
sudo apt update && sudo apt upgrade -y
sudo apt install -y xfce4 xfce4-goodies xrdp xorgxrdp

# --- 2. 建立一個簡化的、穩定的啟動腳本 ---
echo "Creating a simplified startwm.sh for XFCE..."
cat <<EOF | sudo tee /etc/xrdp/startwm.sh
#!/bin/sh
# Simplified startup script for XFCE
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
/usr/bin/startxfce4
EOF

# --- 3. 賦予腳本執行權限 ---
sudo chmod +x /etc/xrdp/startwm.sh

# --- 4. 修改 Xwrapper 設定以允許遠端使用者 ---
echo "Allowing anybody to start X session..."
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config

# --- 5. 將 xrdp 使用者加入必要的群組 ---
sudo adduser xrdp ssl-cert

# --- 6. 重新啟動 xrdp 服務 ---
echo "Restarting XRDP service..."
sudo systemctl restart xrdp

# --- 7. 提示使用者重新啟動 ---
echo "All setup is complete. Please reboot the VM to apply all changes."
echo "Run 'sudo reboot' now."