Skip to content

Commit

Permalink
Removed seamless-android dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bauer committed Nov 6, 2014
1 parent e29b545 commit 0f285df
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If your build fails with Android/dex packaging errors, you forgot the clean.
<dependency>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-core</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
</dependencies>
````
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Core</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright (C) 2008 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 org.fourthline.cling.android;

import android.util.Log;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;

/*
Taken from: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/com/android/internal/logging/AndroidHandler.java;hb=c2ad241504fcaa12d4579d3b0b4038d1ca8d08c9
*/
public class FixedAndroidLogHandler extends Handler {
/**
* Holds the formatter for all Android log handlers.
*/
private static final Formatter THE_FORMATTER = new Formatter() {
@Override
public String format(LogRecord r) {
Throwable thrown = r.getThrown();
if (thrown != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
sw.write(r.getMessage());
sw.write("\n");
thrown.printStackTrace(pw);
pw.flush();
return sw.toString();
} else {
return r.getMessage();
}
}
};

/**
* Constructs a new instance of the Android log handler.
*/
public FixedAndroidLogHandler() {
setFormatter(THE_FORMATTER);
}

@Override
public void close() {
// No need to close, but must implement abstract method.
}

@Override
public void flush() {
// No need to flush, but must implement abstract method.
}

@Override
public void publish(LogRecord record) {
try {
int level = getAndroidLevel(record.getLevel());
String tag = record.getLoggerName();

if (tag == null) {
// Anonymous logger.
tag = "null";
} else {
// Tags must be <= 23 characters.
int length = tag.length();
if (length > 23) {
// Most loggers use the full class name. Try dropping the
// package.
int lastPeriod = tag.lastIndexOf(".");
if (length - lastPeriod - 1 <= 23) {
tag = tag.substring(lastPeriod + 1);
} else {
// Use last 23 chars.
tag = tag.substring(tag.length() - 23);
}
}
}

/* ############################################################################################
Instead of using the perfectly fine java.util.logging API for setting the
loggable levels, this call relies on a totally obscure "local.prop" file which you have to place on
your device. By default, if you do not have that file and if you do not execute some magic
"setprop" commands on your device, only INFO/WARN/ERROR is loggable. So whatever you do with
java.util.logging.Logger.setLevel(...) doesn't have any effect. The debug messages might arrive
here but they are dropped because you _also_ have to set the Android internal logging level with
the aforementioned magic switches.
Also, consider that you have to understand how a JUL logger name is mapped to the "tag" of
the Android log. Basically, the whole cutting and cropping procedure above is what you have to
memorize if you want to log with JUL and configure Android for debug output.
I actually admire the pure evil of this setup, even Mr. Ceki can learn something!
Commenting out these lines makes it all work as expected:
if (!Log.isLoggable(tag, level)) {
return;
}
############################################################################################### */

String message = getFormatter().format(record);
Log.println(level, tag, message);
} catch (RuntimeException e) {
Log.e("AndroidHandler", "Error logging message.", e);
}
}

/**
* Converts a {@link java.util.logging.Logger} logging level into an Android one.
*
* @param level The {@link java.util.logging.Logger} logging level.
*
* @return The resulting Android logging level.
*/
static int getAndroidLevel(Level level) {
int value = level.intValue();
if (value >= 1000) { // SEVERE
return Log.ERROR;
} else if (value >= 900) { // WARNING
return Log.WARN;
} else if (value >= 800) { // INFO
return Log.INFO;
} else {
return Log.DEBUG;
}
}

}
2 changes: 1 addition & 1 deletion core/src/manual/android/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
on Android you will not see <code>FINE</code>, <code>FINER</code>, and <code>FINEST</code> log
messages, as their built-in log handler is broken (or, so badly designed that it might as well
be broken). The easiest workaround is to set a custom log handler available in the
<code>seamless-android</code> package.
<code>FixedAndroidLogHandler</code> class.
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion core/src/site/xhtml/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<dependency>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-core</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
</dependencies>]]></pre>

