LocalDeviceImpl.javaAPI DocphoneME MR2 API (J2ME)9692Wed May 02 18:00:32 BST 2007com.sun.kvem.jsr082.bluetooth


public final class LocalDeviceImpl extends Object
The LocalDeviceImpl class is a LocalDevice API class implementation. This is a singleton class.

Fields Summary
private static final boolean
Set to false in RR version - then the javac skip the code.
private static LocalDeviceImpl
Keeps this singleton object.
private String
Keeps bluetooth address of this device.
private CancelerOfLIAC
Timeout canceller of limited discoverable mode.
Constructors Summary
private LocalDeviceImpl()
Constructs the only instance of LocalDeviceImpl.

Methods Summary
public java.lang.StringgetBluetoothAddress()

        return BCC.getInstance().getBluetoothAddress();
public javax.bluetooth.DeviceClassgetDeviceClass()

        return BCC.getInstance().getDeviceClass();
public intgetDiscoverable()

        return BCC.getInstance().getAccessCode();
public java.lang.StringgetFriendlyName()

        return BCC.getInstance().getFriendlyName();
public static synchronized com.sun.kvem.jsr082.bluetooth.LocalDeviceImplgetInstance()
Retrieves singleton instance.

the only instance of LocalDeviceImpl
BluetoothStateException if an error occured.

        if (instance == null) {
            instance = new LocalDeviceImpl();
        return instance;
public java.lang.StringgetProperty(java.lang.String property)

        return System.getProperty(property);
public javax.bluetooth.ServiceRecordgetRecord( notifier)

        if (notifier == null) {
            throw new NullPointerException("Null notifier specified.");
        if (!(notifier instanceof BluetoothNotifier)) {
            if (!(notifier instanceof SessionNotifierImpl)) {
                throw new IllegalArgumentException("Invalid notifier class.");
            Connection transport =
            if (!(transport instanceof BluetoothNotifier)) {
                throw new IllegalArgumentException("Invalid notifier class.");
            return ((BluetoothNotifier)transport).getServiceRecord();
        return ((BluetoothNotifier)notifier).getServiceRecord();
public booleanisPowerOn()
Checks if Bluetooth device is turned on.

true is the Bluetooth device is on, false otherwise.

        return BCC.getInstance().isBluetoothEnabled();
public booleansetDiscoverable(int accessCode)

        // Check if the specified mode has a valid value
        if (accessCode != DiscoveryAgent.GIAC &&
                accessCode != DiscoveryAgent.LIAC &&
                accessCode != DiscoveryAgent.NOT_DISCOVERABLE &&
                (accessCode < 0x9E8B00 || accessCode > 0x9E8B3F)) {
            throw new IllegalArgumentException("Access code is out of range: "
                    + "0x" + Integer.toHexString(accessCode).toUpperCase());
        synchronized (cancelerOfLIAC) {
             * Accroding to the spec, the device should only be limited
             * discoverable (DiscoveryAgent.LIAC) for 1 minute -
             * then back to the PREVIOUS discoverable mode.
            int oldAccessCode = BCC.getInstance().getAccessCode();
            if (BCC.getInstance().setAccessCode(accessCode)) {
                cancelerOfLIAC.notifyNewAccessCode(oldAccessCode, accessCode);
                if (accessCode != DiscoveryAgent.NOT_DISCOVERABLE) {
                    // Start SDDB if discoverable mode was set successfully
                    // IMPL_NOTE: Do we really need this step?
                return true;
        return false;
public voidupdateRecord(javax.bluetooth.ServiceRecord srvRecord)

        if (DEBUG) {
        if (srvRecord == null) {
            throw new NullPointerException("Null record specified.");
        if (!(srvRecord instanceof ServiceRecordImpl)) {
            throw new IllegalArgumentException("Invalid service record class.");
        ServiceRecordImpl record = (ServiceRecordImpl)srvRecord;
        BluetoothNotifier notifier = record.getNotifier();
        if (notifier == null) {
            throw new IllegalArgumentException(
                    "Service record is not from local SDDB.");