Skip to content

Commit

Permalink
Merge pull request #37 from jahirfiquitiva/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
javiersantos committed Jan 13, 2018
2 parents 6024768 + 47a79eb commit 6989611
Show file tree
Hide file tree
Showing 29 changed files with 519 additions and 295 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ jdk: oraclejdk8

android:
components:
- build-tools-25.0.3
- android-25
- build-tools-27.0.3
- android-27
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
Expand All @@ -16,8 +16,8 @@ before_install:

before_script:
- echo yes | android update sdk --no-ui --all --filter platform-tools,tools
- echo yes | android update sdk --no-ui --all --filter build-tools-25.0.3
- echo yes | android update sdk --no-ui --all --filter android-25
- echo yes | android update sdk --no-ui --all --filter build-tools-27.0.3
- echo yes | android update sdk --no-ui --all --filter android-27

script:
- ./gradlew clean test
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h4 align="center">Android Library</h4>

<p align="center">
<a target="_blank" href="https://android-arsenal.com/api?level=9"><img src="https://img.shields.io/badge/API-9%2B-orange.svg"></a>
<a target="_blank" href="https://android-arsenal.com/api?level=14"><img src="https://img.shields.io/badge/API-14%2B-orange.svg"></a>
<a target="_blank" href="https://travis-ci.org/javiersantos/PiracyChecker"><img src="https://travis-ci.org/javiersantos/PiracyChecker.svg?branch=master"></a>
<a target="_blank" href="http://android-arsenal.com/details/1/3641"><img src="https://img.shields.io/badge/Android%20Arsenal-PiracyChecker-blue.svg"></a>
<a target="_blank" href="https://www.paypal.me/javiersantos" title="Donate using PayPal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" /></a>
Expand Down Expand Up @@ -31,7 +31,7 @@ And add the library to your module **build.gradle**:

```Gradle
dependencies {
compile 'com.github.javiersantos:PiracyChecker:1.1'
implementation 'com.github.javiersantos:PiracyChecker:1.2'
}
```

Expand Down Expand Up @@ -144,6 +144,17 @@ new PiracyChecker(this)
.start();
```

### Enable deep pirate and third-party store apps check
If you want to check if these kind of apps left some files that could make your app work as pirated still, you can enable its check as follows:
```Java
new PiracyChecker(this)
.enableFoldersCheck(true)
...
.start();
```

**BE CAREFUL!** This means, that some times, the app will be recognized as pirated even after those pirate and third-party store apps were uninstalled. Set it to false if you don't like this behaviour/approach.

### Verify if app is a debug build
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.

Expand Down Expand Up @@ -266,7 +277,7 @@ new PiracyChecker(this)
```

## License
Copyright 2017 Javier Santos
Copyright 2018 Javier Santos

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.github.javiersantos.piracychecker.demo"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand All @@ -23,8 +23,8 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile project(':library')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation project(':library')
}
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

buildscript {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -14,7 +16,9 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 12 01:52:21 CET 2017
#Mon Jan 8 01:52:21 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
19 changes: 10 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 12
versionName "1.2"
consumerProguardFiles 'proguard-rules.pro'
minSdkVersion 11
targetSdkVersion 25
versionCode 7
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
}
api fileTree(dir: 'libs', include: ['*.jar'])
api 'com.android.support:appcompat-v7:27.0.2'
}
11 changes: 10 additions & 1 deletion library/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@
# Lib
-keep class com.github.javiersantos.**
-dontwarn com.github.javiersantos.**

# LVL
-keep public class com.android.vending.licensing.ILicensingService
-keep class com.google.**
-keep class autovalue.shaded.com.google.**
-keep class com.android.vending.billing.**
-keep public class com.android.vending.licensing.ILicensingService

