2013-08-28 33 views
5

ユーザーの介入なしにADBからBluetoothを起動することは可能ですか? 私が試した:ADBか起動時にBluetoothを起動しますか?

am start -a android.bluetooth.adapter.action.REQUEST_ENABLE 

が、これは[OK]を押して、ユーザが必要になります。そして:

service call bluetooth 3 

は何もしません。 init.rcでbluetoothdサービスを有効にしても機能しません。

service bluetoothd /system/bin/bluetoothd -n 
    class main 
    socket bluetooth stream 660 bluetooth bluetooth 
    socket dbus_bluetooth stream 660 bluetooth bluetooth 
    # init.rc does not yet support applying capabilities, so run as root and 
    # let bluetoothd drop uid to bluetooth with the right linux capabilities 
    group bluetooth net_bt_admin misc 
    enabled 

そして、私はADBからのコマンドを好むでしょう。 (もし誰かが不思議に思うのであれば、私はFCCテストのためにそれが必要です)。

答えて

3

もしあなたがうまくいけば、アプリは簡単にブルートゥースの状態を変えることができます。コードは、私はあなたがそれに精通していると確信している、非常に簡単です:

BluetoothAdapter.getDefaultAdapter().enable() 

これは、特定の意図をリッスンのみのサービスとの「ヘッドレス」アプリケーションである可能性があります。それをインストールして、アクティベータのインテントをブロードキャストできます。

アプリを「引き出し」(「設定」 - >「アプリ」のみ)に表示しない場合は、AndroidManifest.xmlファイルからランチャーと主なインテントフィルタを削除します。つまり、これらを削除してください:

<intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

この時点から、マニフェストファイルで定義した目的でapp/serviceを開始することができます。たとえば、あなたが作成し、登録アクションcom.company.service.bluetooth.ONとサービスのためのインテントフィルタをし、adbのコマンドでそれを起動することができます。

am startservice -a com.company.service.bluetooth.ON 

電話がある場合はそれを行うには、他の方法があるように思えません。根付いていない。根元にある場合は、service call bluetooth 3が動作するはずです。

このチュートリアルでは、実際の解決策について説明しています。How to launch an Android app from adb - And toggle bluetooth私の作品

根ざしデバイス

adb shell service call bluetooth_manager 8 
Bluetooth On/Off Toggle App.

+0

はい、これは最後の手段(BluetoothONアプリとBluetoothOFFアプリ)のためのアプリを作ることを考えました。アプリ引き出しからアプリを隠すことは可能ですか(4.1.2を参照)そして、 "adb shell am start"を使って起動してください。 –

+0

隠し情報で答えを更新 – allprog

4

:彼らは、このアプリを使用しています。

+0

残念なことに、これは実際に根付いたデバイスを必要としているようです – raphinesse

+0

@raphinesseはい私の答えの最初の行は "ルートデバイス" – Danw25

関連する問題