Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/release' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
AsdMonio committed Sep 16, 2018
2 parents 00d8c3b + e3a68c4 commit 050ef24
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jdk:
android:
components:
- tools
- build-tools-28.0.0
- build-tools-28.0.2
- android-28
- extra-google-m2repository
- extra-android-m2repository
Expand Down
19 changes: 11 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
applicationId "projekt.substratum"
minSdkVersion 24
targetSdkVersion 28
versionCode 1001
versionName "one thousand one"
versionCode 1004
versionName "one thousand four"
buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
buildConfigField "String", "GIT_HASH", "\"${gitHash()}\""
buildConfigField "boolean", "ENHANCED_LOGGING", "false"
Expand Down Expand Up @@ -93,11 +93,11 @@ android {
}

ext {
databindingVersion = '3.3.0-alpha05'
androidXVersion = '1.0.0-rc01'
firebaseVersion = '16.0.1'
crashlyticsVersion = '2.9.4'
glideVersion = '4.7.1'
databindingVersion = '3.3.0-alpha08'
androidXVersion = '1.0.0-rc02'
firebaseVersion = '16.0.3'
crashlyticsVersion = '2.9.5'
glideVersion = '4.8.0'
}

dependencies {
Expand All @@ -116,7 +116,7 @@ dependencies {

// Firebase
implementation "com.google.firebase:firebase-core:$firebaseVersion"
implementation "com.google.firebase:firebase-database:$firebaseVersion"
implementation "com.google.firebase:firebase-database:16.0.1"

// Crashlytics
implementation "com.crashlytics.sdk.android:crashlytics:$crashlyticsVersion"
Expand Down Expand Up @@ -164,5 +164,8 @@ dependencies {

// Splash screen svg animation
implementation 'com.jaredrummler:animated-svg-view:1.0.5'

// SLF4J LoggerFactory
implementation 'org.slf4j:slf4j-api:1.7.16'
}
apply plugin: 'com.google.gms.google-services'
12 changes: 11 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,14 @@
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-keep public class android.support.design.R$* { *; }

# Crashlytics
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

# SLF4J
-keep class org.slf4j.** { *; }
27 changes: 9 additions & 18 deletions app/src/main/java/projekt/substratum/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,9 @@ private void showDialogOrNot(boolean passthrough) {
titleView.setVisibility(View.GONE);
} else if (Systems.isAndromedaDevice(context) &&
!AndromedaService.checkServerActivity()) {
TextView andromedaTitle = activity.progressDialog.findViewById(
R.id.andromeda_title);
Button andromedaOfflineButton =
activity.progressDialog.findViewById(R.id.andromeda_offline_button);
TextView andromedaDebugText =
activity.progressDialog.findViewById(R.id.andromeda_debug_text);
TextView andromedaTitle = activity.progressDialog.findViewById(R.id.andromeda_title);
Button andromedaOfflineButton = activity.progressDialog.findViewById(R.id.andromeda_offline_button);
TextView andromedaDebugText = activity.progressDialog.findViewById(R.id.andromeda_debug_text);
andromedaTitle.setVisibility(View.VISIBLE);
if (!checkAndromeda(context)) {
andromedaTitle.setText(R.string.andromeda_no_firebase);
Expand All @@ -1133,8 +1130,7 @@ private void showDialogOrNot(boolean passthrough) {
getAppVersionCode(context, ANDROMEDA_PACKAGE) > 19
? "activities.InfoActivity" : "InfoActivity"));
andromedaOfflineButton.setVisibility(View.VISIBLE);
andromedaOfflineButton.setOnClickListener(v ->
activity.progressDialog.cancel());
andromedaOfflineButton.setOnClickListener(v -> activity.progressDialog.cancel());
if (BuildConfig.DEBUG) {
andromedaDebugText.setVisibility(View.VISIBLE);
}
Expand All @@ -1143,14 +1139,10 @@ private void showDialogOrNot(boolean passthrough) {
textView.setVisibility(View.GONE);
titleView.setVisibility(View.GONE);
instanceBasedAndromedaFailure = true;
activity.menuView.
findViewById(R.id.tab_themes).setVisibility(View.GONE);
activity.menuView.
findViewById(R.id.tab_priorities).setVisibility(View.GONE);
activity.menuView.
findViewById(R.id.tab_profiles).setVisibility(View.GONE);
activity.bottomBar.
setSelectedItemId(R.id.tab_overlay_manager);
activity.bottomBar.getMenu().removeItem(R.id.tab_themes);
activity.bottomBar.getMenu().removeItem(R.id.tab_priorities);
activity.bottomBar.getMenu().removeItem(R.id.tab_profiles);
activity.bottomBar.setSelectedItemId(R.id.tab_overlay_manager);
} else if (Systems.IS_OREO &&
!Packages.isPackageInstalled(context, ANDROMEDA_PACKAGE)) {
TextView andromedaTitle = activity.progressDialog.findViewById(
Expand All @@ -1159,8 +1151,7 @@ private void showDialogOrNot(boolean passthrough) {
Button andromedaButton = activity.progressDialog.findViewById(
R.id.andromeda_button);
andromedaButton.setVisibility(View.VISIBLE);
andromedaButton.setOnClickListener(view ->
launchActivityUrl(context, R.string.andromeda_url));
andromedaButton.setOnClickListener(view -> launchActivityUrl(context, R.string.andromeda_url));
textView.setVisibility(View.GONE);
titleView.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ protected Void doInBackground(Void... voids) {
if (isAndromedaDevice(context)) {
int andromedaVer = Packages.getAppVersionCode(context, ANDROMEDA_PACKAGE);
FirebaseAnalytics.withdrawAndromedaFingerprint(context, andromedaVer);
SharedPreferences prefs2 =
context.getSharedPreferences("substratum_state", Context.MODE_PRIVATE);
SharedPreferences prefs2 = context.getSharedPreferences("substratum_state", Context.MODE_PRIVATE);
timeoutCount = 0;
while (!prefs2.contains("andromeda_exp_fp_" + andromedaVer) &&
(timeoutCount < 100)) {
Expand Down Expand Up @@ -199,8 +198,7 @@ protected Void doInBackground(Void... voids) {
Packages.isPackageInstalled(context, SST_ADDON_PACKAGE)) {
int sstVersion = Packages.getAppVersionCode(context, SST_ADDON_PACKAGE);
FirebaseAnalytics.withdrawSungstratumFingerprint(context, sstVersion);
SharedPreferences prefs2 =
context.getSharedPreferences("substratum_state", Context.MODE_PRIVATE);
SharedPreferences prefs2 = context.getSharedPreferences("substratum_state", Context.MODE_PRIVATE);
timeoutCount = 0;
while (!prefs2.contains("sungstratum_exp_fp_" + sstVersion) && (timeoutCount <
100)) {
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/java/projekt/substratum/common/Activities.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void launchActivityUrl(Context context,
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(context.getString(resource)));
context.startActivity(i);
} catch (ActivityNotFoundException activityNotFoundException) {
} catch (ActivityNotFoundException ignored) {
Toast.makeText(context,
context.getString(R.string.activity_missing_toast),
Toast.LENGTH_SHORT).show();
Expand All @@ -46,10 +46,16 @@ public static void launchActivityUrl(Context context,
public static void launchExternalActivity(Context context,
String packageName,
String className) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, packageName + '.' + className));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, packageName + '.' + className));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (ActivityNotFoundException ignored) {
Toast.makeText(context,
context.getString(R.string.activity_missing_toast),
Toast.LENGTH_SHORT).show();
}
}

/**
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/java/projekt/substratum/common/References.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import projekt.substratum.common.analytics.FirebaseAnalytics;
import projekt.substratum.services.profiles.ScheduledProfileReceiver;
import projekt.substratum.util.helpers.BinaryInstaller;
import projekt.substratum.util.helpers.Root;
import projekt.substratum.util.helpers.TranslatorParser;

import java.io.BufferedReader;
Expand Down Expand Up @@ -192,7 +193,9 @@ public class References {
public static final String DATA_RESOURCE_DIR = "/data/resource-cache/";
public static final String PIXEL_NEXUS_DIR = "/system/overlay/";
public static final String LEGACY_NEXUS_DIR = "/system/vendor/overlay/";
public static final String P_DIR = "/system/app/";
private static final String P_SYSTEM_DIR = "/system/app/";
public static final String MAGISK_MIRROR_MOUNT_POINT = "/sbin/.core/mirror/system";
private static final String P_MAGISK_DIR = MAGISK_MIRROR_MOUNT_POINT + "/app/";
public static final String VENDOR_DIR = "/vendor/overlay/";
// Notification Channel
public static final String DEFAULT_NOTIFICATION_CHANNEL_ID = "default";
Expand Down Expand Up @@ -252,6 +255,26 @@ public class References {
// boolean simply takes on the value false.
private static Boolean uncertified;
private static int hashValue;
private static String pieDir = null;
private static Boolean isMagisk = null;

public static String getPieDir() {
if (pieDir == null) {
boolean isMagisk = Root.runCommand(String.format("test -d %s && echo '0'", MAGISK_MIRROR_MOUNT_POINT)).equals("0");
if (isMagisk)
pieDir = P_MAGISK_DIR;
else
pieDir = P_SYSTEM_DIR;
}
return pieDir;
}

public static Boolean isMagisk() {
if (isMagisk == null) {
isMagisk = getPieDir().equals(P_MAGISK_DIR);
}
return isMagisk;
}

/**
* Unified method to set theme extra lists
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/projekt/substratum/common/Systems.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public class Systems {
public static final boolean IS_NOUGAT = Build.VERSION.SDK_INT == Build.VERSION_CODES.N ||
Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1;

static Boolean checkPackageSupported;
static SharedPreferences prefs = Substratum.getPreferences();
private static Boolean checkPackageSupported;
private static SharedPreferences prefs = Substratum.getPreferences();
/**
* Cached boolean to find if system
* passes all cases of Samsung checks
Expand Down Expand Up @@ -213,7 +213,7 @@ public static void setAndCheckOMS(Context context) {
if (checkThemeInterfacer(context) || checkSubstratumService(context)) {
foundOms = true;
} else if (sonyCheck == null || sonyCheck.length() == 0) {
Boolean isOMSRunning = isServiceRunning(IOverlayManager.class,
boolean isOMSRunning = isServiceRunning(IOverlayManager.class,
context.getApplicationContext());
if (isOMSRunning || IS_OREO || IS_PIE) {
Substratum.log(SUBSTRATUM_LOG,
Expand Down Expand Up @@ -269,7 +269,7 @@ public static boolean checkThemeInterfacer(Context context) {
*/
public static void setAndCheckSubstratumService() {
StringBuilder check = References.runShellCommand("cmd -l");
Boolean present = check != null && check.toString().contains("substratum");
boolean present = check != null && check.toString().contains("substratum");
prefs.edit().putBoolean("substratum_service_present", false).apply();
if (present) {
prefs.edit().putBoolean("substratum_service_present", true).apply();
Expand Down Expand Up @@ -613,8 +613,8 @@ public static boolean checkPackageSupport(Context context, Boolean override) {
* @param stringArray List of packages to check
* @return True if blacklisted packages found
*/
public static Boolean checkPackageRegex(Context context,
String[] stringArray) {
static Boolean checkPackageRegex(Context context,
String[] stringArray) {
if (stringArray.length == 0) return true;
final PackageManager pm = context.getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
Expand Down Expand Up @@ -654,7 +654,7 @@ public static String checkFirmwareSupport(

Map<String, String> listOfRoms =
ReadSupportedROMsFile.read(context.getCacheDir() + "/" + fileName);
Boolean supported = false;
boolean supported = false;

// First check if it is a valid prop
for (Object o : listOfRoms.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import androidx.annotation.RestrictTo;
import org.apache.commons.io.FileUtils;
import projekt.substratum.Substratum;
import projekt.substratum.common.References;
import projekt.substratum.common.platform.SubstratumService;
import projekt.substratum.common.platform.ThemeInterfacerService;
import projekt.substratum.util.helpers.Root;
Expand Down Expand Up @@ -125,42 +126,42 @@ private static String checkBox(final String mountType) {
* Mount system RW
*/
public static void mountRW() {
Root.runCommand("mount -o " + checkBox("rw") + " /system");
Root.runCommand(String.format("mount -t auto -o %s %s", checkBox("rw"), References.isMagisk() ? References.MAGISK_MIRROR_MOUNT_POINT : "/system"));
}

/**
* Mount data RW
*/
public static void mountRWData() {
Root.runCommand("mount -o " + checkBox("rw") + " /data");
Root.runCommand("mount -t auto -o " + checkBox("rw") + " /data");
}

/**
* Mount vendor RW
*/
public static void mountRWVendor() {
Root.runCommand("mount -o " + checkBox("rw") + " /vendor");
Root.runCommand("mount -t auto -o " + checkBox("rw") + " /vendor");
}

/**
* Mount system RO
*/
public static void mountRO() {
Root.runCommand("mount -o " + checkBox("ro") + " /system");
Root.runCommand(String.format("mount -t auto -o %s %s", checkBox("ro"), References.isMagisk() ? References.MAGISK_MIRROR_MOUNT_POINT : "/system"));
}

/**
* Mount data RO
*/
public static void mountROData() {
Root.runCommand("mount -o " + checkBox("ro") + " /data");
Root.runCommand("mount -t auto -o " + checkBox("ro") + " /data");
}

/**
* Mount vendor RO
*/
public static void mountROVendor() {
Root.runCommand("mount -o " + checkBox("ro") + " /vendor");
Root.runCommand("mount -t auto -o " + checkBox("ro") + " /vendor");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import static projekt.substratum.common.References.EXTERNAL_STORAGE_SAMSUNG_OVERLAY_CACHE;
import static projekt.substratum.common.References.INTERFACER_PACKAGE;
import static projekt.substratum.common.References.LEGACY_NEXUS_DIR;
import static projekt.substratum.common.References.P_DIR;
import static projekt.substratum.common.Resources.FRAMEWORK;
import static projekt.substratum.common.Resources.PIXEL_OVERLAY_PACKAGES;
import static projekt.substratum.common.Resources.SETTINGS;
Expand Down Expand Up @@ -729,7 +728,7 @@ public static void uninstallOverlay(Context context,
if (Systems.IS_PIE && !checkSubstratumService(context)) {
FileOperations.mountRW();
for (String overlay : overlays) {
FileOperations.bruteforceDelete(P_DIR + '_' + overlay + ".apk");
FileOperations.bruteforceDelete(References.getPieDir() + '_' + overlay + ".apk");
}
FileOperations.mountRO();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ public void onCreatePreferences(
boolean isEnabled = (boolean) newValue;
autoDisableTargetOverlays.setVisible(!isEnabled);
prefs.edit().putBoolean("auto_disable_target_overlays", !isEnabled).apply();
prefs.edit().putBoolean("sungstromeda_mode",
isEnabled).apply();
prefs.edit().putBoolean("sungstromeda_mode", isEnabled).apply();
sungstromedaMode.setChecked((Boolean) newValue);
new Handler().postDelayed(() ->
Substratum.restartSubstratum(context), 1000L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ public void onReceive(Context context, Intent intent) {
Substratum.log("AppCrashReciever", String.format("Disabling overlay %s for package " +
"%s", overlay, packageName));
}

AppCrashReceiver.postNotificationAndDisableOverlays(context,
postNotificationAndDisableOverlays(context,
AppCrashReceiver.getApplicationLabel(context, packageName),
overlays);

}
} else if (SYSTEMUI.equals(packageName)) {
if (ThemeManager.listEnabledOverlaysForTarget(context, SYSTEMUI).isEmpty()) return;
Expand All @@ -106,7 +104,7 @@ public void onReceive(Context context, Intent intent) {
case 2:
Substratum.log("AppCrashReceiver", "Disabling all SystemUI overlays now.");
sharedPreferences.edit().remove("sysui_crash_count").apply();
AppCrashReceiver.postNotificationAndDisableOverlays(context,
postNotificationAndDisableOverlays(context,
AppCrashReceiver.getApplicationLabel(context, packageName),
ThemeManager.listEnabledOverlaysForTarget(context, SYSTEMUI));
break;
Expand Down
Loading

0 comments on commit 050ef24

Please sign in to comment.