Commit 2ca9e66b authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Merge branch 'dev' into 'master'

Dev

Closes #144, #141, and #132

See merge request !31
parents 52f27e4d 81cfb4e6
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "27"
ANDROID_BUILD_TOOLS: "27.0.3"
ANDROID_SDK_TOOLS: "26.0.2"
AVD_NAME: test
DEV_DEPLOY_DIR: /var/www/frostnerd/download/appbuilds/dnschanger/ci/dev
RELEASE_DEPLOY_DIR: /var/www/frostnerd/download/appbuilds/dnschanger/ci/releases
image: thyrlian/android-sdk
before_script:
- source /home/public/android-sdk-linux/initAndroid.sh -s ${ANDROID_COMPILE_SDK} -b ${ANDROID_BUILD_TOOLS}
- chmod +x gradlew
stages:
- init
- build
- test
- webdeploy
init:
stage: init
script:
- git config --file=.gitmodules submodule.AndroidUtils.url https://runner:$USER_PASS@git.frostnerd.com/AndroidApps/AndroidUtils.git
- git submodule sync
- git submodule update --init --recursive --force --remote
except:
- /^no_ci.*$/
build:
stage: build
script:
- /./home/public/gitrunner/changeAppVersion.sh app/build.gradle " $CI_COMMIT_REF_NAME\_$CI_PIPELINE_ID" --append
- chmod +x changeVersion.sh
- ./changeVersion.sh app/build.gradle " $CI_COMMIT_REF_NAME\_$CI_PIPELINE_ID" --append
- ./gradlew assembleDebug --stacktrace
artifacts:
paths:
......@@ -43,51 +25,35 @@ build:
build_release:
stage: build
script:
- ./gradlew clean check assembleRelease --stacktrace -Pandroid.injected.signing.store.file=$KEYSTORE_FILE -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEYSTORE_KEY_NAME -Pandroid.injected.signing.key.password=$KEYSTORE_KEY_PASSWORD -x test
only:
- release
- wget -O $KEYSTORE_FILE $KEYSTORE_URL -q
- ./gradlew clean check assembleRelease --stacktrace -Pandroid.injected.signing.store.file=$KEYSTORE_FILE -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEYSTORE_KEY_NAME -Pandroid.injected.signing.key.password=$KEYSTORE_KEY_PASSWORD -x test
artifacts:
paths:
- app/build/outputs/apk/release/app-release.apk
#upload:
# stage: webdeploy
# script:
# - cp -f app/build/outputs/apk/debug/app-debug.apk $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk
# - /./home/public/gitrunner/logCIBuilds.sh $DEV_DEPLOY_DIR
# - ln -s -f $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk $DEV_DEPLOY_DIR/0_latest_$CI_COMMIT_REF_NAME.apk
# except:
# - /^no_ci.*$/
# - /^no_deploy.*$/
# - /^no_tests_no_deploy.*$/
# - /^no_build_no_deploy.*$/
# - /^no_build.*$/
# - release
# artifacts:
# paths:
# - $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk
unitTests:
stage: test
script:
- ./gradlew test --stacktrace || (zip -r tests.zip AndroidUtils/library/build/reports/tests/ app/build/reports/tests && exit 1)
- zip -r tests.zip AndroidUtils/library/build/reports/tests/ app/build/reports/tests
except:
- /^no_ci.*$/
- /^no_tests.*$/
- /^no_build_no_tests.*$/
- /^no_tests_no_deploy.*$/
artifacts:
when: always
paths:
- tests.zip
upload:
stage: webdeploy
script:
- cp -f app/build/outputs/apk/debug/app-debug.apk $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk
- /./home/public/gitrunner/logCIBuilds.sh $DEV_DEPLOY_DIR
- ln -s -f $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk $DEV_DEPLOY_DIR/0_latest_$CI_COMMIT_REF_NAME.apk
except:
- /^no_ci.*$/
- /^no_deploy.*$/
- /^no_tests_no_deploy.*$/
- /^no_build_no_deploy.*$/
- /^no_build.*$/
- release
artifacts:
paths:
- $DEV_DEPLOY_DIR/$CI_COMMIT_REF_NAME-$CI_PIPELINE_ID.apk
upload_release:
stage: webdeploy
script:
- cp -f app/build/outputs/apk/release/app-release.apk $RELEASE_DEPLOY_DIR/$(/./home/public/gitrunner/determineAppVersionName.sh app/build/outputs/apk/release/app-release.apk).apk
only:
- release
#upload_release:
# stage: webdeploy
# script:
# - cp -f app/build/outputs/apk/release/app-release.apk $RELEASE_DEPLOY_DIR/$(/./home/public/gitrunner/determineAppVersionName.sh app/build/outputs/apk/release/app-release.apk).apk
# only:
# - release
#functionalTests:
# stage: test
......
[submodule "AndroidUtils"]
path = AndroidUtils
url = ../../AndroidApps/AndroidUtils
Subproject commit fd07ee7992e685e805b8752ffee26f0e9c09bdf5
[![build status](https://git.frostnerd.com/PublicAndroidApps/DnsChanger/badges/master/build.svg)](https://git.frostnerd.com/PublicAndroidApps/DnsChanger/commits/master)
[![build status](https://git.frostnerd.com/PublicAndroidApps/DnsChanger/badges/master/pipeline.svg)](https://git.frostnerd.com/PublicAndroidApps/DnsChanger/commits/master)
<br>You can download all artifacts at https://dl.frostnerd.com/appbuilds
They are unsigned.<br><br>
This is the source code for my app DNS Changer, which can be found here: https://play.google.com/store/apps/details?id=com.frostnerd.dnschanger<br><br>
**Important**: As it is quite old I'd suggest you to use my other app Nebulo. It doesn't have normal (unencrypted) DNS and rather relies on DNS-over-HTTPS and DNS-over-TLS (Private DNS). It also looks better and is more stable.<br>
It is open source as well. You can find it on Google Play [here](https://play.google.com/store/apps/details?id=com.frostnerd.smokescreen) and the source code [here](https://git.frostnerd.com/PublicAndroidApps/Smokescreen).
I'd suggest you check out the repo as it contains useful information and also information on how to download Nebulo using the F-Droid app.
Have a look at the wiki for this app: https://git.frostnerd.com/PublicAndroidApps/DnsChanger/wikis/home<br>
This app could possibly spy on using the VPN connection which has to be used to apply the choosen DNS Servers. It doesn't. This project is open source so that people familiar with java/Android can check on this promise.
If you are not familiar with it: The VPN is only local. Using the VPN you are assigned an IP-Address which can't be used in the internet (192.168.0.1) and connect to the device only (127.0.0.1:8087),
NOT to an endpoint in the internet. The relevant code lines are those: https://git.frostnerd.com/PublicAndroidApps/DnsChanger/blob/master/app/src/main/java/com/frostnerd/dnschanger/DNSVpnService.java#L239-245
<br><br>
Feel free to contribute to this project, it's completely free to sign up and I'd be happy to fix issues or implement requests.<br><br>
---
Have a look at the wiki for this app: https://git.frostnerd.com/PublicAndroidApps/DnsChanger/wikis/home<br>
This app could possibly spy on using the VPN connection which has to be used to apply the chosen DNS Servers. **It doesn't**. This project is open source so that people familiar with Java/Android can check on this promise.<br>
© Daniel Wolf 2019
Feel free to contribute to this project, it's completely free to sign up and I'd be happy to fix issues or implement requests.<br>
I would also be very grateful for translations. I have a WebLate instance where you can add and manage translations. It can be found [here](https://weblate.frostnerd.com/projects/dns-changer/).
This app uses the library dnsjava. License:
>Copyright (c) 1998-2011, Brian Wellington.
>All rights reserved.
>
>Redistribution and use in source and binary forms, with or without
>modification, are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright notice,
> this list of conditions and the following disclaimer.
>
> * Redistributions in binary form must reproduce the above copyright notice,
> this list of conditions and the following disclaimer in the documentation
> and/or other materials provided with the distribution.
>
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
>AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
>LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
© Daniel Wolf 2020<br>
All rights reserved.
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'project-report'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 30
defaultConfig {
applicationId "com.frostnerd.dnschanger"
minSdkVersion 14
targetSdkVersion 27
versionCode 89
versionName "1.16.0.7"
minSdkVersion 19
targetSdkVersion 30
versionCode 125
versionName "1.16.5.11"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("Boolean", "SENTRY_ENABLED", "true")
buildConfigField("String", "SENTRY_DSN", '"dummy"')
}
debug{
initWith(buildTypes.debug)
minifyEnabled true
shrinkResources true
zipAlignEnabled true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("Boolean", "SENTRY_ENABLED", "true")
buildConfigField("String", "SENTRY_DSN", '"dummy"')
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/library_release.kotlin_module'
}
testOptions {
unitTests.returnDefaultValues = true
unitTests {
includeAndroidResources = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:preference-v14:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation project(path: ':AndroidUtils:library')
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:3.6.1"
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'dnsjava:dnsjava:2.1.8'
implementation 'org.pcap4j:pcap4j-core:1.7.3'
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.7.3'
implementation 'de.measite.minidns:minidns-core:0.2.2'
compileOnly 'org.projectlombok:lombok:1.16.20'
annotationProcessor "org.projectlombok:lombok:1.16.20"
implementation 'com.frostnerd.utils:general:1.0.10'
implementation 'com.frostnerd.utils:database:1.1.25'
implementation 'com.frostnerd.utils:design:1.0.14-fix19'
implementation 'com.frostnerd.utils:materialedittext:1.0.21'
implementation 'com.frostnerd.utils:preferences:2.4.11'
implementation 'com.frostnerd.utils:networking:1.0.5'
implementation 'com.frostnerd.utils:preferenceexport:1.0.10'
implementation 'com.frostnerd.utils:api:1.0.6'
implementation 'io.sentry:sentry-android:4.0.0-alpha.2'
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.preference:preference:1.1.1"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-alpha01'
implementation "com.google.android.material:material:1.2.1"
testImplementation 'junit:junit:4.13'
testImplementation "org.robolectric:robolectric:4.4"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.pcap4j:pcap4j-core:1.8.2'
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.8.2'
implementation 'org.minidns:minidns-core:1.0.0'
implementation 'org.minidns:minidns-hla:1.0.0'
implementation 'com.google.android.play:core:1.9.0'
}
This diff is collapsed.
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\Dev\AndroidSDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}
# This dnsjava class uses old Sun API
-dontnote org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-optimizationpasses 5
-dontwarn java.awt.*
# See http://stackoverflow.com/questions/5701126, happens in dnsjava
-optimizations !code/allocation/variable
-keep class android.support.v7.widget.SearchView { *; }
-keep class com.frostnerd.dnschanger.util.GenericFileProvider
-keep class com.frostnerd.dnschanger.activities.PinActivity
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.frostnerd.dnschanger"
android:installLocation="internalOnly">
......@@ -11,8 +12,12 @@
<uses-permission
android:name="android.permission.USE_FINGERPRINT"
android:required="false" />
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<permission
android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
......@@ -40,11 +45,16 @@
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:hardwareAccelerated="true"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/security_config"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme_Mono">
<meta-data android:name="io.sentry.auto-init" android:value="false" />
<meta-data
android:name="android.max_aspect"
......@@ -81,6 +91,8 @@
<intent-filter>
<action android:name="android.net.VpnService" />
</intent-filter>
<meta-data android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
android:value="true" />
</service>
<activity
......@@ -93,6 +105,11 @@
android:launchMode="singleInstance"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
<activity
android:name=".activities.BackgroundDNSListActivity"
android:launchMode="singleInstance"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
<activity
android:name=".tasker.ConfigureActivity"
android:exported="true"
......@@ -112,6 +129,8 @@
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
......@@ -125,6 +144,8 @@
</receiver>
<service android:name=".services.ConnectivityBackgroundService" />
<service android:name=".services.ConnectivityCheckRestartService" />
<service
android:name=".services.DataService"
android:exported="true"
......@@ -134,10 +155,6 @@
<action android:name="com.frostnerd.dnschanger.services.DataService" />
</intent-filter>
</service>
<service
android:name=".services.jobs.ConnectivityJobAPI21"
android:label="Connectivity Service"
android:permission="android.permission.BIND_JOB_SERVICE" />
<activity
android:name=".activities.ShortcutActivity"
......@@ -152,10 +169,26 @@
android:targetActivity=".activities.ShortcutActivity"
android:taskAffinity="com.frostnerd.dnschangerShortcut"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
<activity android:name=".activities.automation.PauseDnsActivity"
android:exported="true"
/>
<activity android:name=".activities.automation.ResumeDnsActivity"
android:exported="true"
/>
<activity android:name=".activities.automation.StartDnsActivity"
android:exported="true"
/>
<activity android:name=".activities.automation.StopDnsActivity"
android:exported="true"
/>
<activity android:name=".activities.automation.ToggleDnsActivity"
android:exported="true"
/>
<activity
android:name=".activities.PinActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -175,6 +208,7 @@
<activity
android:name=".activities.AppSelectionActivity"
android:launchMode="singleTask"
android:parentActivityName=".activities.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
......@@ -246,6 +280,8 @@
</intent-filter>
</activity>
<activity android:name="com.frostnerd.design.filechooseractivity.FileChooserActivity" />
<receiver
android:name=".receivers.AdminReceiver"
android:description="@string/device_admin_description"
......@@ -259,8 +295,18 @@
</intent-filter>
</receiver>
<receiver android:name=".receivers.UpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="com.frostnerd.dnschanger"
android:exported="false"
android:grantUriPermissions="true">
......@@ -279,15 +325,6 @@
android:resource="@xml/generic_provider_paths" />
</provider>
<!--<receiver android:name=".widgets.BasicWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/basic_widget" />
</receiver>-->
<service
android:name=".services.RuleImportService"
android:stopWithTask="false" />
......
app/src/main/ic_launcher-web.png

18.9 KB | W: | H:

app/src/main/ic_launcher-web.png

16.2 KB | W: | H:

app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
  • 2-up
  • Swipe
  • Onion skin
package com.frostnerd.dnschanger;
import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteException;
import androidx.annotation.Keep;
import com.frostnerd.dnschanger.activities.ErrorDialogActivity;
import com.frostnerd.dnschanger.database.DatabaseHelper;
import com.frostnerd.dnschanger.util.DataSavingSentryEventProcessor;
import com.frostnerd.dnschanger.util.Preferences;
import com.frostnerd.dnschanger.util.ThemeHandler;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import io.sentry.Integration;
import io.sentry.Sentry;
import com.frostnerd.dnschanger.BuildConfig;
import io.sentry.android.core.PhoneStateBreadcrumbsIntegration;
import io.sentry.android.core.SentryAndroid;
import io.sentry.android.core.SentryAndroidOptions;
import io.sentry.android.core.SystemEventsBreadcrumbsIntegration;
import io.sentry.android.core.TempSensorBreadcrumbsIntegration;
import io.sentry.protocol.User;
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
*
......@@ -29,6 +49,10 @@ public class DNSChanger extends Application {
private final Thread.UncaughtExceptionHandler customHandler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
maybeReportSentry(e);
try {
Thread.sleep(750);
} catch (InterruptedException ignored) {}
LogFactory.writeMessage(DNSChanger.this, new String[]{LOG_TAG, LogFactory.Tag.ERROR.toString()}, "Caught uncaught exception");
LogFactory.writeStackTrace(DNSChanger.this, new String[]{LOG_TAG, LogFactory.Tag.ERROR.toString()}, e);
if (showErrorDialog(e)) {
......@@ -39,6 +63,11 @@ public class DNSChanger extends Application {
}
};
private Thread.UncaughtExceptionHandler defaultHandler;
@Keep private DatabaseHelper helper;
private Preferences mPreferences;
private Boolean sentryInitialized = false, sentryInitializing = false, sentryDisabled = false;
// Sometimes you just have to say f it. Don't ask me why, but Context is sometimes null in MainFragment
public static Context context;
private boolean showErrorDialog(Throwable exception) {
if(exception instanceof SQLiteException || (exception.getCause() != null && exception instanceof SQLiteException))return true;
......@@ -48,10 +77,86 @@ public class DNSChanger extends Application {
@Override
public void onCreate() {
setTheme(ThemeHandler.getAppTheme(this));
context = this;
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(customHandler);
super.onCreate();
LogFactory.writeMessage(this, LOG_TAG, "Application created");
helper = DatabaseHelper.getInstance(this);
mPreferences = Preferences.getInstance(this);
setupSentry();
}
public void maybeReportSentry(Throwable ex) {
if(sentryInitialized && !sentryDisabled) {
Sentry.captureException(ex);
}
}
// Creates the SentryClient
// Absolutely no identifiable data is transmitted (Thus it is not subject to GDPR)
// The Sentry instance does not store IP addresses
// Absolutely no tracking is possible.
// Can be turned off in the settings.
public void setupSentry() {
if(!sentryInitialized && !sentryInitializing && BuildConfig.SENTRY_ENABLED && !BuildConfig.SENTRY_DSN.equals("dummy")) {
sentryInitializing = true;
new Thread(new Runnable() {
@Override
public void run() {
try {
boolean enabled = !mPreferences.getBoolean("disable_crash_reporting", false);
if(enabled) {
String hostname = InetAddress.getLocalHost().getHostName();
if(hostname.toLowerCase().contains("mars-sandbox")){
sentryDisabled = true;
return;
}
SentryAndroid.init(DNSChanger.this, new Sentry.OptionsConfiguration<SentryAndroidOptions>() {
@Override
public void configure(SentryAndroidOptions options) {
options.setDsn(BuildConfig.SENTRY_DSN);
setupSentryForDatasaving(options);
}
});
User user = new User();
user.setUsername("anon-" + BuildConfig.VERSION_CODE);
Sentry.setUser(user);
Sentry.setTag("dist", BuildConfig.VERSION_CODE + "");
Sentry.setTag(
"app.installer_package",
getPackageManager().getInstallerPackageName(getPackageName())
);
Sentry.setTag("richdata", "false");
sentryInitialized = true;
}
} catch (Throwable ignored) {
} finally {
sentryInitializing = false;
}
}
}).start();
}
}
private void setupSentryForDatasaving(SentryAndroidOptions options) {
List<Integration> toBeRemoved = new ArrayList<>();
for (Integration integration : options.getIntegrations()) {
if (integration instanceof PhoneStateBreadcrumbsIntegration ||
integration instanceof SystemEventsBreadcrumbsIntegration ||
integration instanceof TempSensorBreadcrumbsIntegration
) toBeRemoved.add(integration);
}
for (Integration integration : toBeRemoved) {
options.getIntegrations().remove(integration);
}
options.addEventProcessor(new DataSavingSentryEventProcessor());
}
public void tearDownSentry() {
Sentry.close();
sentryInitialized