huangcm
2025-04-09 02d4ce54b909bd733f12e9f3fa4c1b03cf2d6f45
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
package com.rockchip.dmi;
 
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.SystemClock;
 
public class DmiUtil {
 
   static {
       System.loadLibrary("getdmi");
   }
 
   private static native Object[] getdmi();
 
   public static DmiInfo getDmiInfo(Context context, boolean regain) {
       DmiInfo dmiInfo = null;
       
       // use the cached infos.
       if (!regain) {
           dmiInfo = DmiInfo.getInstance();
       }
       
       // try to get infos.
       if (null == dmiInfo) {
           // enable wifi to get the mac addr.
           WifiManager wifiManager = (WifiManager) context
                   .getSystemService(Context.WIFI_SERVICE);
           boolean wifiEnabled = wifiManager.isWifiEnabled();
           if (!wifiEnabled) {
               wifiManager.setWifiEnabled(true);
           }
           
           SystemClock.sleep(500);
           dmiInfo = DmiInfo.getInstance(getdmi());
           
           if (!wifiEnabled) {
               wifiManager.setWifiEnabled(false);
           }
       }
       return dmiInfo;
   }
}