(misc) small fixes and updates

Signed-off-by: androidacy-user <opensource@androidacy.com>
master
androidacy-user 1 year ago
parent 788589c315
commit 647f53231e

@ -28,6 +28,7 @@ android {
val gitRemote = providers.exec {
commandLine("git", "config", "--get", "remote.origin.url")
}.standardOutput.asText.get().toString().trim()
val timestamp = System.currentTimeMillis()
namespace = "com.fox2code.mmm"
compileSdk = 33
@ -95,6 +96,8 @@ android {
productFlavors {
create("default") {
dimension = "type"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false")
// Latest commit hash as BuildConfig.COMMIT_HASH
@ -156,6 +159,8 @@ android {
create("play") {
dimension = "type"
applicationIdSuffix = ".play"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false")
// Latest commit hash as BuildConfig.COMMIT_HASH
@ -216,6 +221,8 @@ android {
create("fdroid") {
dimension = "type"
applicationIdSuffix = ".fdroid"
// current timestamp of build
buildConfigField("long", "BUILD_TIME", "$timestamp")
// debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false")
@ -308,6 +315,7 @@ sentry {
setOf(
InstrumentationFeature.DATABASE,
InstrumentationFeature.FILE_IO,
InstrumentationFeature.OKHTTP,
InstrumentationFeature.COMPOSE
)
)

@ -57,6 +57,7 @@ import com.google.android.material.snackbar.Snackbar;
import org.matomo.sdk.extra.TrackHelper;
import java.sql.Timestamp;
import java.util.Objects;
import io.realm.Realm;
@ -120,12 +121,21 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
}
TrackHelper.track().event("enabled_repos", enabledRepos.toString()).with(MainApplication.getINSTANCE().getTracker());
realm.close();
// log all shared preferences that are present
if (!Iof) {
// hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
if (BuildConfig.ENABLE_PROTECTION && !Iof && !BuildConfig.DEBUG) {
throw new RuntimeException("This is not an official build of FoxMMM");
} else if (!Iof && !BuildConfig.DEBUG) {
Timber.w("You may be running an untrusted build.");
// Show a toast to warn the user
Toast.makeText(this, R.string.not_official_build, Toast.LENGTH_LONG).show();
}
Timestamp ts = new Timestamp(System.currentTimeMillis() - (30L * 24 * 60 * 60 * 1000));
// check if this build has expired
Timestamp buildTime = new Timestamp(BuildConfig.BUILD_TIME);
// if the build time is more than 30 days ago, throw an exception
if (ts.getTime() < buildTime.getTime()) {
throw new IllegalStateException("This build has expired. Please download a stable build or update to the latest version.");
}
setContentView(R.layout.activity_main);
this.setTitle(R.string.app_name);
// set window flags to ignore status bar

@ -422,10 +422,6 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
Iof = Arrays.asList(osh).contains(oosh);
} catch (PackageManager.NameNotFoundException ignored) {
}
// hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
if (BuildConfig.ENABLE_PROTECTION && !Iof && !BuildConfig.DEBUG) {
throw new RuntimeException("This is not an official build of FoxMMM");
}
SharedPreferences sharedPreferences = MainApplication.getPreferences("mmm");
// We are only one process so it's ok to do this
SharedPreferences bootPrefs = MainApplication.getPreferences("mmm_boot");

@ -138,7 +138,9 @@ public class InstallerInitializer extends Shell.Initializer {
@Override
public boolean onInit(@NonNull Context context, @NonNull Shell shell) {
if (!shell.isRoot()) {
// open a new shell
shell.newJob().add("id").exec().getOut();
if (!Boolean.TRUE.equals(Shell.isAppGrantedRoot())) {
Timber.w("No root access!");
return false;
}

Loading…
Cancel
Save