SystemUtil

public class SystemUtil

A utility class that binds to a generic service to provide access to INI configuration and device information. This class manages its own service connection lifecycle and ensures safe access by returning default values until the service is connected. Integrators can register a callback to be notified when the service is ready.

Example usage with setObserver:

SystemUtil systemUtil = new SystemUtil(context);
SystemUtil.setObserver(activity, isReady -> {
    if (isReady) {
        String mac = systemUtil.getMacAddress();
        String serial = serviceUtil.getSerialNumber();
        Log.d("Client", "Service ready - MAC: " + mac + ", Serial: " + serial);
    } else {
        Log.d("Client", "Service not ready yet");
    }
});

Constructors

Link copied to clipboard
public void SystemUtil(Context context)
Constructs a new SystemUtil instance and binds to the specified service.

Functions

Link copied to clipboard
public String getIni(String key, String defaultValue)
Retrieves an INI configuration value from the service.
Link copied to clipboard
Retrieves the device's MAC address from the service.
Link copied to clipboard
public boolean getReady()
Checks if the service is currently connected and ready for use.
Link copied to clipboard
Retrieves the device's serial number from the service.
Link copied to clipboard
public void release()
Releases the service connection and clears callbacks.
Link copied to clipboard
public void removeObserver(Observer<Boolean> observer)
Removes a previously registered observer from monitoring the service connection state.
Link copied to clipboard
public void setObserver(LifecycleOwner owner, Observer<Boolean> observer)
Registers an observer to monitor the service connection state.