Expand Down
2 changes: 1 addition & 1 deletion demo/android/browser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-demo-android</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Demo Android Browser</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.widget.Toast;
import org.fourthline.cling.android.AndroidUpnpService;
import org.fourthline.cling.android.AndroidUpnpServiceImpl;
import org.fourthline.cling.android.FixedAndroidLogHandler;
import org.fourthline.cling.model.meta.Device;
import org.fourthline.cling.model.meta.LocalDevice;
import org.fourthline.cling.model.meta.RemoteDevice;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void onCreate(Bundle savedInstanceState) {

// Fix the logging integration between java.util.logging and Android internal logging
org.seamless.util.logging.LoggingUtil.resetRootHandler(
new org.seamless.android.FixedAndroidLogHandler()
new FixedAndroidLogHandler()
);
// Now you can enable logging as needed for various categories of Cling:
// Logger.getLogger("org.fourthline.cling").setLevel(Level.FINEST);
Expand Down
2 changes: 1 addition & 1 deletion demo/android/light/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-demo-android</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Demo Android Light</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.widget.Toast;
import org.fourthline.cling.android.AndroidUpnpService;
import org.fourthline.cling.android.AndroidUpnpServiceImpl;
import org.fourthline.cling.android.FixedAndroidLogHandler;
import org.fourthline.cling.binding.LocalServiceBindingException;
import org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder;
import org.fourthline.cling.model.DefaultServiceManager;
Expand Down Expand Up @@ -110,9 +111,9 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// DOC:LOGGING
// Fix the logging integration between java.util.logging and Android internal logging
org.seamless.util.logging.LoggingUtil.resetRootHandler(
new org.seamless.android.FixedAndroidLogHandler()
);
// org.seamless.util.logging.LoggingUtil.resetRootHandler(
// new FixedAndroidLogHandler()
// );
// Logger.getLogger("org.fourthline.cling").setLevel(Level.FINEST);
// DOC:LOGGING

Expand Down
19 changes: 1 addition & 18 deletions demo/android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-demo</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Demo Android</name>
Expand Down Expand Up @@ -52,23 +52,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.seamless</groupId>
<artifactId>seamless-android</artifactId>
<version>${seamless.version}</version>
<!-- Not needed for FixedAndroidLoggingHandler -->
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v13</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Demo</name>
Expand Down
2 changes: 1 addition & 1 deletion distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>cling</artifactId>
<groupId>org.fourthline.cling</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Distribution</name>
Expand Down
7 changes: 1 addition & 6 deletions distribution/src/dist/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ DEPENDENCIES

Required dependencies of Cling Core (included with this distribution):

+- org.fourthline.cling:cling-core:jar:2.0.0
+- org.fourthline.cling:cling-core:jar:2.0.1
+- org.seamless:seamless-util:jar:1.0.0
+- org.seamless:seamless-http:jar:1.0.0
\- org.seamless:seamless-xml:jar:1.0.0
Expand All @@ -76,11 +76,6 @@ Additional dependencies of Cling Core on Android (not included):
+- org.slf4j:slf4j-jdk14:jar:1.6.1 (or any other SLF4J implementation)
\- org.slf4j:slf4j-api:jar:1.6.1

If you need the fixed Android java.util.logging Handler:

+- org.seamless:seamless-android:jar:1.0.0
\- android.support:compatibility-v13:jar:10 (Exclude this in pom.xml)

WARNING: Jetty JAR files each contain an 'about.html' file, you will get
an error when trying to package your application with APK. Use the Android
Maven plugin and set the "extractDuplicates" option or repackage the Jetty
Expand Down
2 changes: 1 addition & 1 deletion mediarenderer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling MediaRenderer</name>
Expand Down
2 changes: 1 addition & 1 deletion mediarenderer/src/site/xhtml/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ java -Djna.library.path=/usr/lib -jar cling-mediarenderer.jar</pre>

<ul>
<li>
<a href="http://www.4thline.org/m2/org/fourthline/cling/cling-mediarenderer/2.0.0/cling-mediarenderer-2.0.0-standalone.jar">JDK 1.6 desktop application (any OS)</a>
<a href="http://www.4thline.org/m2/org/fourthline/cling/cling-mediarenderer/2.0.1/cling-mediarenderer-2.0.1-standalone.jar">JDK 1.6 desktop application (any OS)</a>
</li>
<li>
<a href="http://www.4thline.org/projects/download/">Cling main distribution (incl. Cling Core library)</a>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<groupId>org.fourthline.cling</groupId>
<artifactId>cling</artifactId>
<packaging>pom</packaging>
<version>2.0.0</version>
<version>2.0.1</version>

<modules>
<module>core</module>
Expand Down Expand Up @@ -80,7 +80,7 @@
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>6</maven.compiler.target>

<seamless.version>1.0.0</seamless.version>
<seamless.version>1.1.0</seamless.version>
<lemma.version>1.1.0</lemma.version>
<testng.version>6.2</testng.version>
<apache.httpcomponents.httpclient.version>4.2.2</apache.httpcomponents.httpclient.version>
Expand Down
2 changes: 1 addition & 1 deletion support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Support</name>
Expand Down
2 changes: 1 addition & 1 deletion support/src/site/xhtml/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<dependency>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-support</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
</dependencies>]]></pre>

Expand Down
2 changes: 1 addition & 1 deletion website/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>cling</artifactId>
<groupId>org.fourthline.cling</groupId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<name>Cling Website</name>
Expand Down
2 changes: 1 addition & 1 deletion website/src/site/xhtml/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
-->

<p>
The current release of Cling is <em>2.0.0 (2014-11-05)</em>: <a href="/projects/download/">Download</a>
The current release of Cling is <em>2.0.1 (2014-11-06)</em>: <a href="/projects/download/">Download</a>
</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion website/src/site/xhtml/roadmap.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<hr/>

<h2>
Cling 2.0.1
Cling 2.0.x
</h2>

<ul>
Expand Down
Loading

0 comments on commit 0f285df

Please sign in to comment.