Skip to content

Added Android Threading Checker #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions ImageSteganographyLibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 26



defaultConfig {
minSdkVersion 19
targetSdkVersion 26
Expand All @@ -13,30 +11,38 @@ android {

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"



}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}
checkTypes {
javaCompileOptions.annotationProcessorOptions.
classNames.add("org.checkerframework.checker.androidthreading.AndroidThreadingChecker")
// You can pass options like so:
// javaCompileOptions.annotationProcessorOptions.arguments.put("warns", "")
}
}

configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.1.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

annotationProcessor 'com.android.support:support-annotations:28.0.0'

implementation files("E:/gsoc-2019/the-checker-framework/checker-framework/checker/dist/checker-qual.jar")
annotationProcessor files("E:/gsoc-2019/the-checker-framework/checker-framework/checker/dist/checker.jar")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ayush.imagesteganographylibrary.Text.AsyncTaskCallback;

import android.support.annotation.AnyThread;

import com.ayush.imagesteganographylibrary.Text.ImageSteganography;

/**
Expand All @@ -8,8 +10,10 @@

public interface TextDecodingCallback {

@AnyThread
void onStartTextEncoding();

@AnyThread
void onCompleteTextEncoding(ImageSteganography result);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ayush.imagesteganographylibrary.Text.AsyncTaskCallback;

import android.support.annotation.AnyThread;

import com.ayush.imagesteganographylibrary.Text.ImageSteganography;

/**
Expand All @@ -8,8 +10,10 @@

public interface TextEncodingCallback {

@AnyThread
void onStartTextEncoding();

@AnyThread
void onCompleteTextEncoding(ImageSteganography result);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.annotation.WorkerThread;
import android.util.Log;

import com.ayush.imagesteganographylibrary.Utils.Utility;
Expand Down Expand Up @@ -32,6 +33,7 @@ class EncodeDecode {
* @parameter : progressHandler {A handler interface, for the progress bar}
*/

