2

Android デバイス名 == "BlueZ"?

私の質問はこれと非常によく似ていBlueZます。実際のデバイス名を表示するように変更する方法、つまり「BlueZ」を表示するのではなく、build.prop から読み取る方法を知る必要があります。

main.confinを見つけましたexternal/bluetooth/bluez/src/main.conf(少しずれている可能性があります)。変数が「BlueZ」に設定された、デバイス名に関する行が含まれています。%dと の両方に変更してみましたが%h、どちらも変更されませんでした。手動でデバイス名に設定してみますが、この修正が複数のデバイスで使用できるようにしたいと考えています。

何か案は?

# Default adaper name
# %h - substituted for hostname
# %d - substituted for adapter id
Name = "Bluez"

上記の 2 つの変数を置き換えてみましたが、どちらも効果がないようです。

4

1 に答える 1

0

外部アプリからはどうですか?Android ビルドを作成し、最後の状態でアプリを実行して Android デバイス名を変更できますか?

IBluetooth.aidl -> setName を使用して Bluetooth 名を変更できます。

チュートリアルは、ここで見つけることができます

つまり、src でパッケージ android.bluetooth を作成し、その中に IBluetooth.aidl と IBluetoothCallback.aidl をコピーして貼り付けます (前のリンクで見つけることができます)。

コードで、パッケージをインポートします。 import android.bluetooth.IBluetooth;

次に、このメソッドを実装して Bluetooth オブジェクトを取得します。

@SuppressWarnings("rawtypes")
private IBluetooth getIBluetooth() {
    IBluetooth ibt = null;
    try {
        Class c2 = Class.forName("android.os.ServiceManager");
        Method m2 = c2.getDeclaredMethod("getService", String.class);
        IBinder b = (IBinder) m2.invoke(null, "bluetooth");
        Class c3 = Class.forName("android.bluetooth.IBluetooth");
        Class[] s2 = c3.getDeclaredClasses();
        Class c = s2[0];
        Method m = c.getDeclaredMethod("asInterface", IBinder.class);
        m.setAccessible(true);
        ibt = (IBluetooth) m.invoke(null, b);
    } catch (Exception e) {
        Log.e("flowlab", "Erroraco!!! " + e.getMessage());
    }
    return ibt;
}

次に、このオブジェクトをインスタンス化します。 IBluetooth ib =getIBluetooth();

おそらく ib.setName("something"); を使用します。

于 2012-05-11T06:47:40.943 に答える