Title: How can I use org.apache.harmony.luni.platform.OSNewtorkSystem
in Android SDK ?

I'm working with Android SDK 1.5. And I'm programming a application
running on Android Emulator.

This application used a library for communication using TCP/IP.

In debug mode, when create a instance of
org.apache.harmony.nio.internal.PipeImpl class a message that is
"Permission denied (maybe missing INTERNET permission)" is thrown.

----------------------------------------------------------------
public PipeImpl() throws IOException {
        super();
        try {
            sink = new SinkChannelImpl(SelectorProvider.provider
());    <<------------ Here !!!!!
            source = new SourceChannelImpl(SelectorProvider.provider
());
            sink.finishConnect();
            source.accept();
            source.closeServer();
        } catch(IOException ioe){
            reset();
            throw ioe;
        } catch(RuntimeException e){
            reset();
            throw e;
        }
    }
----------------------------------------------------------------

As a result, source that is a field of
org.apache.harmony.nio.interjal.SelectorImpl and which type is
Pipe.SourceChannel is null. Because in a constructor of SelectotrImpl,
Pipe returns null and null is set to source.
----------------------------------------------------------------
public SelectorImpl(SelectorProvider selectorProvider) {
        super(selectorProvider);
        try {
            Pipe mockSelector = selectorProvider.openPipe();
            sink = mockSelector.sink();
            source = mockSelector.source();
<<---------------------------------  Here !!!!!!!!!!!!!
            sourcefd = ((FileDescriptorHandler)source).getFD();
            source.configureBlocking(false);
        } catch (IOException e) {
            // do nothing
        }
    }
----------------------------------------------------------------

Finally, in SelectorImpl.prepareChannels(), NullPointerException is
thrown.
----------------------------------------------------------------
private void prepareChannels() {
        readableFDs.add(sourcefd);
        List<SelectionKey> readChannelList = new
ArrayList<SelectionKey>();
        readChannelList.add(source.keyFor(this));
<<--------------------------------    Here !!!!!!!!!!
        List<SelectionKey> writeChannelList = new
ArrayList<SelectionKey>();
        synchronized (keysLock) {
            for (Iterator<SelectionKey> i = keys.iterator(); i.hasNext
();) {
                SelectionKeyImpl key = (SelectionKeyImpl) i.next();
                key.oldInterestOps = key.interestOps();
                boolean isReadableChannel = ((SelectionKey.OP_ACCEPT |
SelectionKey.OP_READ) & key.oldInterestOps) != 0;
                boolean isWritableChannel = ((SelectionKey.OP_CONNECT
| SelectionKey.OP_WRITE) & key.oldInterestOps) != 0;
                SelectableChannel channel = key.channel
();
                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)
channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)
channel).getFD());
                }
            }
        }
        readableChannels = readChannelList.toArray(new SelectionKey
[0]);
        writableChannels = writeChannelList.toArray(new SelectionKey
[0]);
        readable = readableFDs.toArray(new FileDescriptor[0]);
        writable = writableFDs.toArray(new FileDescriptor[0]);
    }
----------------------------------------------------------------

Please, Help me!!!!

I really really thank you for your advance!!!!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to