@WorkerThread
private static byte[] encodeMessage(int[] integer_pixel_array, int image_columns, int image_rows,
MessageEncodingStatus messageEncodingStatus, ProgressHandler progressHandler) {

Expand Down Expand Up @@ -105,6 +107,7 @@ private static byte[] encodeMessage(int[] integer_pixel_array, int image_columns
* @parameter : encrypted_message {string}
* @parameter : progressHandler {Progress bar handler}
*/
@WorkerThread
public static List<Bitmap> encodeMessage(List<Bitmap> splitted_images,
String encrypted_message, ProgressHandler progressHandler) {

Expand Down Expand Up @@ -191,6 +194,7 @@ public static List<Bitmap> encodeMessage(List<Bitmap> splitted_images,
* @parameter : image_rows {Image height}
* @parameter : messageDecodingStatus {object}
*/
@WorkerThread
private static void decodeMessage(byte[] byte_pixel_array, int image_columns,
int image_rows, MessageDecodingStatus messageDecodingStatus) {

Expand Down Expand Up @@ -278,7 +282,7 @@ private static void decodeMessage(byte[] byte_pixel_array, int image_columns,
* @return : encrypted message {String}
* @parameter : encodedImages {list of encode chunk images}
*/

@WorkerThread
public static String decodeMessage(List<Bitmap> encodedImages) {

//Creating object
Expand Down Expand Up @@ -309,6 +313,7 @@ public static String decodeMessage(List<Bitmap> encodedImages) {
* @return : The number of pixel {integer}
* @parameter : message {Message to encode}
*/
@WorkerThread
public static int numberOfPixelForMessage(String message) {
int result = -1;
if (message != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ayush.imagesteganographylibrary.Text;

import android.graphics.Bitmap;
import android.support.annotation.AnyThread;
import android.support.annotation.WorkerThread;
import android.util.Log;

import com.ayush.imagesteganographylibrary.Utils.Crypto;
Expand Down Expand Up @@ -36,6 +38,7 @@ public ImageSteganography() {
this.encrypted_zip = new byte[0];
}

@WorkerThread
public ImageSteganography(String message, String secret_key, Bitmap image) {

this.message = message;
Expand All @@ -58,6 +61,7 @@ public ImageSteganography(String message, String secret_key, Bitmap image) {

}

@WorkerThread
public ImageSteganography(String secret_key, Bitmap image) {
this.secret_key = convertKeyTo128bit(secret_key);
this.image = image;
Expand All @@ -72,6 +76,7 @@ public ImageSteganography(String secret_key, Bitmap image) {
this.encrypted_zip = new byte[0];
}

@WorkerThread
private static String encryptMessage(String message, String secret_key) {
Log.d(TAG, "Message : " + message);

Expand All @@ -93,6 +98,7 @@ private static String encryptMessage(String message, String secret_key) {
return encrypted_message;
}

@WorkerThread
public static String decryptMessage(String message, String secret_key) {
String decrypted_message = "";
if (message != null) {
Expand All @@ -110,6 +116,7 @@ public static String decryptMessage(String message, String secret_key) {
return decrypted_message;
}

@WorkerThread
private static String convertKeyTo128bit(String secret_key) {

StringBuilder result = new StringBuilder(secret_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.util.Log;

import com.ayush.imagesteganographylibrary.Text.AsyncTaskCallback.TextDecodingCallback;
Expand Down Expand Up @@ -34,6 +36,7 @@ public TextDecoding(Activity activity, TextDecodingCallback textDecodingCallback
}

//setting progress dialog if wanted
@UiThread
public void setProgressDialog(ProgressDialog progressDialog) {
this.progressDialog = progressDialog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.support.annotation.UiThread;
import android.support.annotation.WorkerThread;
import android.util.Log;

import com.ayush.imagesteganographylibrary.Text.AsyncTaskCallback.TextEncodingCallback;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ayush.imagesteganographylibrary.Utils;

import android.support.annotation.WorkerThread;
import android.util.Log;

import java.util.Arrays;
Expand All @@ -14,6 +15,7 @@ public class Crypto {
@parameter : Message {String}, Secret key {String}
@return : Encrypted Message {String}
*/
@WorkerThread
public static String encryptMessage(String message, String secret_key) throws Exception {

// Creating key and cipher
Expand Down Expand Up @@ -42,6 +44,7 @@ public static String encryptMessage(String message, String secret_key) throws Ex
@parameter : Encrypted Message {String}, Secret key {String}
@return : Message {String}
*/
@WorkerThread
public static String decryptMessage(String encrypted_message, String secret_key) throws Exception {

Log.d("Decrypt", "message: + " + encrypted_message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.WorkerThread;
import android.util.Log;

import java.util.ArrayList;
Expand All @@ -23,6 +24,7 @@ public class Utility {
* @return : number of Square blocks {Integer}
* @parameter : number of pixels {Integer}
*/
@WorkerThread
public static int squareBlockNeeded(int pixels) {
int result;

Expand All @@ -41,6 +43,7 @@ public static int squareBlockNeeded(int pixels) {
* @return : List of splitted images {List}
* @parameter : Image {Bitmap}
*/
@WorkerThread
public static List<Bitmap> splitImage(Bitmap bitmap) {

//For height and width of the small image chunks
Expand Down Expand Up @@ -101,6 +104,7 @@ public static List<Bitmap> splitImage(Bitmap bitmap) {
* @return : Merged Image {Bitmap}
* @parameter : List {Bitmap}, Original Height {Integer}, Original Width {Integer}
*/
@WorkerThread
public static Bitmap mergeImage(List<Bitmap> images, int original_height, int original_width) {

//Calculating number of Rows and columns of that matrix
Expand Down Expand Up @@ -144,7 +148,7 @@ public static Bitmap mergeImage(List<Bitmap> images, int original_height, int or
* @return : Integer Array
* @parameter : b {the byte array}
*/

@WorkerThread
public static int[] byteArrayToIntArray(byte[] b) {

Log.v("Size byte array", b.length + "");
Expand Down Expand Up @@ -176,6 +180,7 @@ public static int[] byteArrayToIntArray(byte[] b) {
* @return : Integer
* @parameter : b {the byte array}
*/
@WorkerThread
public static int byteArrayToInt(byte[] b) {

return byteArrayToInt(b, 0);
Expand All @@ -188,6 +193,7 @@ public static int byteArrayToInt(byte[] b) {
* @return : Integer
* @parameter : b {the byte array}, offset {integer}
*/
@WorkerThread
private static int byteArrayToInt(byte[] b, int offset) {

int value = 0x00000000;
Expand All @@ -209,6 +215,7 @@ private static int byteArrayToInt(byte[] b, int offset) {
* @return : byte Array representing [rgb] values.
* @parameter : Integer array representing [argb] values.
*/
@WorkerThread
public static byte[] convertArray(int[] array) {

byte[] newarray = new byte[array.length * 3];
Expand All @@ -230,6 +237,7 @@ public static byte[] convertArray(int[] array) {
* @return : true or false {boolean}
* @parameter : String
*/
@WorkerThread
public static boolean isStringEmpty(String str) {
boolean result = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ayush.imagesteganographylibrary.Utils;

import android.support.annotation.WorkerThread;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -20,7 +22,7 @@ class Zipping {
@parameter : Encrypted message {String}
@return : Compressed byte array
*/

@WorkerThread
public static byte[] compress(String string) throws Exception {

ByteArrayOutputStream os = new ByteArrayOutputStream(string.length());
Expand All @@ -41,6 +43,7 @@ public static byte[] compress(String string) throws Exception {
@parameter : byte array
@return : Uncompressed encrypted_message {String}
*/
@WorkerThread
public static String decompress(byte[] compressed) throws Exception {

ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {

configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.1.1'
force 'com.android.support:support-annotations:28.0.0'
}
}

Expand Down