From 3c5011c2c4f9bf583cd3a4f288a18ba85a888977 Mon Sep 17 00:00:00 2001 From: OHMAE Ryosuke Date: Wed, 7 Jun 2017 23:56:20 +0900 Subject: [PATCH] remove tag --- lib/src/main/java/net/mm2d/upnp/Action.java | 6 ++---- lib/src/main/java/net/mm2d/upnp/ControlPoint.java | 12 +++++------- lib/src/main/java/net/mm2d/upnp/DeviceHolder.java | 3 +-- lib/src/main/java/net/mm2d/upnp/EventReceiver.java | 4 +--- lib/src/main/java/net/mm2d/upnp/HttpClient.java | 3 +-- lib/src/main/java/net/mm2d/upnp/HttpMessage.java | 9 ++++----- lib/src/main/java/net/mm2d/upnp/Service.java | 14 ++++++-------- .../java/net/mm2d/upnp/SsdpNotifyReceiver.java | 4 +--- .../java/net/mm2d/upnp/SsdpNotifyReceiverList.java | 3 +-- .../java/net/mm2d/upnp/SsdpSearchServerList.java | 3 +-- lib/src/main/java/net/mm2d/upnp/SsdpServer.java | 8 +++----- .../main/java/net/mm2d/upnp/SubscribeHolder.java | 3 +-- lib/src/main/java/net/mm2d/util/Log.java | 4 ++-- 13 files changed, 29 insertions(+), 47 deletions(-) diff --git a/lib/src/main/java/net/mm2d/upnp/Action.java b/lib/src/main/java/net/mm2d/upnp/Action.java index 1dda902b..00ee8ed9 100644 --- a/lib/src/main/java/net/mm2d/upnp/Action.java +++ b/lib/src/main/java/net/mm2d/upnp/Action.java @@ -46,8 +46,6 @@ * @author 大前良介(OHMAE Ryosuke) */ public class Action { - private static final String TAG = Action.class.getSimpleName(); - /** * ServiceDescriptionのパース時に使用するビルダー * @@ -365,7 +363,7 @@ private Map invokeInner(@Nonnull final String soap) final HttpClient client = createHttpClient(); final HttpResponse response = client.post(request); if (response.getStatus() != Http.Status.HTTP_OK || response.getBody() == null) { - Log.w(TAG, response.toString()); + Log.w(response.toString()); throw new IOException(response.getStartLine()); } try { @@ -512,7 +510,7 @@ private Map parseResponse(@Nonnull final String xml) final String text = node.getTextContent(); if (findArgument(tag) == null) { // Optionalな情報としてArgumentに記述されていないタグが含まれる可能性があるためログ出力に留める - Log.d(TAG, "invalid argument:" + tag + "->" + text); + Log.d("invalid argument:" + tag + "->" + text); } result.put(tag, text); } diff --git a/lib/src/main/java/net/mm2d/upnp/ControlPoint.java b/lib/src/main/java/net/mm2d/upnp/ControlPoint.java index 2a9cc51e..5ee3b7f0 100644 --- a/lib/src/main/java/net/mm2d/upnp/ControlPoint.java +++ b/lib/src/main/java/net/mm2d/upnp/ControlPoint.java @@ -40,8 +40,6 @@ * @author 大前良介(OHMAE Ryosuke) */ public class ControlPoint { - private static final String TAG = ControlPoint.class.getSimpleName(); - /** * 機器発見イベント通知用リスナー。 * @@ -226,7 +224,7 @@ public void run() { private void notifyEvent(@Nullable final String name, @Nullable final String value) { final StateVariable variable = mService.findStateVariable(name); if (variable == null || !variable.isSendEvents() || value == null) { - Log.w(TAG, "illegal notify argument:" + name + " " + value); + Log.w("illegal notify argument:" + name + " " + value); return; } mNotifyEventListenerList.onNotifyEvent(mService, mSeq, variable.getName(), value); @@ -380,7 +378,7 @@ public void terminate() { mCachedThreadPool.shutdownNow(); } } catch (final InterruptedException e) { - Log.w(TAG, e); + Log.w(e); } mSubscribeHolder.shutdownRequest(); mDeviceHolder.shutdownRequest(); @@ -404,8 +402,8 @@ public void start() { } try { mEventReceiver.open(); - } catch (final IOException e1) { - Log.w(TAG, e1); + } catch (final IOException e) { + Log.w(e); } mSearchList.openAndStart(); mNotifyList.openAndStart(); @@ -432,7 +430,7 @@ public void run() { try { service.unsubscribe(); } catch (final IOException e) { - Log.w(TAG, e); + Log.w(e); } } }); diff --git a/lib/src/main/java/net/mm2d/upnp/DeviceHolder.java b/lib/src/main/java/net/mm2d/upnp/DeviceHolder.java index c080e1b3..6f0ae1f5 100644 --- a/lib/src/main/java/net/mm2d/upnp/DeviceHolder.java +++ b/lib/src/main/java/net/mm2d/upnp/DeviceHolder.java @@ -25,7 +25,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class DeviceHolder implements Runnable { - private static final String TAG = DeviceHolder.class.getSimpleName(); private static final long MARGIN_TIME = TimeUnit.SECONDS.toMillis(10); @Nonnull @@ -55,7 +54,7 @@ class DeviceHolder implements Runnable { void start() { mShutdownRequest = false; synchronized (mThreadLock) { - mThread = new Thread(this, TAG); + mThread = new Thread(this, getClass().getSimpleName()); mThread.start(); } } diff --git a/lib/src/main/java/net/mm2d/upnp/EventReceiver.java b/lib/src/main/java/net/mm2d/upnp/EventReceiver.java index 8e5886d0..a33a98a0 100644 --- a/lib/src/main/java/net/mm2d/upnp/EventReceiver.java +++ b/lib/src/main/java/net/mm2d/upnp/EventReceiver.java @@ -41,8 +41,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class EventReceiver { - private static final String TAG = EventReceiver.class.getSimpleName(); - /** * イベントデータの受信を受け取るリスナー。 */ @@ -326,7 +324,7 @@ public void run() { os = mSocket.getOutputStream(); receiveAndReply(is, os); } catch (final IOException e) { - Log.w(TAG, e); + Log.w(e); } finally { IoUtils.closeQuietly(is); IoUtils.closeQuietly(os); diff --git a/lib/src/main/java/net/mm2d/upnp/HttpClient.java b/lib/src/main/java/net/mm2d/upnp/HttpClient.java index e3640169..f6bf9b06 100644 --- a/lib/src/main/java/net/mm2d/upnp/HttpClient.java +++ b/lib/src/main/java/net/mm2d/upnp/HttpClient.java @@ -38,7 +38,6 @@ * @author 大前良介(OHMAE Ryosuke) */ public class HttpClient { - private static final String TAG = HttpClient.class.getSimpleName(); private static final int REDIRECT_MAX = 2; @Nullable private Socket mSocket; @@ -275,7 +274,7 @@ public HttpResponse download(@Nonnull final URL url) throws IOException { final HttpRequest request = makeHttpRequest(url); final HttpResponse response = post(request); if (response.getStatus() != Http.Status.HTTP_OK || TextUtils.isEmpty(response.getBody())) { - Log.i(TAG, "request:" + request.toString() + "\nresponse:" + response.toString()); + Log.i("request:" + request.toString() + "\nresponse:" + response.toString()); throw new IOException(response.getStartLine()); } return response; diff --git a/lib/src/main/java/net/mm2d/upnp/HttpMessage.java b/lib/src/main/java/net/mm2d/upnp/HttpMessage.java index 348aa333..b76a29e5 100644 --- a/lib/src/main/java/net/mm2d/upnp/HttpMessage.java +++ b/lib/src/main/java/net/mm2d/upnp/HttpMessage.java @@ -38,7 +38,6 @@ * @see HttpRequest */ public abstract class HttpMessage { - private static final String TAG = HttpMessage.class.getSimpleName(); private static final int BUFFER_SIZE = 1500; private static final int DEFAULT_CHUNK_SIZE = 1024; private static final int CR = 0x0d; @@ -269,7 +268,7 @@ public int getContentLength() { try { return Integer.parseInt(len); } catch (final NumberFormatException e) { - Log.w(TAG, e); + Log.w(e); } } return 0; @@ -325,7 +324,7 @@ private void setBodyInner(@Nullable final String string, try { mBodyBinary = string.getBytes(CHARSET); } catch (final UnsupportedEncodingException e) { - Log.w(TAG, e); + Log.w(e); } } if (withContentLength) { @@ -345,7 +344,7 @@ public String getBody() { try { mBody = new String(mBodyBinary, CHARSET); } catch (final UnsupportedEncodingException e) { - Log.w(TAG, e); + Log.w(e); } } return mBody; @@ -399,7 +398,7 @@ private byte[] getHeaderBytes() { try { return getHeaderString().getBytes(CHARSET); } catch (final UnsupportedEncodingException e) { - Log.w(TAG, e); + Log.w(e); } return new byte[0]; } diff --git a/lib/src/main/java/net/mm2d/upnp/Service.java b/lib/src/main/java/net/mm2d/upnp/Service.java index dbb8cae5..c458af97 100644 --- a/lib/src/main/java/net/mm2d/upnp/Service.java +++ b/lib/src/main/java/net/mm2d/upnp/Service.java @@ -30,8 +30,6 @@ * @author 大前良介(OHMAE Ryosuke) */ public class Service { - private static final String TAG = Service.class.getSimpleName(); - /** * DeviceDescriptionのパース時に使用するビルダー */ @@ -482,7 +480,7 @@ private static long parseTimeout(@Nonnull final HttpResponse response) { final int second = Integer.parseInt(secondSection); return TimeUnit.SECONDS.toMillis(second); } catch (final NumberFormatException e) { - Log.w(TAG, e); + Log.w(e); } return DEFAULT_SUBSCRIPTION_TIMEOUT; } @@ -533,7 +531,7 @@ private boolean subscribeInner(final boolean keepRenew) throws IOException { final HttpRequest request = makeSubscribeRequest(); final HttpResponse response = client.post(request); if (response.getStatus() != Http.Status.HTTP_OK) { - Log.w(TAG, "subscribe request:" + request.toString() + "\nresponse:" + response.toString()); + Log.w("subscribe request:" + request.toString() + "\nresponse:" + response.toString()); return false; } if (parseSubscribeResponse(response)) { @@ -547,7 +545,7 @@ private boolean parseSubscribeResponse(@Nonnull final HttpResponse response) { final String sid = response.getHeader(Http.SID); final long timeout = parseTimeout(response); if (TextUtils.isEmpty(sid) || timeout == 0) { - Log.w(TAG, "subscribe response:" + response.toString()); + Log.w("subscribe response:" + response.toString()); return false; } mSubscriptionId = sid; @@ -591,7 +589,7 @@ private boolean renewSubscribeInner() throws IOException { final HttpRequest request = makeRenewSubscribeRequest(mSubscriptionId); final HttpResponse response = client.post(request); if (response.getStatus() != Http.Status.HTTP_OK) { - Log.w(TAG, "renewSubscribe request:" + request.toString() + "\nresponse:" + response.toString()); + Log.w("renewSubscribe request:" + request.toString() + "\nresponse:" + response.toString()); return false; } return parseRenewSubscribeResponse(response); @@ -601,7 +599,7 @@ private boolean parseRenewSubscribeResponse(@Nonnull final HttpResponse response final String sid = response.getHeader(Http.SID); final long timeout = parseTimeout(response); if (!TextUtils.equals(sid, mSubscriptionId) || timeout == 0) { - Log.w(TAG, "renewSubscribe response:" + response.toString()); + Log.w("renewSubscribe response:" + response.toString()); return false; } mSubscriptionStart = System.currentTimeMillis(); @@ -635,7 +633,7 @@ public boolean unsubscribe() throws IOException { final HttpRequest request = makeUnsubscribeRequest(mSubscriptionId); final HttpResponse response = client.post(request); if (response.getStatus() != Http.Status.HTTP_OK) { - Log.w(TAG, "unsubscribe request:" + request.toString() + "\nresponse:" + response.toString()); + Log.w("unsubscribe request:" + request.toString() + "\nresponse:" + response.toString()); return false; } mControlPoint.unregisterSubscribeService(this); diff --git a/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiver.java b/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiver.java index a1e2777d..73ba23ae 100644 --- a/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiver.java +++ b/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiver.java @@ -24,8 +24,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class SsdpNotifyReceiver extends SsdpServer { - private static final String TAG = SsdpNotifyReceiver.class.getSimpleName(); - /** * NOTIFY受信を受け取るリスナー。 */ @@ -66,7 +64,7 @@ protected void onReceive(@Nonnull final InetAddress sourceAddress, // セグメント情報が間違っており、マルチキャスト以外のやり取りができない相手からのパケットは // 受け取っても無駄なので破棄する。 if (!isSameSegment(getInterfaceAddress(), sourceAddress)) { - Log.w(TAG, "Invalid segment packet received:" + sourceAddress.toString() + Log.w("Invalid segment packet received:" + sourceAddress.toString() + " " + getInterfaceAddress().toString()); return; } diff --git a/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiverList.java b/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiverList.java index 12d88e31..1ed70398 100644 --- a/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiverList.java +++ b/lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiverList.java @@ -24,7 +24,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class SsdpNotifyReceiverList { - private static final String TAG = SsdpNotifyReceiverList.class.getSimpleName(); @Nonnull private final List mList; @@ -44,7 +43,7 @@ void openAndStart() { receiver.open(); receiver.start(); } catch (final IOException e) { - Log.w(TAG, e); + Log.w(e); } } } diff --git a/lib/src/main/java/net/mm2d/upnp/SsdpSearchServerList.java b/lib/src/main/java/net/mm2d/upnp/SsdpSearchServerList.java index a8f1e858..b77ce153 100644 --- a/lib/src/main/java/net/mm2d/upnp/SsdpSearchServerList.java +++ b/lib/src/main/java/net/mm2d/upnp/SsdpSearchServerList.java @@ -25,7 +25,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class SsdpSearchServerList { - private static final String TAG = SsdpSearchServerList.class.getSimpleName(); @Nonnull private final List mList; @@ -45,7 +44,7 @@ void openAndStart() { server.open(); server.start(); } catch (final IOException e) { - Log.w(TAG, e); + Log.w(e); } } } diff --git a/lib/src/main/java/net/mm2d/upnp/SsdpServer.java b/lib/src/main/java/net/mm2d/upnp/SsdpServer.java index 2d33269a..08e1f596 100644 --- a/lib/src/main/java/net/mm2d/upnp/SsdpServer.java +++ b/lib/src/main/java/net/mm2d/upnp/SsdpServer.java @@ -32,7 +32,6 @@ */ // TODO: SocketChannelを使用した受信(MulticastChannelはAndroid N以降のため保留) abstract class SsdpServer { - private static final String TAG = SsdpServer.class.getSimpleName(); /** * SSDPに使用するアドレス。 */ @@ -112,7 +111,7 @@ void open() throws IOException { } @Nonnull - // VisibleForTesting + // VisibleForTesting MulticastSocket createMulticastSocket(final int port) throws IOException { return new MulticastSocket(port); } @@ -171,7 +170,7 @@ void send(@Nonnull final SsdpMessage message) { message.getMessage().writeData(baos); send(baos.toByteArray()); } catch (final IOException e) { - Log.w(TAG, e); + Log.w(e); } } @@ -194,7 +193,6 @@ private void send(@Nonnull final byte[] message) throws IOException { protected abstract void onReceive(@Nonnull InetAddress sourceAddress, @Nonnull byte[] data, int length); private static class ReceiveTask implements Runnable { - private static final String TAG = ReceiveTask.class.getSimpleName(); @Nonnull private final SsdpServer mSsdpServer; @Nonnull @@ -220,7 +218,7 @@ private static class ReceiveTask implements Runnable { */ synchronized void start() { mShutdownRequest = false; - mThread = new Thread(this, TAG); + mThread = new Thread(this, getClass().getSimpleName()); mThread.start(); } diff --git a/lib/src/main/java/net/mm2d/upnp/SubscribeHolder.java b/lib/src/main/java/net/mm2d/upnp/SubscribeHolder.java index 1b5d8cf2..e26ba7c3 100644 --- a/lib/src/main/java/net/mm2d/upnp/SubscribeHolder.java +++ b/lib/src/main/java/net/mm2d/upnp/SubscribeHolder.java @@ -26,7 +26,6 @@ * @author 大前良介(OHMAE Ryosuke) */ class SubscribeHolder implements Runnable { - private static final String TAG = SubscribeHolder.class.getSimpleName(); private static final long MIN_INTERVAL = TimeUnit.SECONDS.toMillis(1); private final Object mThreadLock = new Object(); @@ -45,7 +44,7 @@ class SubscribeHolder implements Runnable { void start() { mShutdownRequest = false; synchronized (mThreadLock) { - mThread = new Thread(this, TAG); + mThread = new Thread(this, getClass().getSimpleName()); mThread.start(); } } diff --git a/lib/src/main/java/net/mm2d/util/Log.java b/lib/src/main/java/net/mm2d/util/Log.java index 3b99bcc4..e45b0c3f 100644 --- a/lib/src/main/java/net/mm2d/util/Log.java +++ b/lib/src/main/java/net/mm2d/util/Log.java @@ -145,7 +145,7 @@ public static void setLogLevel(final int level) { * * @param append 追加する場合true */ - public static void setAppendCaller(boolean append) { + public static void setAppendCaller(final boolean append) { sAppendCaller = append; } @@ -398,7 +398,7 @@ private static void println( } @Nonnull - private static String makeTag(@Nullable final String tag, @Nullable StackTraceElement element) { + private static String makeTag(@Nullable final String tag, @Nullable final StackTraceElement element) { if (tag != null) { return tag; }