summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorSohani Rao <sohanirao@google.com>2016-11-10 22:48:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-11-10 22:48:48 +0000
commita541bf342d7014f6ca9dde2194e0304e1553cee0 (patch)
tree847986b5a96ada94320dfccf0f07de8d565de1a1 /service
parent573654d47ace707f0cae2a50462dce05feef30d0 (diff)
parentcda805612a020057f7363b8e89be72ca9d6958f9 (diff)
Merge "Async Channel with Logging for Wifi Services"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java6
-rw-r--r--service/java/com/android/server/wifi/util/WifiAsyncChannel.java98
2 files changed, 101 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 876356271..e3e56c8d3 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -82,6 +82,7 @@ import com.android.server.wifi.WifiInjector;
import com.android.server.wifi.WifiMonitor;
import com.android.server.wifi.WifiNative;
import com.android.server.wifi.WifiStateMachine;
+import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiPermissionsUtil;
import java.io.FileDescriptor;
@@ -114,7 +115,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private DhcpResults mDhcpResults;
private P2pStateMachine mP2pStateMachine;
- private AsyncChannel mReplyChannel = new AsyncChannel();
+ private AsyncChannel mReplyChannel = new WifiAsyncChannel(TAG);
private AsyncChannel mWifiChannel;
private static final Boolean JOIN_GROUP = true;
@@ -371,7 +372,6 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
HandlerThread wifiP2pThread = new HandlerThread("WifiP2pService");
wifiP2pThread.start();
mClientHandler = new ClientHandler(wifiP2pThread.getLooper());
-
mP2pStateMachine = new P2pStateMachine(TAG, wifiP2pThread.getLooper(), mP2pSupported);
mP2pStateMachine.start();
}
@@ -700,7 +700,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
break;
case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION:
- AsyncChannel ac = new AsyncChannel();
+ AsyncChannel ac = new WifiAsyncChannel(TAG);
ac.connect(mContext, getHandler(), message.replyTo);
break;
case BLOCK_DISCOVERY:
diff --git a/service/java/com/android/server/wifi/util/WifiAsyncChannel.java b/service/java/com/android/server/wifi/util/WifiAsyncChannel.java
new file mode 100644
index 000000000..ccdfb522f
--- /dev/null
+++ b/service/java/com/android/server/wifi/util/WifiAsyncChannel.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi.util;
+
+import android.annotation.NonNull;
+import android.os.Message;
+
+import com.android.internal.util.AsyncChannel;
+import com.android.server.wifi.WifiInjector;
+import com.android.server.wifi.WifiLog;
+
+/**
+ * This class subclasses AsyncChannel and adds logging
+ * to the sendMessage() API
+ */
+public class WifiAsyncChannel extends AsyncChannel {
+ private static final String LOG_TAG = "WifiAsyncChannel";
+ private WifiLog mLog;
+ private String mTag;
+ /**
+ * AsyncChannelWithLogging constructor
+ */
+ public WifiAsyncChannel(String serviceTag) {
+ mTag = LOG_TAG + "." + serviceTag;
+ }
+
+ @NonNull
+ private WifiLog getOrInitLog() {
+ // Lazy initization of mLog
+ if (mLog == null) {
+ mLog = WifiInjector.getInstance().makeLog(mTag);
+ }
+ return mLog;
+ }
+
+ /**
+ * Send a message to the destination handler.
+ *
+ * @param msg
+ */
+ @Override
+ public void sendMessage(Message msg) {
+ getOrInitLog().trace("sendMessage message=%")
+ .c(msg.what)
+ .flush();
+ super.sendMessage(msg);
+ }
+
+ /**
+ * Reply to srcMsg
+ *
+ * @param srcMsg
+ * @param dstMsg
+ */
+ @Override
+ public void replyToMessage(Message srcMsg, Message dstMsg) {
+ getOrInitLog()
+ .trace("replyToMessage recvdMessage=% sendingUid=% sentMessage=%")
+ .c(srcMsg.what)
+ .c(srcMsg.sendingUid)
+ .c(dstMsg.what)
+ .flush();
+ super.replyToMessage(srcMsg, dstMsg);
+ }
+
+ /**
+ * Send the Message synchronously.
+ *
+ * @param msg to send
+ * @return reply message or null if an error.
+ */
+ @Override
+ public Message sendMessageSynchronously(Message msg) {
+ getOrInitLog().trace("sendMessageSynchronously.send message=%")
+ .c(msg.what)
+ .flush();
+ Message replyMessage = super.sendMessageSynchronously(msg);
+ getOrInitLog().trace("sendMessageSynchronously.recv message=% sendingUid=%")
+ .c(replyMessage.what)
+ .c(replyMessage.sendingUid)
+ .flush();
+ return replyMessage;
+ }
+}