-dontwarn org.apache.**
-dontwarn com.google.**
-dontwarn autovalue.shaded.com.google.**
-dontwarn com.android.vending.billing.**
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public class AESObfuscator implements Obfuscator {
private Cipher mDecryptor;

/**
* @param salt an array of random bytes to use for each (un)obfuscation
* @param applicationId application identifier, e.g. the package name
* @param deviceId device identifier. Use as many sources as possible to create this unique
* identifier.
* @param salt
* an array of random bytes to use for each (un)obfuscation
* @param applicationId
* application identifier, e.g. the package name
* @param deviceId
* device identifier. Use as many sources as possible to create this unique identifier.
*/
public AESObfuscator(byte[] salt, String applicationId, String deviceId) {
try {
Expand Down Expand Up @@ -92,7 +94,7 @@ public String unobfuscate(String obfuscated, String key) throws ValidationExcept
int headerIndex = result.indexOf(header + key);
if (headerIndex != 0) {
throw new ValidationException("Header not found (invalid data or key)" + ":" +
obfuscated);
obfuscated);
}
return result.substring(header.length() + key.length(), result.length());
} catch (Base64DecoderException | IllegalBlockSizeException | BadPaddingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public class APKExpansionPolicy implements Policy {
private Vector<Long> mExpansionFileSizes = new Vector<>();

/**
* @param context The context for the current application
* @param obfuscator An obfuscator to be used with preferences.
* @param context
* The context for the current application
* @param obfuscator
* An obfuscator to be used with preferences.
*/
public APKExpansionPolicy(Context context, Obfuscator obfuscator) {
// Import old values
Expand All @@ -82,7 +84,7 @@ public APKExpansionPolicy(Context context, Obfuscator obfuscator) {
mLastResponse = Integer.parseInt(
mPreferences.getString(PREF_LAST_RESPONSE, Integer.toString(Policy.RETRY)));
mValidityTimestamp = Long.parseLong(mPreferences.getString(PREF_VALIDITY_TIMESTAMP,
DEFAULT_VALIDITY_TIMESTAMP));
DEFAULT_VALIDITY_TIMESTAMP));
mRetryUntil = Long.parseLong(mPreferences.getString(PREF_RETRY_UNTIL, DEFAULT_RETRY_UNTIL));
mMaxRetries = Long.parseLong(mPreferences.getString(PREF_MAX_RETRIES, DEFAULT_MAX_RETRIES));
mRetryCount = Long.parseLong(mPreferences.getString(PREF_RETRY_COUNT, DEFAULT_RETRY_COUNT));
Expand All @@ -108,8 +110,10 @@ public void resetPolicy() {
* client should ignore retry errors until <li>GR: the number of retry errors that the client
* should ignore </ul>
*
* @param response the result from validating the server response
* @param rawData the raw server response data
* @param response
* the result from validating the server response
* @param rawData
* the raw server response data
*/
public void processServerResponse(int response,
ResponseData rawData) {
Expand Down Expand Up @@ -160,7 +164,8 @@ public void processServerResponse(int response,
* Set the last license response received from the server and add to preferences. You must
* manually call PreferenceObfuscator.commit() to commit these changes to disk.
*
* @param l the response
* @param l
* the response
*/
private void setLastResponse(int l) {
mLastResponseTime = System.currentTimeMillis();
Expand All @@ -176,7 +181,8 @@ public long getRetryCount() {
* Set the current retry count and add to preferences. You must manually call
* PreferenceObfuscator.commit() to commit these changes to disk.
*
* @param c the new retry count
* @param c
* the new retry count
*/
private void setRetryCount(long c) {
mRetryCount = c;
Expand All @@ -191,7 +197,8 @@ public long getValidityTimestamp() {
* Set the last validity timestamp (VT) received from the server and add to preferences. You
* must manually call PreferenceObfuscator.commit() to commit these changes to disk.
*
* @param validityTimestamp the VT string received
* @param validityTimestamp
* the VT string received
*/
private void setValidityTimestamp(String validityTimestamp) {
Long lValidityTimestamp;
Expand All @@ -216,7 +223,8 @@ public long getRetryUntil() {
* Set the retry until timestamp (GT) received from the server and add to preferences. You must
* manually call PreferenceObfuscator.commit() to commit these changes to disk.
*
* @param retryUntil the GT string received
* @param retryUntil
* the GT string received
*/
private void setRetryUntil(String retryUntil) {
Long lRetryUntil;
Expand All @@ -241,7 +249,8 @@ public long getMaxRetries() {
* Set the max retries value (GR) as received from the server and add to preferences. You must
* manually call PreferenceObfuscator.commit() to commit these changes to disk.
*
* @param maxRetries the GR string received
* @param maxRetries
* the GR string received
*/
private void setMaxRetries(String maxRetries) {
Long lMaxRetries;
Expand Down Expand Up @@ -272,8 +281,9 @@ public int getExpansionURLCount() {
* Gets the expansion URL. Since these URLs are not committed to preferences, this will always
* return null if there has not been an LVL fetch in the current session.
*
* @param index the index of the URL to fetch. This value will be either MAIN_FILE_URL_INDEX or
* PATCH_FILE_URL_INDEX
* @param index
* the index of the URL to fetch. This value will be either MAIN_FILE_URL_INDEX or
* PATCH_FILE_URL_INDEX
*/
public String getExpansionURL(int index) {
if (index < mExpansionURLs.size()) {
Expand All @@ -286,9 +296,11 @@ public String getExpansionURL(int index) {
* Sets the expansion URL. Expansion URL's are not committed to preferences, but are instead
* intended to be stored when the license response is processed by the front-end.
*
* @param index the index of the expansion URL. This value will be either MAIN_FILE_URL_INDEX or
* PATCH_FILE_URL_INDEX
* @param URL the URL to set
* @param index
* the index of the expansion URL. This value will be either MAIN_FILE_URL_INDEX or
* PATCH_FILE_URL_INDEX
* @param URL
* the URL to set
*/
public void setExpansionURL(int index, String URL) {
if (index >= mExpansionURLs.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public interface DeviceLimiter {
/**
* Checks if this device is allowed to use the given user's license.
*
* @param userId the user whose license the server responded with
* @param userId
* the user whose license the server responded with
*
* @return LICENSED if the device is allowed, NOT_LICENSED if not, RETRY if an error occurs
*/
int isDeviceAllowed(String userId);
Expand Down
Loading

0 comments on commit 6989611

Please sign in to comment.