├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── lvl_sample ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── icon.png │ │ │ ├── layout │ │ │ │ └── main.xml │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── google │ │ │ └── play │ │ │ └── licensing │ │ │ └── MainActivity.java │ └── androidTest │ │ ├── res │ │ ├── drawable │ │ │ └── icon.png │ │ ├── values │ │ │ └── strings.xml │ │ └── layout │ │ │ └── main.xml │ │ └── java │ │ └── com │ │ └── google │ │ └── android │ │ └── vending │ │ └── licensing │ │ ├── StrictPolicyTest.java │ │ ├── ObfuscatedPreferencesTest.java │ │ ├── ServerManagedPolicyTest.java │ │ ├── AESObfuscatorTest.java │ │ └── APKExpansionPolicyTest.java └── build.gradle ├── README.txt ├── lvl_library ├── build.gradle └── src │ └── main │ ├── aidl │ └── com │ │ └── android │ │ └── vending │ │ └── licensing │ │ ├── ILicenseResultListener.aidl │ │ └── ILicensingService.aidl │ ├── AndroidManifest.xml │ └── java │ └── com │ └── google │ └── android │ └── vending │ └── licensing │ ├── util │ ├── Base64DecoderException.java │ ├── URIQueryDecoder.java │ └── Base64.java │ ├── ValidationException.java │ ├── NullDeviceLimiter.java │ ├── Obfuscator.java │ ├── DeviceLimiter.java │ ├── Policy.java │ ├── PreferenceObfuscator.java │ ├── ResponseData.java │ ├── LicenseCheckerCallback.java │ ├── StrictPolicy.java │ ├── AESObfuscator.java │ ├── LicenseValidator.java │ ├── ServerManagedPolicy.java │ ├── APKExpansionPolicy.java │ └── LicenseChecker.java ├── .gitignore ├── CONTRIBUTING.md ├── gradlew.bat ├── gradlew ├── LICENSE.txt ├── source.properties └── package.xml /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':lvl_library' 2 | include ':lvl_sample' 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/play-licensing/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lvl_sample/src/main/res/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/play-licensing/HEAD/lvl_sample/src/main/res/drawable/icon.png -------------------------------------------------------------------------------- /lvl_sample/src/androidTest/res/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/play-licensing/HEAD/lvl_sample/src/androidTest/res/drawable/icon.png -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Client library for the Google Play licensing server. 2 | 3 | See the licensing documentation at https://developer.android.com/guide/publishing/licensing.html 4 | -------------------------------------------------------------------------------- /lvl_sample/src/androidTest/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World! 4 | MarketLicensingTest 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 22 14:24:37 GMT 2024 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /lvl_sample/src/androidTest/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /lvl_library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | namespace 'com.google.android.vending.licensing' 5 | compileSdk 34 6 | defaultConfig { 7 | minSdk 4 8 | targetSdk 34 9 | } 10 | buildTypes { 11 | release { 12 | minifyEnabled false 13 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 14 | } 15 | } 16 | buildFeatures { 17 | aidl true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .DS_Store 3 | 4 | # built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # files for the dex VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # generated files 15 | bin/ 16 | out/ 17 | gen/ 18 | 19 | # Libraries used by the app 20 | # Can explicitly add if we want, but shouldn't do so blindly. Licenses, bloat, etc. 21 | /libs 22 | 23 | 24 | # Build stuff (auto-generated by android update project ...) 25 | build.xml 26 | ant.properties 27 | local.properties 28 | 29 | # Eclipse project files 30 | .classpath 31 | .project 32 | 33 | # idea project files 34 | .idea/ 35 | .idea/.name 36 | *.iml 37 | *.ipr 38 | *.iws 39 | 40 | ##Gradle-based build 41 | .gradle 42 | build/ 43 | -------------------------------------------------------------------------------- /lvl_sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | namespace 'com.example.google.play.licensing' 5 | compileSdk 34 6 | defaultConfig { 7 | applicationId "com.example.google.play.licensing" 8 | minSdk 8 9 | targetSdk 34 10 | testApplicationId "com.example.google.play.licensing.test" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation project(':lvl_library') 23 | androidTestImplementation 'com.android.support.test:runner:0.5' 24 | } 25 | -------------------------------------------------------------------------------- /lvl_library/src/main/aidl/com/android/vending/licensing/ILicenseResultListener.aidl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.vending.licensing; 18 | 19 | oneway interface ILicenseResultListener { 20 | void verifyLicense(int responseCode, String signedData, String signature); 21 | } 22 | -------------------------------------------------------------------------------- /lvl_library/src/main/aidl/com/android/vending/licensing/ILicensingService.aidl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.vending.licensing; 18 | 19 | import com.android.vending.licensing.ILicenseResultListener; 20 | 21 | oneway interface ILicensingService { 22 | void checkLicense(long nonce, String packageName, in ILicenseResultListener listener); 23 | } 24 | -------------------------------------------------------------------------------- /lvl_library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lvl_library/src/main/java/com/google/android/vending/licensing/util/Base64DecoderException.java: -------------------------------------------------------------------------------- 1 | // Copyright 2002, Google, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.google.android.vending.licensing.util; 16 | 17 | /** 18 | * Exception thrown when encountering an invalid Base64 input character. 19 | * 20 | * @author nelson 21 | */ 22 | public class Base64DecoderException extends Exception { 23 | public Base64DecoderException() { 24 | super(); 25 | } 26 | 27 | public Base64DecoderException(String s) { 28 | super(s); 29 | } 30 | 31 | private static final long serialVersionUID = 1L; 32 | } 33 | -------------------------------------------------------------------------------- /lvl_library/src/main/java/com/google/android/vending/licensing/ValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.android.vending.licensing; 18 | 19 | /** 20 | * Indicates that an error occurred while validating the integrity of data managed by an 21 | * {@link Obfuscator}.} 22 | */ 23 | public class ValidationException extends Exception { 24 | public ValidationException() { 25 | super(); 26 | } 27 | 28 | public ValidationException(String s) { 29 | super(s); 30 | } 31 | 32 | private static final long serialVersionUID = 1L; 33 | } 34 | -------------------------------------------------------------------------------- /lvl_library/src/main/java/com/google/android/vending/licensing/NullDeviceLimiter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.android.vending.licensing; 18 | 19 | /** 20 | * A DeviceLimiter that doesn't limit the number of devices that can use a 21 | * given user's license. 22 | *

23 | * Unless you have reason to believe that your application is being pirated 24 | * by multiple users using the same license (signing in to Market as the same 25 | * user), we recommend you use this implementation. 26 | */ 27 | public class NullDeviceLimiter implements DeviceLimiter { 28 | 29 | public int isDeviceAllowed(String userId) { 30 | return Policy.LICENSED; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lvl_sample/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 27 |