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

@ -57,6 +57,7 @@ import com.google.android.material.snackbar.Snackbar;
import org.matomo.sdk.extra.TrackHelper; import org.matomo.sdk.extra.TrackHelper;
import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
import io.realm.Realm; 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()); TrackHelper.track().event("enabled_repos", enabledRepos.toString()).with(MainApplication.getINSTANCE().getTracker());
realm.close(); realm.close();
// log all shared preferences that are present // hide this behind a buildconfig flag for now, but crash the app if it's not an official build and not debug
if (!Iof) { 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."); Timber.w("You may be running an untrusted build.");
// Show a toast to warn the user // Show a toast to warn the user
Toast.makeText(this, R.string.not_official_build, Toast.LENGTH_LONG).show(); 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); setContentView(R.layout.activity_main);
this.setTitle(R.string.app_name); this.setTitle(R.string.app_name);
// set window flags to ignore status bar // 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); Iof = Arrays.asList(osh).contains(oosh);
} catch (PackageManager.NameNotFoundException ignored) { } 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"); SharedPreferences sharedPreferences = MainApplication.getPreferences("mmm");
// We are only one process so it's ok to do this // We are only one process so it's ok to do this
SharedPreferences bootPrefs = MainApplication.getPreferences("mmm_boot"); SharedPreferences bootPrefs = MainApplication.getPreferences("mmm_boot");

@ -138,7 +138,9 @@ public class InstallerInitializer extends Shell.Initializer {
@Override @Override
public boolean onInit(@NonNull Context context, @NonNull Shell shell) { 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!"); Timber.w("No root access!");
return false; return false;
} }

Loading…
Cancel
Save