diff --git a/bin/dde-system-daemon/bluetooth.go b/bin/dde-system-daemon/bluetooth.go deleted file mode 100644 index 1fa84f77b..000000000 --- a/bin/dde-system-daemon/bluetooth.go +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -package main - -import ( - "fmt" - "path/filepath" - - dbus "github.com/godbus/dbus/v5" - "github.com/linuxdeepin/go-lib/dbusutil" - "github.com/linuxdeepin/go-lib/keyfile" -) - -const ( - bluetoothPrefixDir = "/var/lib/bluetooth" - - kfSectionGeneral = "General" - kfKeyTechnologies = "SupportedTechnologies" -) - -func (*Daemon) BluetoothGetDeviceTechnologies(adapter, device string) (technologies []string, busErr *dbus.Error) { - var filename = filepath.Join(bluetoothPrefixDir, adapter, device, "info") - if !filepath.HasPrefix(filename, bluetoothPrefixDir) { - return nil, dbusutil.ToError(fmt.Errorf("invaild adapter: [%s] device: [%s]", adapter, device)) - } - technologies, err := doBluetoothGetDeviceTechnologies(filename) - if err != nil { - return nil, dbusutil.ToError(err) - } - return technologies, nil -} - -func doBluetoothGetDeviceTechnologies(filename string) ([]string, error) { - var kf = keyfile.NewKeyFile() - err := kf.LoadFromFile(filename) - if err != nil { - return nil, fmt.Errorf("can't parse file: %s", filename) - } - return kf.GetStringList(kfSectionGeneral, kfKeyTechnologies) -} diff --git a/bin/dde-system-daemon/bluetooth_test.go b/bin/dde-system-daemon/bluetooth_test.go deleted file mode 100644 index b2fce07d0..000000000 --- a/bin/dde-system-daemon/bluetooth_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -package main - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_doBluetoothGetDeviceTechnologies(t *testing.T) { - type args struct { - filename string - } - tests := []struct { - name string - args args - want []string - wantErr bool - }{ - { - name: "doBluetoothGetDeviceTechnologies", - args: args{ - filename: "./testdata/doBluetoothGetDeviceTechnologies/info1", - }, - want: []string{"abc", "ccc"}, - wantErr: false, - }, - { - name: "doBluetoothGetDeviceTechnologies not exists", - args: args{ - filename: "./testdata/nonono", - }, - want: []string{}, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := doBluetoothGetDeviceTechnologies(tt.args.filename) - if tt.wantErr { - assert.NotNil(t, err) - return - } - - assert.Nil(t, err) - assert.ElementsMatch(t, tt.want, got) - }) - } -} diff --git a/bin/dde-system-daemon/exported_methods_auto.go b/bin/dde-system-daemon/exported_methods_auto.go index 6b2d9ee38..624b7dcec 100644 --- a/bin/dde-system-daemon/exported_methods_auto.go +++ b/bin/dde-system-daemon/exported_methods_auto.go @@ -8,12 +8,6 @@ import ( func (v *Daemon) GetExportedMethods() dbusutil.ExportedMethods { return dbusutil.ExportedMethods{ - { - Name: "BluetoothGetDeviceTechnologies", - Fn: v.BluetoothGetDeviceTechnologies, - InArgs: []string{"adapter", "device"}, - OutArgs: []string{"technologies"}, - }, { Name: "ClearTty", Fn: v.ClearTty, diff --git a/bin/dde-system-daemon/testdata/doBluetoothGetDeviceTechnologies/info1 b/bin/dde-system-daemon/testdata/doBluetoothGetDeviceTechnologies/info1 deleted file mode 100644 index ea3ff982d..000000000 --- a/bin/dde-system-daemon/testdata/doBluetoothGetDeviceTechnologies/info1 +++ /dev/null @@ -1,2 +0,0 @@ -[General] -SupportedTechnologies=abc;ccc diff --git a/bluetooth1/bluetooth_ifc.go b/bluetooth1/bluetooth_ifc.go index b0c17cdb9..0e18e31fd 100644 --- a/bluetooth1/bluetooth_ifc.go +++ b/bluetooth1/bluetooth_ifc.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -291,6 +291,8 @@ func (b *Bluetooth) FeedPasskey(device dbus.ObjectPath, accept bool, passkey uin return nil } +// DebugInfo is retained for D-Bus compatibility. The system service returns +// an empty snapshot so this proxy cannot expose adapter or device details. func (b *Bluetooth) DebugInfo() (info string, busErr *dbus.Error) { logger.Info("dbus call DebugInfo") diff --git a/system/bluetooth1/bluetooth_ifc.go b/system/bluetooth1/bluetooth_ifc.go index 20ed831a8..f3768e777 100644 --- a/system/bluetooth1/bluetooth_ifc.go +++ b/system/bluetooth1/bluetooth_ifc.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -373,9 +373,11 @@ func (b *SysBluetooth) UnregisterAgent(sender dbus.Sender, agentPath dbus.Object return nil } +// DebugInfo is retained for D-Bus compatibility but no longer exposes +// adapter or device details. func (b *SysBluetooth) DebugInfo() (info string, busErr *dbus.Error) { - info = fmt.Sprintf("adapters: %s\ndevices: %s", marshalJSON(b.adapters), marshalJSON(b.devices)) - return info, nil + logger.Debug("dbus call DebugInfo") + return "", nil } // ClearUnpairedDevice will remove all device in unpaired list diff --git a/system/bluetooth1/bluetooth_ifc_test.go b/system/bluetooth1/bluetooth_ifc_test.go new file mode 100644 index 000000000..bf9d4daae --- /dev/null +++ b/system/bluetooth1/bluetooth_ifc_test.go @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +package bluetooth + +import "testing" + +func TestDebugInfoDoesNotExposeBluetoothDetails(t *testing.T) { + b := &SysBluetooth{} + + info, err := b.DebugInfo() + if err != nil { + t.Fatalf("DebugInfo returned an unexpected error: %v", err) + } + if want := ""; info != want { + t.Fatalf("DebugInfo returned %q, want %q", info, want) + } +}