diff --git a/build.gradle b/build.gradle index a60ed7b22..f21541ea7 100755 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,12 @@ buildscript { repositories { - jcenter() + google() mavenCentral() + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:4.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -14,23 +15,22 @@ buildscript { ext{ - compileSdkVersion = 24 - buildToolsVersion = '23.0.3' + compileSdkVersion = 32 group = 'org.eclipse.paho' - sampleArchivesBaseName = 'org.eclipse.paho.android.sample' - sampleVersion = '1.1.1' + sampleArchivesBaseName = 'inder.paho.mqtt' + sampleVersion = '1.1.3' - serviceArchivesBaseName = 'org.eclipse.paho.android.service' - serviceVersion = '1.1.1' + serviceArchivesBaseName = 'inder.paho.mqtt' + serviceVersion = '1.1.4' clientVersion = '1.1.0' mavenUrl = "https://repo.eclipse.org/content/repositories/paho-releases/" - supportLibVersion = '24.2.1' + supportLibVersion = '27.0.2' } @@ -57,6 +57,8 @@ println "SDK dir: $sdkDir" allprojects { repositories { + google() + mavenCentral() jcenter() maven { url "file://$sdkDir/extras/android/m2repository/" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 978247479..4d9ca1649 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Jan 24 11:18:55 GMT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 000000000..faa03d22f --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,4 @@ +jdk: + - openjdk11 +before_install: + - ./scripts/prepareJitpackEnvironment.sh diff --git a/org.eclipse.paho.android.sample/build.gradle b/org.eclipse.paho.android.sample/build.gradle index c33f156ce..2e509d6ae 100644 --- a/org.eclipse.paho.android.sample/build.gradle +++ b/org.eclipse.paho.android.sample/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion + // buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId rootProject.ext.sampleArchivesBaseName minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 32 versionCode 1 versionName "0.1" } @@ -32,13 +32,13 @@ repositories { dependencies { - //compile fileTree(dir: '../org.eclipse.paho.android/service/libs', excludes: ["org.eclipse.paho.client.mqttv3-${rootProject.ext.clientVersion}.jar"], include: '') - compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" - compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" - compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" - compile (project(':org.eclipse.paho.android.service')){ - //exclude module: "org.eclipse.paho.client.mqttv3" - transitive=true + implementation fileTree(dir: '../org.eclipse.paho.android/service/libs', include: '') + implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" + implementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" + implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" + implementation(project(':org.eclipse.paho.android.service')){ + // exclude module: "org.eclipse.paho.client.mqttv3" + //transitive=true } } @@ -48,7 +48,7 @@ task publishAPK(type: Copy) { } -configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3' -task debug << { +//configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3' +task debug doLast { configurations.compile.each { println it} } diff --git a/org.eclipse.paho.android.sample/src/main/AndroidManifest.xml b/org.eclipse.paho.android.sample/src/main/AndroidManifest.xml index 65d3cd7d0..6374ba8dd 100644 --- a/org.eclipse.paho.android.sample/src/main/AndroidManifest.xml +++ b/org.eclipse.paho.android.sample/src/main/AndroidManifest.xml @@ -24,7 +24,8 @@ + android:label="@string/app_name" + android:exported="true"> diff --git a/org.eclipse.paho.android.service/build.gradle b/org.eclipse.paho.android.service/build.gradle index bda982503..a375b2262 100755 --- a/org.eclipse.paho.android.service/build.gradle +++ b/org.eclipse.paho.android.service/build.gradle @@ -3,11 +3,11 @@ apply plugin: 'maven-publish' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion +// buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { minSdkVersion 9 - targetSdkVersion 24 + targetSdkVersion 32 testApplicationId "org.eclipse.paho.android.service.test" } @@ -36,19 +36,21 @@ configurations { } dependencies { - compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" - compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}" - compile fileTree(include: ['*.jar'], dir: 'libs') + api "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" + api "com.android.support:support-v4:${rootProject.ext.supportLibVersion}" + api fileTree(include: ['*.jar'], dir: 'libs') } android.libraryVariants.all { variant -> task("generate${variant.name}Javadoc", type: Javadoc) { + doFirst { + ext.androidJar = + "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" + classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) + } + title = "$name $version API" description "Generates Javadoc for $variant.name." - source = variant.javaCompile.source - ext.androidJar = - "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" - classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) options.links("http://docs.oracle.com/javase/7/docs/api/"); options.links("http://d.android.com/reference/"); exclude '**/BuildConfig.java' @@ -92,41 +94,42 @@ task("generateJavaDocJar", type: Jar, dependsOn: (rootProject.ext.serviceVersion publishing { publications { paho(MavenPublication) { - groupId 'org.eclipse.paho' - artifact generateSourcesJar - artifact generateLibraryJar - artifact generateJavaDocJar + groupId 'inderrapido' artifact "$buildDir/outputs/aar/" + rootProject.ext.serviceArchivesBaseName + "-" + rootProject.ext.serviceVersion + ".aar" } } - repositories { - if (project.hasProperty('eclipseRepoUsername')) { - maven { - name 'eclipse' - url 'https://repo.eclipse.org/content/repositories/paho-' + (rootProject.ext.serviceVersion.endsWith('-SNAPSHOT') ? 'snapshots/' : 'releases/') - credentials { - username eclipseRepoUsername - password eclipseRepoPassword - } - } - } else { - maven { - url "$buildDir/repo" - } - } - } +// repositories { +// if (project.hasProperty('eclipseRepoUsername')) { +// maven { +// name 'eclipse' +// url 'https://repo.eclipse.org/content/repositories/paho-' + (rootProject.ext.serviceVersion.endsWith('-SNAPSHOT') ? 'snapshots/' : 'releases/') +// credentials { +// username eclipseRepoUsername +// password eclipseRepoPassword +// } +// } +// } else { +// maven { +// url "$buildDir/repo" +// } +// } +// } } -task debug << { +task debug doLast { configurations.compile.each { println it} } // Required to bundle Java library Jar in AAR -clean.doLast{ - copyLibs.execute() +clean.dependsOn("copyLibs").doLast{ + //copyLibs.execute() +// println "Copying MQTT Jar into libs directory" +// from configurations.compile +// into 'libs' +// include 'org.eclipse.paho*' } -assemble.doLast { - renameReleaseAAR.execute() +assemble.dependsOn("renameReleaseAAR").doLast { + // renameReleaseAAR.execute() } clean.doFirst { diff --git a/org.eclipse.paho.android.service/src/main/AndroidManifest.xml b/org.eclipse.paho.android.service/src/main/AndroidManifest.xml index b1c079cb8..ba0b4ae08 100755 --- a/org.eclipse.paho.android.service/src/main/AndroidManifest.xml +++ b/org.eclipse.paho.android.service/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ - + + diff --git a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java index 8ad9569f9..12d71b127 100755 --- a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java +++ b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/AlarmPingSender.java @@ -3,20 +3,15 @@ * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. + * and Eclipse Distribution License v1.0 which accompany this distribution. * - * The Eclipse Public License is available at + * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at + * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. */ package org.eclipse.paho.android.service; -import org.eclipse.paho.client.mqttv3.IMqttActionListener; -import org.eclipse.paho.client.mqttv3.IMqttToken; -import org.eclipse.paho.client.mqttv3.MqttPingSender; -import org.eclipse.paho.client.mqttv3.internal.ClientComms; - import android.annotation.SuppressLint; import android.app.AlarmManager; import android.app.PendingIntent; @@ -30,6 +25,11 @@ import android.os.PowerManager.WakeLock; import android.util.Log; +import org.eclipse.paho.client.mqttv3.IMqttActionListener; +import org.eclipse.paho.client.mqttv3.IMqttToken; +import org.eclipse.paho.client.mqttv3.MqttPingSender; +import org.eclipse.paho.client.mqttv3.internal.ClientComms; + /** * Default ping sender implementation on Android. It is based on AlarmManager. * @@ -60,6 +60,16 @@ public AlarmPingSender(MqttService service) { that = this; } + + private int pendingIntentFlags() { + if (Build.VERSION.SDK_INT >= 23) { + return PendingIntent.FLAG_IMMUTABLE; + } else { + return PendingIntent.FLAG_UPDATE_CURRENT; + } + } + + @Override public void init(ClientComms comms) { this.comms = comms; @@ -74,7 +84,7 @@ public void start() { service.registerReceiver(alarmReceiver, new IntentFilter(action)); pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent( - action), PendingIntent.FLAG_UPDATE_CURRENT); + action), pendingIntentFlags()); schedule(comms.getKeepAlive()); hasStarted = true; @@ -95,7 +105,7 @@ public void stop() { try{ service.unregisterReceiver(alarmReceiver); }catch(IllegalArgumentException e){ - //Ignore unregister errors. + //Ignore unregister errors. } } } diff --git a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java index 06e5b7e98..7a94eb321 100755 --- a/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java +++ b/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java @@ -3,16 +3,16 @@ * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v1.0 which accompany this distribution. + * and Eclipse Distribution License v1.0 which accompany this distribution. * - * The Eclipse Public License is available at + * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at + * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. - * + * * Ian Craggs - Per subscription message handlers bug 466579 * Ian Craggs - ack control (bug 472172) - * + * */ package org.eclipse.paho.android.service; @@ -77,7 +77,7 @@ public class MqttAndroidClient extends BroadcastReceiver implements IMqttAsyncClient { /** - * + * * The Acknowledgment mode for messages received from {@link MqttCallback#messageArrived(String, MqttMessage)} * */ @@ -152,15 +152,15 @@ public void onServiceDisconnected(ComponentName name) { //The acknowledgment that a message has been processed by the application private final Ack messageAck; private boolean traceEnabled = false; - + private volatile boolean receiverRegistered = false; private volatile boolean bindedService = false; /** * Constructor - create an MqttAndroidClient that can be used to communicate with an MQTT server on android - * - * @param context - * object used to pass context to the callback. + * + * @param context + * object used to pass context to the callback. * @param serverURI * specifies the protocol, host name and port to be used to * connect to an MQTT server @@ -176,7 +176,7 @@ public MqttAndroidClient(Context context, String serverURI, /** * Constructor - create an MqttAndroidClient that can be used to communicate * with an MQTT server on android - * + * * @param ctx * Application's context * @param serverURI @@ -196,7 +196,7 @@ public MqttAndroidClient(Context ctx, String serverURI, String clientId, Ack ack /** * Constructor - create an MqttAndroidClient that can be used to communicate * with an MQTT server on android - * + * * @param ctx * Application's context * @param serverURI @@ -215,7 +215,7 @@ public MqttAndroidClient(Context ctx, String serverURI, String clientId, MqttCli /** * Constructor- create an MqttAndroidClient that can be used to communicate * with an MQTT server on android - * + * * @param context * used to pass context to the callback. * @param serverURI @@ -257,7 +257,7 @@ public boolean isConnected() { * All clients connected to the same server or server farm must have a * unique ID. *

- * + * * @return the client ID used by this client. */ @Override @@ -271,7 +271,7 @@ public String getClientId() { * The format of the returned String is the same as that used on the * constructor. *

- * + * * @return the server's address, as a URI String. */ @Override @@ -294,13 +294,13 @@ public void close() { mqttService.close(clientHandle); } } - + /** * Connects to an MQTT server using the default options. *

* The default options are specified in {@link MqttConnectOptions} class. *

- * + * * @throws MqttException * for any connected problems * @return token used to track and wait for the connect to complete. The @@ -313,14 +313,14 @@ public IMqttToken connect() throws MqttException { return connect(null, null); } - + /** * Connects to an MQTT server using the provided connect options. *

* The connection will be established using the options specified in the * {@link MqttConnectOptions} parameter. *

- * + * * @param options * a set of connection parameters that override the defaults. * @throws MqttException @@ -339,7 +339,7 @@ public IMqttToken connect(MqttConnectOptions options) throws MqttException { *

* The default options are specified in {@link MqttConnectOptions} class. *

- * + * * @param userContext * optional object used to pass context to the callback. Use null * if not required. @@ -377,7 +377,7 @@ public IMqttToken connect(Object userContext, IMqttActionListener callback) *
  • Passing in a callback {@link IMqttActionListener}
  • * * - * + * * @param options * a set of connection parameters that override the defaults. * @param userContext @@ -433,7 +433,7 @@ public IMqttToken connect(MqttConnectOptions options, Object userContext, @Override public void run() { doConnect(); - + //Register receiver to show shoulder tap. if (!receiverRegistered) registerReceiver(MqttAndroidClient.this); } @@ -461,13 +461,13 @@ private void doConnect() { } mqttService.setTraceEnabled(traceEnabled); mqttService.setTraceCallbackId(clientHandle); - + String activityToken = storeToken(connectToken); try { mqttService.connect(clientHandle, connectOptions, null, activityToken); } - catch (MqttException e) { + catch (MqttException | IllegalStateException | IllegalArgumentException e) { IMqttActionListener listener = connectToken.getActionCallback(); if (listener != null) { listener.onFailure(connectToken, e); @@ -483,7 +483,7 @@ private void doConnect() { * for work to quiesce before disconnecting. This method must not be called * from inside {@link MqttCallback} methods. *

    - * + * * @return token used to track and wait for disconnect to complete. The * token will be passed to any callback that has been set. * @throws MqttException @@ -507,7 +507,7 @@ public IMqttToken disconnect() throws MqttException { * specified quiesce time for work to complete before disconnecting. This * method must not be called from inside {@link MqttCallback} methods. *

    - * + * * @param quiesceTimeout * the amount of time in milliseconds to allow for existing work * to finish before disconnecting. A value of zero or less means @@ -537,7 +537,7 @@ public IMqttToken disconnect(long quiesceTimeout) throws MqttException { * for work to quiesce before disconnecting. This method must not be called * from inside {@link MqttCallback} methods. *

    - * + * * @param userContext * optional object used to pass context to the callback. Use null * if not required. @@ -587,7 +587,7 @@ public IMqttToken disconnect(Object userContext, * or *
  • Passing in a callback {@link IMqttActionListener}
  • * - * + * * @param quiesceTimeout * the amount of time in milliseconds to allow for existing work * to finish before disconnecting. A value of zero or less means @@ -620,7 +620,7 @@ public IMqttToken disconnect(long quiesceTimeout, Object userContext, * A convenience method, which will create a new {@link MqttMessage} object * with a byte array payload and the specified QoS, and then publish it. *

    - * + * * @param topic * to deliver the message to, for example "finance/stock/ibm". * @param payload @@ -651,7 +651,7 @@ public IMqttDeliveryToken publish(String topic, byte[] payload, int qos, * Publishes a message to a topic on the server. Takes an * {@link MqttMessage} message and delivers it to the server at the * requested quality of service. - * + * * @param topic * to deliver the message to, for example "finance/stock/ibm". * @param message @@ -679,7 +679,7 @@ public IMqttDeliveryToken publish(String topic, MqttMessage message) * A convenience method, which will create a new {@link MqttMessage} object * with a byte array payload, the specified QoS and retained, then publish it. *

    - * + * * @param topic * to deliver the message to, for example "finance/stock/ibm". * @param payload @@ -741,12 +741,12 @@ public IMqttDeliveryToken publish(String topic, byte[] payload, int qos, *
  • Depending when the failure occurs QoS 0 messages may not be * delivered. * - * + * *

    * When building an application, the design of the topic tree should take * into account the following principles of topic name syntax and semantics: *

    - * + * *
      *
    • A topic must be at least one character long.
    • *
    • Topic names are case sensitive. For example, ACCOUNTS and @@ -759,12 +759,12 @@ public IMqttDeliveryToken publish(String topic, byte[] payload, int qos, * matches "+/+" and "/+", but not "+".
    • *
    • Do not include the null character (Unicode \x0000) in any topic.
    • *
    - * + * *

    * The following principles apply to the construction and content of a topic * tree: *

    - * + * *
      *
    • The length is limited to 64k but within that there are no limits to * the number of levels in a topic tree.
    • @@ -783,7 +783,7 @@ public IMqttDeliveryToken publish(String topic, byte[] payload, int qos, * or *
    • Passing in a callback {@link IMqttActionListener} to this method
    • *
    - * + * * @param topic * to deliver the message to, for example "finance/stock/ibm". * @param message @@ -820,7 +820,7 @@ public IMqttDeliveryToken publish(String topic, MqttMessage message, /** * Subscribe to a topic, which may include wildcards. - * + * * @param topic * the topic to subscribe to, which can include wildcards. * @param qos @@ -835,7 +835,7 @@ public IMqttDeliveryToken publish(String topic, MqttMessage message, * for security related problems * @throws MqttException * for non security related problems - * + * * @see #subscribe(String[], int[], Object, IMqttActionListener) */ @Override @@ -846,12 +846,12 @@ public IMqttToken subscribe(String topic, int qos) throws MqttException, /** * Subscribe to multiple topics, each topic may include wildcards. - * + * *

    * Provides an optimized way to subscribe to multiple topics compared to * subscribing to each one individually. *

    - * + * * @param topic * one or more topics to subscribe to, which can include * wildcards @@ -867,7 +867,7 @@ public IMqttToken subscribe(String topic, int qos) throws MqttException, * for security related problems * @throws MqttException * for non security related problems - * + * * @see #subscribe(String[], int[], Object, IMqttActionListener) */ @Override @@ -878,7 +878,7 @@ public IMqttToken subscribe(String[] topic, int[] qos) /** * Subscribe to a topic, which may include wildcards. - * + * * @param topic * the topic to subscribe to, which can include wildcards. * @param qos @@ -897,7 +897,7 @@ public IMqttToken subscribe(String[] topic, int[] qos) * token will be passed to callback methods if set. * @throws MqttException * if there was an error when registering the subscription. - * + * * @see #subscribe(String[], int[], Object, IMqttActionListener) */ @Override @@ -943,7 +943,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * the client connects with the same client ID the server will * deliver the stored messages to the client. *

    - * + * *

    * The "topic filter" string is used when subscription may contain special * characters, which allows you to subscribe to multiple topics at once. @@ -953,7 +953,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * tree and provide a hierarchical structure to the topic space. The use of * the topic level separator is significant when the two wildcard characters * are encountered in topics specified by subscribers. - * + * *

    Multi-level wildcard
    *
    *

    @@ -974,7 +974,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * # represents zero levels. The topic level separator is * meaningless in this context, because there are no levels to separate. *

    - * + * *

    * The multi-level wildcard can be specified only on its own or * next to the topic level separator character. Therefore, # and @@ -984,7 +984,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * finance/#/closingprice is not valid. *

    *
    - * + * *
    Single-level wildcard
    *
    *

    @@ -995,7 +995,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * wildcard matches only a single level, finance/+ does not match * finance. *

    - * + * *

    * Use the single-level wildcard at any level in the topic tree, and in * conjunction with the multilevel wildcard. Specify the single-level @@ -1017,7 +1017,7 @@ public IMqttToken subscribe(String topic, int qos, Object userContext, * or

  • *
  • Passing in a callback {@link IMqttActionListener} to this method
  • * - * + * * @param topic * one or more topics to subscribe to, which can include * wildcards @@ -1049,7 +1049,7 @@ public IMqttToken subscribe(String[] topic, int[] qos, Object userContext, mqttService.subscribe(clientHandle, topic, qos, null, activityToken); return token; } - + /** * Subscribe to a topic, which may include wildcards. * @@ -1090,11 +1090,11 @@ public IMqttToken subscribe(String topicFilter, int qos, Object userContext, IMq * @throws MqttException if there was an error registering the subscription. */ public IMqttToken subscribe(String topicFilter, int qos, IMqttMessageListener messageListener) throws MqttException { - + return subscribe(topicFilter, qos, null, null, messageListener); } - + /** * Subscribe to multiple topics, each of which may include wildcards. * @@ -1114,7 +1114,7 @@ public IMqttToken subscribe(String topicFilter, int qos, IMqttMessageListener me * @throws MqttException if there was an error registering the subscription. */ public IMqttToken subscribe(String[] topicFilters, int[] qos, IMqttMessageListener[] messageListeners) throws MqttException { - + return subscribe(topicFilters, qos, null, null, messageListeners); } @@ -1152,7 +1152,7 @@ public IMqttToken subscribe(String[] topicFilters, int[] qos, Object userContext /** * Requests the server unsubscribe the client from a topic. - * + * * @param topic * the topic to unsubscribe from. It must match a topic specified * on an earlier subscribe. @@ -1160,7 +1160,7 @@ public IMqttToken subscribe(String[] topicFilters, int[] qos, Object userContext * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. - * + * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override @@ -1170,7 +1170,7 @@ public IMqttToken unsubscribe(String topic) throws MqttException { /** * Requests the server to unsubscribe the client from one or more topics. - * + * * @param topic * one or more topics to unsubscribe from. Each topic must match * one specified on an earlier subscription. @@ -1178,7 +1178,7 @@ public IMqttToken unsubscribe(String topic) throws MqttException { * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. - * + * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override @@ -1188,7 +1188,7 @@ public IMqttToken unsubscribe(String[] topic) throws MqttException { /** * Requests the server to unsubscribe the client from a topics. - * + * * @param topic * the topic to unsubscribe from. It must match a topic specified * on an earlier subscribe. @@ -1202,7 +1202,7 @@ public IMqttToken unsubscribe(String[] topic) throws MqttException { * token will be passed to callback methods if set. * @throws MqttException * if there was an error unregistering the subscription. - * + * * @see #unsubscribe(String[], Object, IMqttActionListener) */ @Override @@ -1237,7 +1237,7 @@ public IMqttToken unsubscribe(String topic, Object userContext, * or *
  • Passing in a callback {@link IMqttActionListener} to this method
  • * - * + * * @param topic * one or more topics to unsubscribe from. Each topic must match * one specified on an earlier subscription. @@ -1277,7 +1277,7 @@ public IMqttToken unsubscribe(String[] topic, Object userContext, * state to be remembered the client must connect with cleanSession set to * false *

    - * + * * @return zero or more delivery tokens */ @Override @@ -1302,10 +1302,10 @@ public IMqttDeliveryToken[] getPendingDeliveryTokens() { * from each non-blocking method or using setting a * {@link IMqttActionListener} on the non-blocking method. *

    - * + * * @param callback * which will be invoked for certain asynchronous events - * + * * @see MqttCallback */ @Override @@ -1313,11 +1313,11 @@ public void setCallback(MqttCallback callback) { this.callback = callback; } - + /** * identify the callback to be invoked when making tracing calls back into * the Activity - * + * * @param traceCallback handler */ public void setTraceCallback(MqttTraceHandler traceCallback) { @@ -1327,18 +1327,18 @@ public void setTraceCallback(MqttTraceHandler traceCallback) { /** * turn tracing on and off - * + * * @param traceEnabled * set true to enable trace, otherwise, set * false to disable trace - * + * */ public void setTraceEnabled(boolean traceEnabled) { this.traceEnabled = traceEnabled; if (mqttService !=null) mqttService.setTraceEnabled(traceEnabled); } - + /** *

    * Process incoming Intent objects representing the results of operations @@ -1395,7 +1395,7 @@ else if (MqttServiceConstants.DISCONNECT_ACTION.equals(action)) { else if (MqttServiceConstants.TRACE_ACTION.equals(action)) { traceAction(data); }else{ - mqttService.traceError(MqttService.TAG, "Callback action doesn't exist."); + mqttService.traceError(MqttService.TAG, "Callback action doesn't exist."); } } @@ -1403,7 +1403,7 @@ else if (MqttServiceConstants.TRACE_ACTION.equals(action)) { /** * Acknowledges a message received on the * {@link MqttCallback#messageArrived(String, MqttMessage)} - * + * * @param messageId * the messageId received from the MqttMessage (To access this * field you need to cast {@link MqttMessage} to @@ -1418,24 +1418,24 @@ public boolean acknowledgeMessage(String messageId) { return false; } - + public void messageArrivedComplete(int messageId, int qos) throws MqttException { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } - + public void setManualAcks(boolean manualAcks) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } /** * Process the results of a connection - * + * * @param data */ private void connectAction(Bundle data) { IMqttToken token = connectToken; removeMqttToken(data); - + simpleAction(token, data); } @@ -1443,7 +1443,7 @@ private void connectAction(Bundle data) { /** * Process a notification that we have disconnected - * + * * @param data */ private void disconnected(Bundle data) { @@ -1459,7 +1459,7 @@ private void disconnected(Bundle data) { /** * Process a Connection Lost notification - * + * * @param data */ private void connectionLostAction(Bundle data) { @@ -1483,7 +1483,7 @@ private void connectExtendedAction(Bundle data){ /** * Common processing for many notifications - * + * * @param token * the token associated with the action being undertake * @param data @@ -1501,13 +1501,13 @@ private void simpleAction(IMqttToken token, Bundle data) { ((MqttTokenAndroid) token).notifyFailure(exceptionThrown); } } else { - mqttService.traceError(MqttService.TAG, "simpleAction : token is null"); + mqttService.traceError(MqttService.TAG, "simpleAction : token is null"); } } /** * Process notification of a publish(send) operation - * + * * @param data */ private void sendAction(Bundle data) { @@ -1518,7 +1518,7 @@ private void sendAction(Bundle data) { /** * Process notification of a subscribe operation - * + * * @param data */ private void subscribeAction(Bundle data) { @@ -1528,7 +1528,7 @@ private void subscribeAction(Bundle data) { /** * Process notification of an unsubscribe operation - * + * * @param data */ private void unSubscribeAction(Bundle data) { @@ -1538,7 +1538,7 @@ private void unSubscribeAction(Bundle data) { /** * Process notification of a published message having been delivered - * + * * @param data */ private void messageDeliveredAction(Bundle data) { @@ -1556,7 +1556,7 @@ private void messageDeliveredAction(Bundle data) { /** * Process notification of a message's arrival - * + * * @param data */ private void messageArrivedAction(Bundle data) { @@ -1585,10 +1585,10 @@ private void messageArrivedAction(Bundle data) { } } } - + /** * Process trace action - pass trace data back to the callback - * + * * @param data */ private void traceAction(Bundle data) { @@ -1597,9 +1597,9 @@ private void traceAction(Bundle data) { String severity = data.getString(MqttServiceConstants.CALLBACK_TRACE_SEVERITY); String message = data.getString(MqttServiceConstants.CALLBACK_ERROR_MESSAGE); String tag = data.getString(MqttServiceConstants.CALLBACK_TRACE_TAG); - if (MqttServiceConstants.TRACE_DEBUG.equals(severity)) + if (MqttServiceConstants.TRACE_DEBUG.equals(severity)) traceCallback.traceDebug(tag, message); - else if (MqttServiceConstants.TRACE_ERROR.equals(severity)) + else if (MqttServiceConstants.TRACE_ERROR.equals(severity)) traceCallback.traceError(tag, message); else { @@ -1608,7 +1608,7 @@ else if (MqttServiceConstants.TRACE_ERROR.equals(severity)) } } } - + /** * @param token * identifying an operation @@ -1622,12 +1622,12 @@ private synchronized String storeToken(IMqttToken token) { /** * Get a token identified by a string, and remove it from our map - * + * * @param data * @return the token */ private synchronized IMqttToken removeMqttToken(Bundle data) { - + String activityToken = data.getString(MqttServiceConstants.CALLBACK_ACTIVITY_TOKEN); if (activityToken!=null){ int tokenNumber = Integer.parseInt(activityToken); @@ -1640,7 +1640,7 @@ private synchronized IMqttToken removeMqttToken(Bundle data) { /** * Get a token identified by a string, and remove it from our map - * + * * @param data * @return the token */ @@ -1669,14 +1669,14 @@ public MqttMessage getBufferedMessage(int bufferIndex){ public void deleteBufferedMessage(int bufferIndex){ mqttService.deleteBufferedMessage(clientHandle, bufferIndex); } - + /** * Get the SSLSocketFactory using SSL key store and password *

    * A convenience method, which will help user to create a SSLSocketFactory * object *

    - * + * * @param keyStore * the SSL key store which is generated by some SSL key tool, * such as keytool in Java JDK @@ -1693,17 +1693,17 @@ public SSLSocketFactory getSSLSocketFactory (InputStream keyStore, String passwo SSLContext ctx = null; SSLSocketFactory sslSockFactory=null; KeyStore ts; - ts = KeyStore.getInstance("BKS"); + ts = KeyStore.getInstance("BKS"); ts.load(keyStore, password.toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); tmf.init(ts); TrustManager[] tm = tmf.getTrustManagers(); ctx = SSLContext.getInstance("TLSv1"); ctx.init(null, tm, null); - + sslSockFactory=ctx.getSocketFactory(); return sslSockFactory; - + } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException | KeyManagementException e) { throw new MqttSecurityException(e); } @@ -1713,18 +1713,18 @@ public SSLSocketFactory getSSLSocketFactory (InputStream keyStore, String passwo public void disconnectForcibly() throws MqttException { throw new UnsupportedOperationException(); } - + @Override public void disconnectForcibly(long disconnectTimeout) throws MqttException { throw new UnsupportedOperationException(); } - + @Override public void disconnectForcibly(long quiesceTimeout, long disconnectTimeout) throws MqttException { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } - + /** * Unregister receiver which receives intent from MqttService avoids * IntentReceiver leaks. @@ -1745,11 +1745,11 @@ public void unregisterResources(){ } } } - + /** * Register receiver to receiver intent from MqttService. Call this method * when activity is hidden and become to show again. - * + * * @param context * - Current activity context. */ diff --git a/paho.mqtt.android.example/build.gradle b/paho.mqtt.android.example/build.gradle index 98424690c..0387cbb33 100644 --- a/paho.mqtt.android.example/build.gradle +++ b/paho.mqtt.android.example/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion +// buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "paho.mqtt.java.example" minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 32 versionCode 1 versionName "1.0" } @@ -31,19 +31,19 @@ repositories { dependencies { - compile fileTree(dir: 'libs', excludes: ["org.eclipse.paho.client.mqttv3-${rootProject.ext.clientVersion}.jar"], include: '*.jar') - testCompile 'junit:junit:4.12' - compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" - compile "com.android.support:design:${rootProject.ext.supportLibVersion}" - compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" - compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" - compile (project(':org.eclipse.paho.android.service')){ + implementation fileTree(dir: 'libs', include: '*.jar') + testImplementation 'junit:junit:4.12' + implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" + implementation "com.android.support:design:${rootProject.ext.supportLibVersion}" + implementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}" + implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}" + implementation(project(':org.eclipse.paho.android.service')){ //exclude module: "org.eclipse.paho.client.mqttv3" transitive=true } } -configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3' -task debug << { +//configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3' +task debug doLast { configurations.compile.each { println it} } diff --git a/paho.mqtt.android.example/src/main/AndroidManifest.xml b/paho.mqtt.android.example/src/main/AndroidManifest.xml index 7c8e3c598..f9afb8f1d 100644 --- a/paho.mqtt.android.example/src/main/AndroidManifest.xml +++ b/paho.mqtt.android.example/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ + + android:theme="@style/AppTheme.NoActionBar" + android:exported="true">