Repository: 1nikolas/play-integrity-checker-app Branch: main Commit: ee6316e906c7 Files: 49 Total size: 84.8 KB Directory structure: gitextract_9fpq23tj/ ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── assets/ │ │ └── licenses/ │ │ ├── Appcompat │ │ ├── Constraintlayout │ │ ├── Material Components for Android │ │ └── okhttp │ ├── java/ │ │ └── gr/ │ │ └── nikolasspyr/ │ │ └── integritycheck/ │ │ ├── MainActivity.java │ │ ├── Utils.java │ │ └── dialogs/ │ │ ├── AboutDialog.java │ │ └── licenses/ │ │ ├── License.java │ │ ├── LicensesAdapter.java │ │ ├── LicensesDialog.java │ │ └── LicensesViewModel.java │ └── res/ │ ├── drawable/ │ │ ├── ic_appicon.xml │ │ ├── ic_fail.xml │ │ ├── ic_gh.xml │ │ ├── ic_help.xml │ │ ├── ic_json.xml │ │ ├── ic_launcher_foreground.xml │ │ ├── ic_licenses.xml │ │ ├── ic_pass.xml │ │ └── ic_unknown.xml │ ├── layout/ │ │ ├── activity_main.xml │ │ ├── dialog_about.xml │ │ ├── dialog_licenses.xml │ │ ├── dialog_response.xml │ │ └── item_license.xml │ ├── menu/ │ │ └── menu.xml │ ├── mipmap-anydpi-v26/ │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ ├── values-night/ │ │ └── themes.xml │ └── xml/ │ ├── backup_rules.xml │ └── data_extraction_rules.xml ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Log/OS Files *.log # Android Studio generated files and folders captures/ .externalNativeBuild/ .cxx/ *.apk output.json # IntelliJ *.iml .idea/ misc.xml deploymentTargetDropDown.xml render.experimental.xml # Keystore files *.jks *.keystore # Android Profiling *.hprof # Mac OS .DS_Store ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2022 Nikolas Spiridakis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Play Integrity API Checker Get info about your Device Integrity through the Play Integrity API [Get it on Google Play](https://play.google.com/store/apps/details?id=gr.nikolasspyr.integritycheck) > [!WARNING] > If you don't install the app from Play Store and sideload it, you might not get the `MEETS_BASIC_INTEGRITY` and `MEETS_STRONG_INTEGRITY` results. > [!WARNING] > If you want to implement the Play Integrity API in your app you shouldn't do it this way. The API server should not send the whole JSON to the app, only a yes/no. Also ideally you should pair the integrity request with another one (for example login). That way your API won't let the user proceed without a valid Integrity token that passes integrity checks (even if your app is reverse engineered). ## Setup In order to run this yourself you'll need: 1) The [Play Integrity Checker Server](https://github.com/1nikolas/play-integrity-checker-server) 2) Your server url specified in `local.properties` like this: ``` API_URL=https://my-awesome-server-url.com ``` 3) The app to be on Play Store (otherwise you won't have access to `MEETS_BASIC_INTEGRITY` and `MEETS_STRONG_INTEGRITY`) 4) Play Integrity linked to a Google Cloud project through the Play Console with `MEETS_BASIC_INTEGRITY` and `MEETS_STRONG_INTEGRITY` enabled ![](https://user-images.githubusercontent.com/30593419/180609045-fe0da305-24d9-4ffb-a44d-4294a759c787.png) To set up your Google Cloud project see [here](https://github.com/1nikolas/play-integrity-checker-server#how-to-set-up-google-cloud) ## License MIT License ``` Copyright (c) 2022 Nikolas Spiridakis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` ================================================ FILE: app/.gitignore ================================================ /build /release ================================================ FILE: app/build.gradle ================================================ plugins { id 'com.android.application' } android { defaultConfig { applicationId "gr.nikolasspyr.integritycheck" minSdkVersion 21 targetSdkVersion 36 compileSdk = 36 versionCode 22 versionName "2.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //Get variables from local.properties Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) buildConfigField "String", "API_URL", "\"${properties.getProperty('API_URL')}\"" } buildFeatures { dataBinding = true buildConfig = true } buildTypes { release { minifyEnabled true shrinkResources = true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } namespace = 'gr.nikolasspyr.integritycheck' } dependencies { implementation 'androidx.appcompat:appcompat:1.7.1' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.2.1' implementation 'com.google.android.play:integrity:1.4.0' implementation 'com.squareup.okhttp3:okhttp:4.12.0' } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/assets/licenses/Appcompat ================================================ Copyright (C) 2014 The Android Open Source Project https://developer.android.com/jetpack/androidx/releases/appcompat Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: app/src/main/assets/licenses/Constraintlayout ================================================ Copyright (C) 2015 The Android Open Source Project https://developer.android.com/jetpack/androidx/releases/constraintlayout Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: app/src/main/assets/licenses/Material Components for Android ================================================ Copyright 2018 Google LLC https://github.com/material-components/material-components-android Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: app/src/main/assets/licenses/okhttp ================================================ Copyright 2019 Square, Inc. https://github.com/square/okhttp Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/MainActivity.java ================================================ package gr.nikolasspyr.integritycheck; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.constraintlayout.widget.Group; import androidx.core.content.ContextCompat; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import com.google.android.gms.tasks.Task; import com.google.android.material.button.MaterialButton; import com.google.android.material.color.MaterialColors; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.progressindicator.CircularProgressIndicator; import com.google.android.play.core.integrity.IntegrityManager; import com.google.android.play.core.integrity.IntegrityManagerFactory; import com.google.android.play.core.integrity.IntegrityServiceException; import com.google.android.play.core.integrity.IntegrityTokenRequest; import com.google.android.play.core.integrity.IntegrityTokenResponse; import com.google.android.play.core.integrity.model.IntegrityErrorCode; import org.json.JSONObject; import java.io.IOException; import java.util.Locale; import gr.nikolasspyr.integritycheck.dialogs.AboutDialog; import okhttp3.Call; import okhttp3.Callback; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; public class MainActivity extends AppCompatActivity { private MaterialButton btn; private ImageView deviceIntegrityIcon; private ImageView basicIntegrityIcon; private ImageView strongIntegrityIcon; private ImageView virtualIntegrityIcon; private Group virtualIntegrity; private String jsonResponse; private Integer[] integrityState = {-1, -1, -1, -1}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(R.string.app_name); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { ViewCompat.setOnApplyWindowInsetsListener( findViewById(android.R.id.content), (view, insets) -> { Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); view.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; } ); } btn = findViewById(R.id.check_btn); basicIntegrityIcon = findViewById(R.id.basic_integrity_icon); deviceIntegrityIcon = findViewById(R.id.device_integrity_icon); strongIntegrityIcon = findViewById(R.id.strong_integrity_icon); virtualIntegrityIcon = findViewById(R.id.virtual_integrity_icon); virtualIntegrity = findViewById(R.id.virtual_integrity); btn.setOnClickListener(view -> { toggleButtonLoading(true); jsonResponse = null; integrityState = new Integer[]{-1, -1, -1, -1}; setIcons(integrityState); getToken(); }); } private void getToken() { String nonce = generateNonce(); // Create an instance of a manager. IntegrityManager integrityManager = IntegrityManagerFactory.create(getApplicationContext()); // Request the integrity token by providing a nonce. Task integrityTokenResponseTask = integrityManager.requestIntegrityToken( IntegrityTokenRequest.builder() .setNonce(nonce) .build()); integrityTokenResponseTask.addOnSuccessListener(integrityTokenResponse -> sendTokenRequest(integrityTokenResponse.token())); integrityTokenResponseTask.addOnFailureListener(e -> { toggleButtonLoading(false); String errorMessage; if (e instanceof IntegrityServiceException) { errorMessage = getErrorMessageText((IntegrityServiceException) e); } else { errorMessage = e.getMessage(); } showErrorDialog(getString(R.string.token_error_title), errorMessage); }); } private void sendTokenRequest(String token) { OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .get() .url(BuildConfig.API_URL + "/api/check?token=" + token) .build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(@NonNull Call call, @NonNull IOException e) { onRequestError(e.getMessage()); } @Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException { if (!response.isSuccessful()) { onRequestError(String.format(Locale.US, getString(R.string.server_api_error_status_code), response.code())); return; } ResponseBody responseBody = response.body(); if (responseBody == null) { onRequestError(getString(R.string.server_api_error_empty_res)); return; } String responseBodyString = responseBody.string(); try { parseResponseJSON(responseBodyString); } catch (Exception e) { onRequestError(e.getMessage()); } } }); } private void onRequestError(String error) { runOnUiThread(() -> { showErrorDialog(getString(R.string.server_api_error_title), error); toggleButtonLoading(false); }); } private void parseResponseJSON(String apiResponseJson) throws Exception { JSONObject json = new JSONObject(apiResponseJson); if (json.has("error")) { throw new Exception(json.getString("error")); } JSONObject result; if (json.has("deviceIntegrity")) { result = json.getJSONObject("deviceIntegrity"); jsonResponse = json.toString(4); } else { result = new JSONObject(); } if (result.has("deviceRecognitionVerdict")) { integrityState = parseValues(result.get("deviceRecognitionVerdict").toString()); } else { integrityState = parseValues(""); } runOnUiThread(() -> setIcons(integrityState)); runOnUiThread(() -> toggleButtonLoading(false)); } private void toggleButtonLoading(boolean isLoading) { setButtonLoading(btn, isLoading); btn.setEnabled(!isLoading); } private Drawable getProgressBarDrawable(Context context) { CircularProgressIndicator drawable = new CircularProgressIndicator(context); drawable.setIndicatorSize(48); drawable.setTrackThickness(5); drawable.setIndicatorColor(MaterialColors.getColor(context, com.google.android.material.R.attr.colorSecondary, Color.BLUE)); drawable.setIndeterminate(true); return drawable.getIndeterminateDrawable(); } private void setButtonLoading(MaterialButton button, boolean loading) { button.setMaxLines(1); button.setEllipsize(TextUtils.TruncateAt.END); button.setIconGravity(MaterialButton.ICON_GRAVITY_START); if (loading) { Drawable drawable = button.getIcon(); if (!(drawable instanceof Animatable)) { drawable = getProgressBarDrawable(button.getContext()); if (drawable instanceof Animatable) { button.setIcon(drawable); ((Animatable) drawable).start(); } } } else { button.setIcon(null); } } private String generateNonce() { int length = 50; String nonce = ""; String allowed = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (int i = 0; i < length; i++) { nonce = nonce.concat(String.valueOf(allowed.charAt((int) Math.floor(Math.random() * allowed.length())))); } return nonce; } private void showErrorDialog(String title, String message) { new MaterialAlertDialogBuilder(MainActivity.this, R.style.Theme_PlayIntegrityAPIChecker_Dialogs) .setTitle(title) .setCancelable(true) .setPositiveButton(R.string.ok, (dialogInterface, i) -> { }) .setMessage(message) .show(); } private Integer[] parseValues(String integrity) { return new Integer[]{integrity.contains("MEETS_BASIC_INTEGRITY") ? 1 : 0, integrity.contains("MEETS_DEVICE_INTEGRITY") ? 1 : 0, integrity.contains("MEETS_STRONG_INTEGRITY") ? 1 : 0, integrity.contains("MEETS_VIRTUAL_INTEGRITY") ? 1 : -1}; } private void setIcons(Integer[] integrityState) { setIcon(basicIntegrityIcon, integrityState[0]); setIcon(deviceIntegrityIcon, integrityState[1]); setIcon(strongIntegrityIcon, integrityState[2]); setIcon(virtualIntegrityIcon, integrityState[3]); if (integrityState[3] != -1) { virtualIntegrity.setVisibility(View.VISIBLE); } else { virtualIntegrity.setVisibility(View.GONE); } } private void setIcon(ImageView img, int state) { if (state == -1) { img.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_unknown)); img.setContentDescription(getString(R.string.status_unknown)); } else if (state == 0) { img.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_fail)); img.setContentDescription(getString(R.string.status_fail)); } else { img.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_pass)); img.setContentDescription(getString(R.string.status_pass)); } } private String getErrorCodeName(int errorCode) { return switch (errorCode) { case IntegrityErrorCode.NO_ERROR -> "NO_ERROR"; case IntegrityErrorCode.API_NOT_AVAILABLE -> "API_NOT_AVAILABLE"; case IntegrityErrorCode.PLAY_STORE_NOT_FOUND -> "PLAY_STORE_NOT_FOUND"; case IntegrityErrorCode.NETWORK_ERROR -> "NETWORK_ERROR"; case IntegrityErrorCode.PLAY_STORE_ACCOUNT_NOT_FOUND -> "PLAY_STORE_ACCOUNT_NOT_FOUND"; case IntegrityErrorCode.APP_NOT_INSTALLED -> "APP_NOT_INSTALLED"; case IntegrityErrorCode.PLAY_SERVICES_NOT_FOUND -> "PLAY_SERVICES_NOT_FOUND"; case IntegrityErrorCode.APP_UID_MISMATCH -> "APP_UID_MISMATCH"; case IntegrityErrorCode.TOO_MANY_REQUESTS -> "TOO_MANY_REQUESTS"; case IntegrityErrorCode.CANNOT_BIND_TO_SERVICE -> "CANNOT_BIND_TO_SERVICE"; case IntegrityErrorCode.NONCE_TOO_SHORT -> "NONCE_TOO_SHORT"; case IntegrityErrorCode.NONCE_TOO_LONG -> "NONCE_TOO_LONG"; case IntegrityErrorCode.GOOGLE_SERVER_UNAVAILABLE -> "GOOGLE_SERVER_UNAVAILABLE"; case IntegrityErrorCode.NONCE_IS_NOT_BASE64 -> "NONCE_IS_NOT_BASE64"; case IntegrityErrorCode.PLAY_STORE_VERSION_OUTDATED -> "PLAY_STORE_VERSION_OUTDATED"; case IntegrityErrorCode.PLAY_SERVICES_VERSION_OUTDATED -> "PLAY_SERVICES_VERSION_OUTDATED"; case IntegrityErrorCode.CLOUD_PROJECT_NUMBER_IS_INVALID -> "CLOUD_PROJECT_NUMBER_IS_INVALID"; case IntegrityErrorCode.CLIENT_TRANSIENT_ERROR -> "CLIENT_TRANSIENT_ERROR"; case IntegrityErrorCode.INTERNAL_ERROR -> "INTERNAL_ERROR"; default -> "UNKNOWN_ERROR_CODE"; }; } private String getErrorReason(int errorCode) { return switch (errorCode) { case IntegrityErrorCode.API_NOT_AVAILABLE -> getString(R.string.error_reason_api_not_available); case IntegrityErrorCode.APP_NOT_INSTALLED -> getString(R.string.error_reason_app_not_installed); case IntegrityErrorCode.APP_UID_MISMATCH -> getString(R.string.error_reason_app_uid_mismatch); case IntegrityErrorCode.CANNOT_BIND_TO_SERVICE -> getString(R.string.error_reason_cannot_bind_to_service); case IntegrityErrorCode.CLIENT_TRANSIENT_ERROR -> getString(R.string.error_reason_client_transient_error); case IntegrityErrorCode.CLOUD_PROJECT_NUMBER_IS_INVALID -> getString(R.string.error_reason_cloud_project_number_is_invalid); case IntegrityErrorCode.GOOGLE_SERVER_UNAVAILABLE -> getString(R.string.error_reason_google_server_unavailable); case IntegrityErrorCode.INTERNAL_ERROR -> getString(R.string.error_reason_internal_error); case IntegrityErrorCode.NETWORK_ERROR -> getString(R.string.error_reason_network_error); case IntegrityErrorCode.NONCE_IS_NOT_BASE64 -> getString(R.string.error_reason_nonce_is_not_base64); case IntegrityErrorCode.NONCE_TOO_LONG -> getString(R.string.error_reason_nonce_too_long); case IntegrityErrorCode.NONCE_TOO_SHORT -> getString(R.string.error_reason_nonce_too_short); case IntegrityErrorCode.NO_ERROR -> ""; case IntegrityErrorCode.PLAY_SERVICES_NOT_FOUND -> getString(R.string.error_reason_play_services_not_found); case IntegrityErrorCode.PLAY_SERVICES_VERSION_OUTDATED -> getString(R.string.error_reason_play_services_outdated); case IntegrityErrorCode.PLAY_STORE_ACCOUNT_NOT_FOUND -> getString(R.string.error_reason_play_store_account_not_found); case IntegrityErrorCode.PLAY_STORE_NOT_FOUND -> getString(R.string.error_reason_play_store_not_found); case IntegrityErrorCode.PLAY_STORE_VERSION_OUTDATED -> getString(R.string.error_reason_play_store_version_outdated); case IntegrityErrorCode.TOO_MANY_REQUESTS -> getString(R.string.error_reason_too_many_requests); default -> getString(R.string.error_reason_unknown); }; } private String getErrorSolution(int errorCode) { return switch (errorCode) { case IntegrityErrorCode.API_NOT_AVAILABLE, IntegrityErrorCode.CANNOT_BIND_TO_SERVICE, IntegrityErrorCode.PLAY_STORE_VERSION_OUTDATED -> getString(R.string.error_solution_update_play_store); case IntegrityErrorCode.APP_NOT_INSTALLED, IntegrityErrorCode.APP_UID_MISMATCH -> getString(R.string.error_solution_something_wrong_attack); case IntegrityErrorCode.CLIENT_TRANSIENT_ERROR, IntegrityErrorCode.GOOGLE_SERVER_UNAVAILABLE, IntegrityErrorCode.INTERNAL_ERROR -> getString(R.string.error_solution_try_again); case IntegrityErrorCode.CLOUD_PROJECT_NUMBER_IS_INVALID, IntegrityErrorCode.NONCE_IS_NOT_BASE64, IntegrityErrorCode.NONCE_TOO_LONG, IntegrityErrorCode.NONCE_TOO_SHORT, IntegrityErrorCode.NO_ERROR -> getString(R.string.error_solution_open_issue); case IntegrityErrorCode.NETWORK_ERROR -> getString(R.string.error_solution_check_connection); case IntegrityErrorCode.PLAY_SERVICES_NOT_FOUND -> getString(R.string.error_solution_install_update_play_services); case IntegrityErrorCode.PLAY_SERVICES_VERSION_OUTDATED -> getString(R.string.error_solution_update_play_services); case IntegrityErrorCode.PLAY_STORE_ACCOUNT_NOT_FOUND -> getString(R.string.error_solution_login); case IntegrityErrorCode.PLAY_STORE_NOT_FOUND -> getString(R.string.error_solution_install_official_play_store); case IntegrityErrorCode.TOO_MANY_REQUESTS -> getString(R.string.error_solution_try_again_later); default -> ""; }; } private String getErrorMessageText(IntegrityServiceException integrityServiceException) { int errorCode = integrityServiceException.getErrorCode(); StringBuilder errorMessageBuilder = new StringBuilder(); errorMessageBuilder.append(String.format(Locale.US, "%s (%d)", getErrorCodeName(errorCode), errorCode)); String errorReason = getErrorReason(errorCode); if (!errorReason.isEmpty()) { errorMessageBuilder.append("\n"); errorMessageBuilder.append(errorReason); } String errorSolution = getErrorSolution(errorCode); if (!errorSolution.isEmpty()) { errorMessageBuilder.append("\n\n"); errorMessageBuilder.append(errorSolution); } return errorMessageBuilder.toString(); } // Menu stuff @Override public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.about) { new AboutDialog(MainActivity.this).show(); return true; } else if (id == R.id.json_response) { if (jsonResponse == null) { Toast.makeText(this, R.string.check_first, Toast.LENGTH_SHORT).show(); } else { AlertDialog dialog = new MaterialAlertDialogBuilder(MainActivity.this, R.style.Theme_PlayIntegrityAPIChecker_Dialogs) .setTitle(R.string.json_response) .setCancelable(true) .setPositiveButton(R.string.ok, null) .setNeutralButton(R.string.copy_json, (dialogInterface, i) -> { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("", jsonResponse); clipboard.setPrimaryClip(clip); dialogInterface.dismiss(); Toast.makeText(MainActivity.this, getString(R.string.copied), Toast.LENGTH_SHORT).show(); }) .setView(R.layout.dialog_response) .show(); TextView text = dialog.findViewById(R.id.message); if (text == null) { dialog.dismiss(); return true; } text.setText(jsonResponse); } return true; } else if (id == R.id.documentation) { Utils.openLink(getString(R.string.docs_link), this); return true; } else { return super.onOptionsItemSelected(item); } } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/Utils.java ================================================ package gr.nikolasspyr.integritycheck; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.widget.Toast; public class Utils { public static void openLink(String url, Context context) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); try { context.startActivity(i); } catch (ActivityNotFoundException e) { //For devices that have no browsers Toast.makeText(context, R.string.no_browser_found, Toast.LENGTH_LONG).show(); } } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/dialogs/AboutDialog.java ================================================ package gr.nikolasspyr.integritycheck.dialogs; import android.content.Context; import android.view.View; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import com.google.android.material.button.MaterialButton; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.Locale; import gr.nikolasspyr.integritycheck.BuildConfig; import gr.nikolasspyr.integritycheck.R; import gr.nikolasspyr.integritycheck.Utils; import gr.nikolasspyr.integritycheck.dialogs.licenses.LicensesDialog; public class AboutDialog { private final AlertDialog dialog; public AboutDialog(Context context) { dialog = new MaterialAlertDialogBuilder(context, R.style.Theme_PlayIntegrityAPIChecker_Dialogs) .setPositiveButton(R.string.ok, (dialog, which) -> { }) .create(); View dialogView = View.inflate(context, R.layout.dialog_about, null); dialog.setView(dialogView); TextView aboutText = dialogView.findViewById(R.id.about_text); aboutText.setText(String.format(Locale.US, context.getResources().getString(R.string.about_text), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); MaterialButton githubBtn = dialogView.findViewById(R.id.about_github); MaterialButton licensesBtn = dialogView.findViewById(R.id.about_licenses); githubBtn.setOnClickListener(v -> { Utils.openLink(context.getString(R.string.about_github_link), context); dialog.dismiss(); }); licensesBtn.setOnClickListener(v -> { new LicensesDialog(context).show(); dialog.dismiss(); }); } public void show() { dialog.show(); } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/dialogs/licenses/License.java ================================================ package gr.nikolasspyr.integritycheck.dialogs.licenses; public class License { public String subject; public String text; public License(String subject, String text) { this.subject = subject; this.text = text; } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/dialogs/licenses/LicensesAdapter.java ================================================ package gr.nikolasspyr.integritycheck.dialogs.licenses; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import java.util.List; import gr.nikolasspyr.integritycheck.R; public class LicensesAdapter extends RecyclerView.Adapter { private final LayoutInflater mInflater; private List mLicenses; public LicensesAdapter(Context c) { mInflater = LayoutInflater.from(c); } public void setLicenses(List licenses) { mLicenses = licenses; notifyItemRangeInserted(0, licenses.size()); } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(mInflater.inflate(R.layout.item_license, parent, false)); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { holder.bind(mLicenses.get(position)); } @Override public int getItemCount() { return mLicenses == null ? 0 : mLicenses.size(); } static class ViewHolder extends RecyclerView.ViewHolder { private final TextView title; private final TextView text; private ViewHolder(@NonNull View itemView) { super(itemView); title = itemView.findViewById(R.id.license_title); text = itemView.findViewById(R.id.license_text); } private void bind(License license) { title.setText(license.subject); text.setText(license.text); } } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/dialogs/licenses/LicensesDialog.java ================================================ package gr.nikolasspyr.integritycheck.dialogs.licenses; import android.content.Context; import android.view.View; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.button.MaterialButton; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import gr.nikolasspyr.integritycheck.R; public class LicensesDialog { private final AlertDialog dialog; private final Context context; public LicensesDialog(Context context) { this.context = context; dialog = new MaterialAlertDialogBuilder(context, R.style.Theme_PlayIntegrityAPIChecker_Dialogs) .setTitle(R.string.licenses) .setPositiveButton(R.string.ok, (dialog, which) -> { }) .create(); View dialogView = View.inflate(context, R.layout.dialog_licenses, null); dialog.setView(dialogView); RecyclerView recyclerView = dialogView.findViewById(R.id.licenses_recycler); recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.getRecycledViewPool().setMaxRecycledViews(0, 16); LicensesAdapter adapter = new LicensesAdapter(context); recyclerView.setAdapter(adapter); AppCompatActivity activity = (AppCompatActivity) context; LicensesViewModel viewModel = new LicensesViewModel(activity.getApplication()); viewModel.getLicenses().observe(activity, adapter::setLicenses); } public void show() { dialog.show(); MaterialButton button = (MaterialButton) dialog.getButton(AlertDialog.BUTTON_POSITIVE); button.setTextColor(context.getResources().getColor(R.color.blueSecondary)); button.setRippleColorResource(R.color.blueSecondary); } } ================================================ FILE: app/src/main/java/gr/nikolasspyr/integritycheck/dialogs/licenses/LicensesViewModel.java ================================================ package gr.nikolasspyr.integritycheck.dialogs.licenses; import android.app.Application; import android.content.res.AssetManager; import androidx.annotation.NonNull; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class LicensesViewModel extends AndroidViewModel { private final MutableLiveData> mLicenses = new MutableLiveData<>(); private final MutableLiveData mAreLicensesLoading = new MutableLiveData<>(); public LicensesViewModel(@NonNull Application application) { super(application); mLicenses.setValue(Collections.emptyList()); mAreLicensesLoading.setValue(false); loadLicences(); } public LiveData> getLicenses() { return mLicenses; } private void loadLicences() { if (Boolean.TRUE.equals(mAreLicensesLoading.getValue())) return; mAreLicensesLoading.setValue(true); new Thread(() -> { try { AssetManager assetManager = getApplication().getAssets(); String licensesDir = "licenses"; String[] rawLicenses = assetManager.list(licensesDir); assert rawLicenses != null; ArrayList licenses = new ArrayList<>(rawLicenses.length); for (String rawLicense : rawLicenses) licenses.add(new License(rawLicense, readStream(assetManager.open(licensesDir + "/" + rawLicense), "UTF-8"))); Collections.sort(licenses, (license1, license2) -> license1.subject.compareToIgnoreCase(license2.subject)); mLicenses.postValue(licenses); mAreLicensesLoading.postValue(false); } catch (Exception e) { mAreLicensesLoading.postValue(false); } }).start(); } public static void copyStream(InputStream from, OutputStream to) throws IOException { byte[] buf = new byte[1024 * 1024]; int len; while ((len = from.read(buf)) > 0) { to.write(buf, 0, len); } } public static byte[] readStream(InputStream inputStream) throws IOException { try (InputStream in = inputStream) { return readStreamNoClose(in); } } public static String readStream(InputStream inputStream, String charset) throws IOException { return new String(readStream(inputStream), charset); } public static byte[] readStreamNoClose(InputStream inputStream) throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); copyStream(inputStream, buffer); return buffer.toByteArray(); } } ================================================ FILE: app/src/main/res/drawable/ic_appicon.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_fail.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_gh.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_help.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_json.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_licenses.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_pass.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_unknown.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: app/src/main/res/layout/dialog_about.xml ================================================ ================================================ FILE: app/src/main/res/layout/dialog_licenses.xml ================================================ ================================================ FILE: app/src/main/res/layout/dialog_response.xml ================================================ ================================================ FILE: app/src/main/res/layout/item_license.xml ================================================ ================================================ FILE: app/src/main/res/menu/menu.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #000000 #ffffff #DE000000 #DEFFFFFF #4285f4 #ECF3FE #171E29 #0059c1 #121212 #3ec714 #c91818 #FFDA1A ================================================ FILE: app/src/main/res/values/ic_launcher_background.xml ================================================ #353937 ================================================ FILE: app/src/main/res/values/strings.xml ================================================ Play Integrity API Checker Error OK Check Integrity Checker Licenses Github Made by Nikolas Spiridakis\nVersion: %s (%d) About https://github.com/1nikolas/play-integrity-checker-app No browser found! Unknown Pass Fail Show JSON response Raw JSON response Please run a check first! Learn what the results mean https://developer.android.com/google/play/integrity/verdicts#optional-device-labels Copy JSON Copied to clipboard! Integrity API Error Server API Request Error API returned: %d Empty Response Integrity API is not available. The calling app is not installed. The calling app UID (user id) does not match the one from Package Manager. Binding to the service in the Play Store has failed. This can be due to having an old Play Store version installed on the device. There was a transient error in the client device. The provided cloud project number is invalid. Unknown internal Google server error. Unknown internal error. No available network is found. Nonce is not encoded as a base64 web-safe no-wrap string. Nonce length is too long. The nonce must be less than 500 bytes before base64 encoding. Nonce length is too short. The nonce must be a minimum of 16 bytes (before base64 encoding) to allow for a better security. Play Services is not available or version is too old. Play Services needs to be updated. No Play Store account is found on device. No Play Store app is found on device or not official version is installed. The Play Store needs to be updated. The calling app is making too many requests to the API and hence is throttled. Unknown error. Try updating Play Store. Something is wrong (possibly an attack). Try again. If this happens consistently, open an issue on Github. Check your connection. Try installing/updating Google Play Services. Try updating Google Play Services. Try logging in to Play Store. Try installing an official and recent version of Play Store. Try again later. ================================================ FILE: app/src/main/res/values/themes.xml ================================================ ================================================ FILE: app/src/main/res/values-night/themes.xml ================================================ ================================================ FILE: app/src/main/res/xml/backup_rules.xml ================================================ ================================================ FILE: app/src/main/res/xml/data_extraction_rules.xml ================================================ ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.12.0' apply false id 'com.android.library' version '8.12.0' apply false } tasks.register('clean', Delete) { delete layout.buildDirectory } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ #Thu Jan 16 16:08:38 EET 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true android.nonFinalResIds=false ================================================ FILE: gradlew ================================================ #!/bin/sh # # Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 # ############################################################################## # # Gradle start up script for POSIX generated by Gradle. # # Important for running: # # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is # noncompliant, but you have some other compliant shell such as ksh or # bash, then to run this script, type that shell name before the whole # command line, like: # # ksh Gradle # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # «${var#prefix}», «${var%suffix}», and «$( cmd )»; # * compound commands having a testable exit status, especially «case»; # * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # # (2) This script targets any POSIX shell, so it avoids extensions provided # by Bash, Ksh, etc; in particular arrays are avoided. # # The "traditional" practice of packing multiple parameters into a # space-separated string is a well documented source of bugs and security # problems, so this is (mostly) avoided, by progressively accumulating # options in "$@", and eventually passing that to Java. # # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; # see the in-line comments for details. # # There are tweaks for specific operating systems such as AIX, CygWin, # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. # ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link app_path=$0 # Need this for daisy-chained symlinks. while APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path [ -h "$app_path" ] do ls=$( ls -ld "$app_path" ) link=${ls#*' -> '} case $link in #( /*) app_path=$link ;; #( *) app_path=$APP_HOME$link ;; esac done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s ' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum warn () { echo "$*" } >&2 die () { echo echo "$*" echo exit 1 } >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "$( uname )" in #( CYGWIN* ) cygwin=true ;; #( Darwin* ) darwin=true ;; #( MSYS* | MINGW* ) msys=true ;; #( NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD=$JAVA_HOME/jre/sh/java else JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD=java if ! command -v java >/dev/null 2>&1 then die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi # Collect all arguments for the java command, stacking in reverse order: # * args from the command line # * the main class name # * -classpath # * -D...appname settings # * --module-path (only if needed) # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) # Now convert the arguments - kludge to limit ourselves to /bin/sh for arg do if case $arg in #( -*) false ;; # don't mess with options #( /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath [ -e "$t" ] ;; #( *) false ;; esac then arg=$( cygpath --path --ignore --mixed "$arg" ) fi # Roll the args list around exactly as many times as the number of # args, so each arg winds up back in the position where it started, but # possibly modified. # # NB: a `for` loop captures its iteration list before it begins, so # changing the positional parameters here affects neither the number of # iterations, nor the values presented in `arg`. shift # remove old arg set -- "$@" "$arg" # push replacement arg done fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ org.gradle.wrapper.GradleWrapperMain \ "$@" # Stop when "xargs" is not available. if ! command -v xargs >/dev/null 2>&1 then die "xargs is not available" fi # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. # # In Bash we could simply go: # # readarray ARGS < <( xargs -n1 <<<"$var" ) && # set -- "${ARGS[@]}" "$@" # # but POSIX shell has neither arrays nor command substitution, so instead we # post-process each arg (as a line of input to sed) to backslash-escape any # character that might be a shell metacharacter, then use eval to reverse # that process (while maintaining the separation between arguments), and wrap # the whole thing up as a single "set" statement. # # This will of course break if any of these variables contains a newline or # an unmatched quote. # eval "set -- $( printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | xargs -n1 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | tr '\n' ' ' )" '"$@"' exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @rem @rem Copyright 2015 the original author or authors. @rem @rem Licensed under the Apache License, Version 2.0 (the "License"); @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem @rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem @rem SPDX-License-Identifier: Apache-2.0 @rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Resolve any "." and ".." in APP_HOME to make it shorter. for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute echo. 1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute echo. 1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! set EXIT_CODE=%ERRORLEVEL% if %EXIT_CODE% equ 0 set EXIT_CODE=1 if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle ================================================ pluginManagement { repositories { gradlePluginPortal() google() mavenCentral() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } rootProject.name = "Play Integrity API Checker" include ':app'