diff --git a/.travis.yml b/.travis.yml index 33ddb13..55056bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ env: global: - ANDROID_API=28 - ANDROID_BUILD_TOOLS=28.0.3 - - EMULATOR_API=24 + - EMULATOR_API=21 android: components: diff --git a/README.md b/README.md index 017968b..ece266b 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,23 @@ repositories { And add the library to your module **build.gradle**: +**AndroidX** + +```gradle +dependencies { + implementation 'com.github.javiersantos:PiracyChecker:1.2.5' +} +``` + +**Pre AndroidX (no longer supported)** + ```gradle dependencies { implementation 'com.github.javiersantos:PiracyChecker:1.2.4' } ``` + ## Recommendations * Always enable ProGuard in your production release. Always, without exceptions. * PiracyChecker should be included in your `onCreate` method in order to check for a valid license as soon as possible. @@ -159,7 +170,7 @@ It will check for: Lucky Patcher, Uret Patcher, Freedom, CreeHack and HappyMod. ```kotlin piracyChecker { - enableUnauthorizedAppsCheck(true) + enableUnauthorizedAppsCheck() ... }.start() ``` @@ -168,7 +179,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() ... .start(); ``` @@ -220,7 +231,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .blockIfUnauthorizedAppUninstalled(preferences, "app_unauthorized") // Change "app_unauthorized" with your own value ... .start(); @@ -244,7 +255,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .blockIfUnauthorizedAppUninstalled("license_preferences", "app_unauthorized") // Change "license_preferences" and "app_unauthorized" with your own value ... .start(); @@ -270,7 +281,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableStoresCheck(true) + .enableStoresCheck() ... .start(); ``` @@ -293,7 +304,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableFoldersCheck(true) + .enableFoldersCheck() ... .start(); ``` @@ -315,7 +326,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableAPKCheck(true) + .enableAPKCheck() ... .start(); ``` @@ -341,7 +352,7 @@ piracyChecker { ```java new PiracyChecker(this) - .enableDebugCheck(true) + .enableDebugCheck() ... .start(); ``` @@ -353,8 +364,10 @@ new PiracyChecker(this) ### Verify if app is being run in an emulator If your app is running on an emulator outside the development process, it gives an indication that someone other than you is trying to analyze the app. +**Warning!**: Using deep check can cause crashes in some specific devices. + ```kotlin -val deepCheck = fals +val deepCheck = false piracyChecker { .enableEmulatorCheck(deepCheck) ... @@ -550,7 +563,7 @@ piracyChecker { new PiracyChecker(this) .enableGooglePlayLicensing("BASE_64_LICENSE_KEY") .enableSigningCertificate("YOUR_APK_SIGNATURE") - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .saveResultToSharedPreferences("my_app_preferences", "valid_license") ... .start(); diff --git a/app/build.gradle b/app/build.gradle index 8f488f4..7d1e5db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -36,17 +36,20 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support:cardview-v7:28.0.0' implementation project(':library') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' + // Testing-only dependencies testImplementation 'junit:junit:4.12' - androidTestImplementation('com.android.support.test:runner:1.0.1', { + androidTestImplementation 'androidx.test:rules:1.1.0' + androidTestImplementation('androidx.test:runner:1.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) } \ No newline at end of file diff --git a/app/src/androidTest/java/com/github/javiersantos/piracychecker/PiracyCheckerTest.java b/app/src/androidTest/java/com/github/javiersantos/piracychecker/PiracyCheckerTest.java index fce9782..922a0de 100644 --- a/app/src/androidTest/java/com/github/javiersantos/piracychecker/PiracyCheckerTest.java +++ b/app/src/androidTest/java/com/github/javiersantos/piracychecker/PiracyCheckerTest.java @@ -1,9 +1,5 @@ package com.github.javiersantos.piracychecker; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - import com.github.javiersantos.piracychecker.callbacks.PiracyCheckerCallback; import com.github.javiersantos.piracychecker.demo.MainActivity; import com.github.javiersantos.piracychecker.enums.InstallerID; @@ -19,6 +15,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import androidx.test.InstrumentationRegistry; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + import static org.junit.Assert.assertTrue; /** @@ -26,11 +26,11 @@ */ @RunWith(AndroidJUnit4.class) public class PiracyCheckerTest { - + @Rule public final ActivityTestRule uiThreadTestRule = new ActivityTestRule<>(MainActivity.class); - + @Test public void verifySigningCertificate_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -45,7 +45,7 @@ public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -60,10 +60,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifySigningCertificate_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -79,7 +79,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -94,10 +94,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyInstaller_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -117,7 +117,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -132,10 +132,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyUnauthorizedApps_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -143,14 +143,14 @@ public void verifyUnauthorizedApps_ALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .callback(new PiracyCheckerCallback() { @Override public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -161,10 +161,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyThirdPartyStores_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -172,14 +172,14 @@ public void verifyThirdPartyStores_ALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .callback(new PiracyCheckerCallback() { @Override public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -190,10 +190,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyDeepPirate_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -201,14 +201,14 @@ public void verifyDeepPirate_ALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableFoldersCheck(true) + .enableFoldersCheck() .callback(new PiracyCheckerCallback() { @Override public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -219,10 +219,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyDebug_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -230,7 +230,7 @@ public void verifyDebug_DONTALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableDebugCheck(true) + .enableDebugCheck() .callback(new PiracyCheckerCallback() { @Override public void allow() { @@ -238,7 +238,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -253,10 +253,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyEmulator_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -272,7 +272,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -287,10 +287,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyEmulatorDeep_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -306,7 +306,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -321,7 +321,7 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppTest.java b/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppTest.java index ce5a005..237a974 100644 --- a/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppTest.java +++ b/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppTest.java @@ -1,9 +1,5 @@ package com.github.javiersantos.piracychecker; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - import com.github.javiersantos.piracychecker.callbacks.PiracyCheckerCallback; import com.github.javiersantos.piracychecker.demo.MainActivity; import com.github.javiersantos.piracychecker.enums.PiracyCheckerError; @@ -17,6 +13,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import androidx.test.InstrumentationRegistry; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + import static org.junit.Assert.assertTrue; /** @@ -25,11 +25,11 @@ */ @RunWith(AndroidJUnit4.class) public class UnauthorizedAppTest { - + @Rule public final ActivityTestRule uiThreadTestRule = new ActivityTestRule<>(MainActivity.class); - + @Test public void verifyUnauthorizedCustomApp_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -46,7 +46,7 @@ public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -58,10 +58,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyUnauthorizedCustomApp_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -80,7 +80,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -95,10 +95,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyUnauthorizedApps_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -106,7 +106,7 @@ public void verifyUnauthorizedApps_DONTALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .blockIfUnauthorizedAppUninstalled("piracychecker_preferences", "app_unauthorized") .callback(new PiracyCheckerCallback() { @@ -117,7 +117,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -132,8 +132,8 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + } diff --git a/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppUninstalledTest.java b/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppUninstalledTest.java index 266d9c4..6b712c0 100644 --- a/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppUninstalledTest.java +++ b/app/src/androidTest/java/com/github/javiersantos/piracychecker/UnauthorizedAppUninstalledTest.java @@ -1,9 +1,5 @@ package com.github.javiersantos.piracychecker; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - import com.github.javiersantos.piracychecker.callbacks.PiracyCheckerCallback; import com.github.javiersantos.piracychecker.demo.MainActivity; import com.github.javiersantos.piracychecker.enums.PiracyCheckerError; @@ -17,6 +13,10 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import androidx.test.InstrumentationRegistry; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; + import static org.junit.Assert.assertTrue; /** @@ -25,11 +25,11 @@ */ @RunWith(AndroidJUnit4.class) public class UnauthorizedAppUninstalledTest { - + @Rule public final ActivityTestRule uiThreadTestRule = new ActivityTestRule<>(MainActivity.class); - + @Test public void verifyBlockUnauthorizedApps_DONTALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -37,7 +37,7 @@ public void verifyBlockUnauthorizedApps_DONTALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .blockIfUnauthorizedAppUninstalled("piracychecker_preferences", "app_unauthorized") .callback(new PiracyCheckerCallback() { @@ -49,7 +49,7 @@ public void allow() { false); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { @@ -64,10 +64,10 @@ public void doNotAllow(@NotNull PiracyCheckerError error, .start(); } }); - + signal.await(30, TimeUnit.SECONDS); } - + @Test public void verifyUnauthorizedApps_ALLOW() throws Throwable { final CountDownLatch signal = new CountDownLatch(1); @@ -75,14 +75,14 @@ public void verifyUnauthorizedApps_ALLOW() throws Throwable { @Override public void run() { new PiracyChecker(InstrumentationRegistry.getTargetContext()) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() .callback(new PiracyCheckerCallback() { @Override public void allow() { assertTrue("PiracyChecker OK", true); signal.countDown(); } - + @Override public void doNotAllow(@NotNull PiracyCheckerError error, @org.jetbrains.annotations.Nullable PirateApp app) { diff --git a/app/src/main/java/com/github/javiersantos/piracychecker/demo/KotlinActivity.kt b/app/src/main/java/com/github/javiersantos/piracychecker/demo/KotlinActivity.kt index 2fe5458..3e94657 100644 --- a/app/src/main/java/com/github/javiersantos/piracychecker/demo/KotlinActivity.kt +++ b/app/src/main/java/com/github/javiersantos/piracychecker/demo/KotlinActivity.kt @@ -3,9 +3,9 @@ package com.github.javiersantos.piracychecker.demo import android.content.Intent import android.net.Uri import android.os.Bundle -import android.support.v7.app.AlertDialog -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.Toolbar +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.Toolbar import android.util.Log import android.widget.RadioGroup import com.github.javiersantos.piracychecker.allow @@ -115,7 +115,7 @@ class KotlinActivity : AppCompatActivity() { fun verifyEmulator() { piracyChecker { display(piracyCheckerDisplay) - enableEmulatorCheck() + enableEmulatorCheck(false) }.start() } } \ No newline at end of file diff --git a/app/src/main/java/com/github/javiersantos/piracychecker/demo/MainActivity.java b/app/src/main/java/com/github/javiersantos/piracychecker/demo/MainActivity.java index d90b1d4..f8cdddd 100644 --- a/app/src/main/java/com/github/javiersantos/piracychecker/demo/MainActivity.java +++ b/app/src/main/java/com/github/javiersantos/piracychecker/demo/MainActivity.java @@ -3,10 +3,10 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.support.annotation.IdRes; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import androidx.annotation.IdRes; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.View; import android.widget.RadioGroup; @@ -78,7 +78,7 @@ public void verifyInstallerId(View view) { public void verifyUnauthorizedApps(View view) { new PiracyChecker(this) .display(piracyCheckerDisplay) - .enableUnauthorizedAppsCheck(true) + .enableUnauthorizedAppsCheck() //.blockIfUnauthorizedAppUninstalled("license_checker", "block") .start(); } @@ -86,21 +86,21 @@ public void verifyUnauthorizedApps(View view) { public void verifyStores(View view) { new PiracyChecker(this) .display(piracyCheckerDisplay) - .enableStoresCheck(true) + .enableStoresCheck() .start(); } public void verifyDebug(View view) { new PiracyChecker(this) .display(piracyCheckerDisplay) - .enableDebugCheck(true) + .enableDebugCheck() .start(); } public void verifyEmulator(View view) { new PiracyChecker(this) .display(piracyCheckerDisplay) - .enableEmulatorCheck(true) + .enableEmulatorCheck(false) .start(); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f0cca3c..f1a846d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - - - - - + + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index 83af7b5..edaae7b 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -1,5 +1,5 @@ - - - + - - + - - + - - + - - + - - + - - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index dbbdd40..7b61783 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -1,3 +1,4 @@ + - \ No newline at end of file