Search in sources :

Example 1 with AsyncChannel

use of com.android.internal.util.AsyncChannel in project android_frameworks_base by ParanoidAndroid.

the class MobileDataStateTracker method enableMobileProvisioning.

/**
     *  Inform DCT mobile provisioning has started, it ends when provisioning completes.
     */
public void enableMobileProvisioning(String url) {
    if (DBG)
        log("enableMobileProvisioning(url=" + url + ")");
    final AsyncChannel channel = mDataConnectionTrackerAc;
    if (channel != null) {
        Message msg = Message.obtain();
        msg.what = DctConstants.CMD_ENABLE_MOBILE_PROVISIONING;
        msg.setData(Bundle.forPair(DctConstants.PROVISIONING_URL_KEY, url));
        channel.sendMessage(msg);
    }
}
Also used : Message(android.os.Message) AsyncChannel(com.android.internal.util.AsyncChannel)

Example 2 with AsyncChannel

use of com.android.internal.util.AsyncChannel in project android_frameworks_base by ParanoidAndroid.

the class MobileDataStateTracker method supplyMessenger.

public void supplyMessenger(Messenger messenger) {
    if (VDBG)
        log(mApnType + " got supplyMessenger");
    AsyncChannel ac = new AsyncChannel();
    ac.connect(mContext, MobileDataStateTracker.this.mHandler, messenger);
}
Also used : AsyncChannel(com.android.internal.util.AsyncChannel)

Example 3 with AsyncChannel

use of com.android.internal.util.AsyncChannel in project android_frameworks_base by ParanoidAndroid.

the class MobileDataStateTracker method setPolicyDataEnable.

@Override
public void setPolicyDataEnable(boolean enabled) {
    if (DBG)
        log("setPolicyDataEnable(enabled=" + enabled + ")");
    final AsyncChannel channel = mDataConnectionTrackerAc;
    if (channel != null) {
        channel.sendMessage(DctConstants.CMD_SET_POLICY_DATA_ENABLE, enabled ? DctConstants.ENABLED : DctConstants.DISABLED);
        mPolicyDataEnabled = enabled;
    }
}
Also used : AsyncChannel(com.android.internal.util.AsyncChannel)

Example 4 with AsyncChannel

use of com.android.internal.util.AsyncChannel in project android_frameworks_base by ParanoidAndroid.

the class WifiManager method init.

private void init() {
    synchronized (sThreadRefLock) {
        if (++sThreadRefCount == 1) {
            Messenger messenger = getWifiServiceMessenger();
            if (messenger == null) {
                sAsyncChannel = null;
                return;
            }
            sHandlerThread = new HandlerThread("WifiManager");
            sAsyncChannel = new AsyncChannel();
            sConnected = new CountDownLatch(1);
            sHandlerThread.start();
            Handler handler = new ServiceHandler(sHandlerThread.getLooper());
            sAsyncChannel.connect(mContext, handler, messenger);
            try {
                sConnected.await();
            } catch (InterruptedException e) {
                Log.e(TAG, "interrupted wait at init");
            }
        }
    }
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) AsyncChannel(com.android.internal.util.AsyncChannel) Messenger(android.os.Messenger) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 5 with AsyncChannel

use of com.android.internal.util.AsyncChannel in project platform_frameworks_base by android.

the class ConnectivityService method handleAsyncChannelHalfConnect.

private void handleAsyncChannelHalfConnect(Message msg) {
    AsyncChannel ac = (AsyncChannel) msg.obj;
    if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkFactory connected");
            // A network factory has connected.  Send it all current NetworkRequests.
            for (NetworkRequestInfo nri : mNetworkRequests.values()) {
                if (nri.request.isListen())
                    continue;
                NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
                ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.getCurrentScore() : 0), 0, nri.request);
            }
        } else {
            loge("Error connecting NetworkFactory");
            mNetworkFactoryInfos.remove(msg.obj);
        }
    } else if (mNetworkAgentInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkAgent connected");
            // A network agent has requested a connection.  Establish the connection.
            mNetworkAgentInfos.get(msg.replyTo).asyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
        } else {
            loge("Error connecting NetworkAgent");
            NetworkAgentInfo nai = mNetworkAgentInfos.remove(msg.replyTo);
            if (nai != null) {
                final boolean wasDefault = isDefaultNetwork(nai);
                synchronized (mNetworkForNetId) {
                    mNetworkForNetId.remove(nai.network.netId);
                    mNetIdInUse.delete(nai.network.netId);
                }
                // Just in case.
                mLegacyTypeTracker.remove(nai, wasDefault);
            }
        }
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) AsyncChannel(com.android.internal.util.AsyncChannel)

Aggregations

AsyncChannel (com.android.internal.util.AsyncChannel)31 Handler (android.os.Handler)10 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)10 Messenger (android.os.Messenger)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 LinkProperties (android.net.LinkProperties)5 Network (android.net.Network)5 NetworkCapabilities (android.net.NetworkCapabilities)5 NetworkInfo (android.net.NetworkInfo)5 NetworkMisc (android.net.NetworkMisc)5 Message (android.os.Message)5 HandlerThread (android.os.HandlerThread)1