zhuguifei
2025-12-30 61eee1173c00a7ba9d9c748d28fe3acdb33b9441
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.shlb.comb.activity;
 
import android.bluetooth.BluetoothAdapter;
import android.content.pm.PackageManager;
import android.os.Build;
import android.view.View;
 
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
import com.shlb.comb.R;
import com.shlb.comb.base.BaseActivity;
import com.shlb.comb.event.UpdateEvent;
 
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
 
public class CurrentDeviceActivity extends BaseActivity {
 
    private QMUIGroupListView mGroupHardware;
    private QMUIGroupListView mGroupBle;
    private QMUIGroupListView mGroupAudio;
    private QMUIGroupListView mGroupScreen;
 
    @Override
    protected void contentView() {
        setContentView(R.layout.activity_current_device);
    }
 
    @Override
    protected void initView() {
        super.initHead();
        tv_center.setText("设备信息");
        if (iv_right != null) iv_right.setVisibility(View.GONE);
        if (iv_left != null) {
            iv_left.setImageDrawable(getResources().getDrawable(R.mipmap.icon_back));
            iv_left.setOnClickListener(v -> finish());
        }
 
        mGroupHardware = findViewById(R.id.group_hardware);
        mGroupBle = findViewById(R.id.group_ble);
        mGroupAudio = findViewById(R.id.group_audio);
        mGroupScreen = findViewById(R.id.group_screen);
    }
 
    @Override
    protected void initData() {
        initHardwareInfo();
        initBleInfo();
        initAudioInfo();
        initScreenInfo();
    }
 
    @Override
    protected void initEvent() {
    }
 
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(UpdateEvent event) {
        // Required by BaseActivity's EventBus registration
    }
 
    private void initHardwareInfo() {
        QMUIGroupListView.newSection(this)
                .setTitle("硬件信息")
                .addItemView(createItem("设备名称", Build.DEVICE), null)
                .addItemView(createItem("Android 版本", Build.VERSION.RELEASE), null)
                .addItemView(createItem("制造商", Build.MANUFACTURER), null)
                .addItemView(createItem("型号", Build.MODEL), null)
                .addItemView(createItem("构建版本", Build.DISPLAY), null)
                .addItemView(createItem("主板", Build.BOARD), null)
                .addItemView(createItem("产品名", Build.PRODUCT), null)
                .addTo(mGroupHardware);
    }
 
    private void initBleInfo() {
        PackageManager pm = getPackageManager();
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 
        boolean isBleSupported = pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
        
        QMUIGroupListView.Section section = QMUIGroupListView.newSection(this)
                .setTitle("低功耗蓝牙");
 
        section.addItemView(createItem("支持 BLE", isBleSupported ? "是" : "否", isBleSupported), null);
        
        if (adapter != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                boolean isOffloadedFilteringSupported = adapter.isOffloadedFilteringSupported();
                boolean isOffloadedScanBatchingSupported = adapter.isOffloadedScanBatchingSupported();
                boolean isMultipleAdvertisementSupported = adapter.isMultipleAdvertisementSupported();
                
                section.addItemView(createItem("支持脱机过滤", isOffloadedFilteringSupported ? "是" : "否", isOffloadedFilteringSupported), null);
                section.addItemView(createItem("支持脱机扫描批处理", isOffloadedScanBatchingSupported ? "是" : "否", isOffloadedScanBatchingSupported), null);
                section.addItemView(createItem("支持多重广播", isMultipleAdvertisementSupported ? "是" : "否", isMultipleAdvertisementSupported), null);
            }
            
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                boolean isLe2MPhySupported = adapter.isLe2MPhySupported();
                boolean isLeCodedPhySupported = adapter.isLeCodedPhySupported();
                boolean isLeExtendedAdvertisingSupported = adapter.isLeExtendedAdvertisingSupported();
                boolean isLePeriodicAdvertisingSupported = adapter.isLePeriodicAdvertisingSupported();
 
                section.addItemView(createItem("支持高速 (PHY 2M)", isLe2MPhySupported ? "是" : "否", isLe2MPhySupported), null);
                section.addItemView(createItem("支持远距离 (PHY Coded)", isLeCodedPhySupported ? "是" : "否", isLeCodedPhySupported), null);
                section.addItemView(createItem("支持扩展广播", isLeExtendedAdvertisingSupported ? "是" : "否", isLeExtendedAdvertisingSupported), null);
                section.addItemView(createItem("支持周期性广播", isLePeriodicAdvertisingSupported ? "是" : "否", isLePeriodicAdvertisingSupported), null);
            }
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                 int maxDataLength = adapter.isLeExtendedAdvertisingSupported() ? 1650 : 31;
                 section.addItemView(createItem("最大广播数据长度", String.valueOf(maxDataLength)), null);
             }
        }
 
        section.addTo(mGroupBle);
    }
 
    private void initAudioInfo() {
        QMUIGroupListView.newSection(this)
                .setTitle("蓝牙音频")
                .addItemView(createItem("支持 LE Audio", "否", false), null)
                .addItemView(createItem("支持 LE 广播源", "否", false), null)
                .addItemView(createItem("支持 LE 广播助手", "否", false), null)
                .addItemView(createItem("最大连接音频设备数", "0"), null)
                .addTo(mGroupAudio);
    }
 
    private void initScreenInfo() {
        android.util.DisplayMetrics dm = getResources().getDisplayMetrics();
        int screenWidth = dm.widthPixels;
        int screenHeight = dm.heightPixels;
        float density = dm.density;
        int densityDpi = dm.densityDpi;
        
        QMUIGroupListView.newSection(this)
                .setTitle("屏幕信息")
                .addItemView(createItem("分辨率", screenWidth + " x " + screenHeight), null)
                .addItemView(createItem("密度", density + " (" + densityDpi + " dpi)"), null)
                .addTo(mGroupScreen);
    }
 
    private QMUICommonListItemView createItem(String title, String detail) {
        return createItem(title, detail, true);
    }
 
    private QMUICommonListItemView createItem(String title, String detail, boolean isSupported) {
        QMUICommonListItemView item = mGroupHardware.createItemView(title);
        item.setOrientation(QMUICommonListItemView.HORIZONTAL);
        item.setDetailText(detail);
        return item;
    }
}