From 8d6b9ae43ec608c88d95c9d7a27960d7771ec0dd Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 20 Oct 2014 18:25:18 -0700 Subject: [PATCH] Incorporate PR feedback. Add license and eliminate duplicate code. // FREEBIE --- build.gradle | 6 ++--- .../jobqueue/EncryptionKeys.java | 16 ++++++++++++ .../java/org/whispersystems/jobqueue/Job.java | 16 ++++++++++++ .../whispersystems/jobqueue/JobConsumer.java | 16 ++++++++++++ .../whispersystems/jobqueue/JobManager.java | 16 ++++++++++++ .../jobqueue/JobParameters.java | 16 ++++++++++++ .../org/whispersystems/jobqueue/JobQueue.java | 16 ++++++++++++ .../dependencies/ContextDependent.java | 16 ++++++++++++ .../persistence/JavaJobSerializer.java | 16 ++++++++++++ .../jobqueue/persistence/JobSerializer.java | 16 ++++++++++++ .../persistence/PersistentStorage.java | 16 ++++++++++++ .../requirements/NetworkRequirement.java | 16 ++++++++++++ .../NetworkRequirementProvider.java | 26 +++++++++++++++---- .../jobqueue/requirements/Requirement.java | 16 ++++++++++++ .../requirements/RequirementListener.java | 16 ++++++++++++ .../requirements/RequirementProvider.java | 16 ++++++++++++ 16 files changed, 247 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index a36eb6f371..0be9e214a2 100644 --- a/build.gradle +++ b/build.gradle @@ -30,9 +30,9 @@ repositories { dependencies { compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' - compile 'com.android.support:support-v4:20.0.0' + compile 'com.android.support:support-v4:21.0.0' compile 'se.emilsjolander:stickylistheaders:2.2.0' - compile 'com.google.android.gms:play-services:5.0.89' + compile 'com.google.android.gms:play-services:6.1.11' compile 'com.astuetz:pagerslidingtabstrip:1.0.1' compile 'org.w3c:smil:1.0.0' compile 'org.apache.httpcomponents:httpclient-android:4.3.5' @@ -48,9 +48,7 @@ dependencies { dependencyVerification { verify = [ 'com.actionbarsherlock:actionbarsherlock:5ab04d74101f70024b222e3ff9c87bee151ec43331b4a2134b6cc08cf8565819', - 'com.android.support:support-v4:81f2b1c2c94efd5a4ec7fcd97b6cdcd00e87a933905c5c86103c7319eb024572', 'se.emilsjolander:stickylistheaders:89146b46c96fea0e40200474a2625cda10fe94891e4128f53cdb42375091b9b6', - 'com.google.android.gms:play-services:38f326e525830f1d70f60f594ceafcbdf5b312287ddbecd338fd1ed7958a4b1e', 'com.astuetz:pagerslidingtabstrip:f1641396732c7132a7abb837e482e5ee2b0ebb8d10813fc52bbaec2c15c184c2', 'org.w3c:smil:085dc40f2bb249651578bfa07499fd08b16ad0886dbe2c4078586a408da62f9b', 'org.apache.httpcomponents:httpclient-android:6f56466a9bd0d42934b90bfbfe9977a8b654c058bf44a12bdc2877c4e1f033f1', diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/EncryptionKeys.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/EncryptionKeys.java index bdfe608729..a673567994 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/EncryptionKeys.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/EncryptionKeys.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; public class EncryptionKeys { diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/Job.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/Job.java index 508da4f7a9..3a38759225 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/Job.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/Job.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; import org.whispersystems.jobqueue.requirements.Requirement; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobConsumer.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobConsumer.java index 9dd391857b..773a7a874e 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobConsumer.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobConsumer.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; import org.whispersystems.jobqueue.persistence.PersistentStorage; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobManager.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobManager.java index 0f4aeb0965..5c4b1e2e21 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobManager.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobManager.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; import android.content.Context; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobParameters.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobParameters.java index 589340a8cd..e42672371a 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobParameters.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobParameters.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; import org.whispersystems.jobqueue.requirements.Requirement; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobQueue.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobQueue.java index 91e3a90213..6218a31405 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/JobQueue.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/JobQueue.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue; import java.util.HashMap; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/dependencies/ContextDependent.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/dependencies/ContextDependent.java index 0cdc91abe3..582caf7ef3 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/dependencies/ContextDependent.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/dependencies/ContextDependent.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.dependencies; import android.content.Context; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JavaJobSerializer.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JavaJobSerializer.java index 761ef6117d..719f51fd07 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JavaJobSerializer.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JavaJobSerializer.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.persistence; import android.content.Context; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JobSerializer.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JobSerializer.java index dea6cacf3d..226c9b6494 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JobSerializer.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/JobSerializer.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.persistence; import org.whispersystems.jobqueue.EncryptionKeys; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/PersistentStorage.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/PersistentStorage.java index 9e99882b5e..30ed1cb845 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/PersistentStorage.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/persistence/PersistentStorage.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.persistence; import android.content.ContentValues; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirement.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirement.java index 1f1f7c3be8..924e9cca6e 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirement.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirement.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.requirements; import android.content.Context; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirementProvider.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirementProvider.java index c16863568d..60d375c271 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirementProvider.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/NetworkRequirementProvider.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.requirements; import android.content.BroadcastReceiver; @@ -11,7 +27,11 @@ public class NetworkRequirementProvider implements RequirementProvider { private RequirementListener listener; + private final NetworkRequirement requirement; + public NetworkRequirementProvider(Context context) { + this.requirement = new NetworkRequirement(context); + context.getApplicationContext().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -19,11 +39,7 @@ public class NetworkRequirementProvider implements RequirementProvider { return; } - ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo netInfo = cm.getActiveNetworkInfo(); - boolean connected = netInfo != null && netInfo.isConnectedOrConnecting(); - - if (connected) { + if (requirement.isPresent()) { listener.onRequirementStatusChanged(); } } diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/Requirement.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/Requirement.java index 22e7a40bc0..058497e495 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/Requirement.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/Requirement.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.requirements; import java.io.Serializable; diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementListener.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementListener.java index 34460d6f85..2b2cb1b649 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementListener.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementListener.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.requirements; public interface RequirementListener { diff --git a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementProvider.java b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementProvider.java index caaddd1972..8389092374 100644 --- a/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementProvider.java +++ b/jobqueue/src/main/java/org/whispersystems/jobqueue/requirements/RequirementProvider.java @@ -1,3 +1,19 @@ +/** + * Copyright (C) 2014 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.whispersystems.jobqueue.requirements; public interface RequirementProvider {