Remove unused Android MainActivity and Application copies (#3849)
What changed, and why it matters
This commit deletes four leftover Android Java files that were no longer used. The app's namespace was already fixed to 'com.cakewallet.cake_wallet', so these old copies of the main activity and application class under different package names were dead code. Removing them does not change how the app behaves or introduce any security issue.
No security action needed. Treat as routine code cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change removes duplicate/unused Flutter Application and MainActivity classes under com.cakewallet.haven and com.monero.app. Because the Android namespace is fixed to com.cakewallet.cake_wallet, the real entry points are the remaining classes in that package. The deleted files contained identical or near-identical native-channel handling code (SecureRandom, battery optimization, FLAG_SECURE), but they were not referenced by the manifest and therefore not executable. The patch is purely cleanup.
Changed components
android/app/src/main/java/com/cakewallet/haven/Application.javaandroid/app/src/main/java/com/cakewallet/haven/MainActivity.javaandroid/app/src/main/java/com/monero/app/Application.javaandroid/app/src/main/java/com/monero/app/MainActivity.javaInspect captured patch +0 / −187
### android/app/src/main/java/com/cakewallet/haven/Application.java
@@ -1,6 +0,0 @@
-package com.cakewallet.haven;
-
-import io.flutter.app.FlutterApplication;
-
-public class Application extends FlutterApplication {
-}
### android/app/src/main/java/com/cakewallet/haven/MainActivity.java
@@ -1,83 +0,0 @@
-package com.cakewallet.haven;
-
-import androidx.annotation.NonNull;
-
-import io.flutter.embedding.android.FlutterFragmentActivity;
-import io.flutter.embedding.engine.FlutterEngine;
-import io.flutter.plugins.GeneratedPluginRegistrant;
-
-import io.flutter.plugin.common.MethodCall;
-import io.flutter.plugin.common.MethodChannel;
-
-import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.WindowManager;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.PowerManager;
-import android.provider.Settings;
-
-import java.security.SecureRandom;
-
-public class MainActivity extends FlutterFragmentActivity {
- final String UTILS_CHANNEL = "com.cake_wallet/native_utils";
-
- @Override
- public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
- GeneratedPluginRegistrant.registerWith(flutterEngine);
-
- MethodChannel utilsChannel =
- new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(),
- UTILS_CHANNEL);
-
- utilsChannel.setMethodCallHandler(this::handle);
- }
-
- private void handle(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
- Handler handler = new Handler(Looper.getMainLooper());
-
- try {
- switch (call.method) {
- case "sec_random":
- int count = call.argument("count");
- SecureRandom random = new SecureRandom();
- byte bytes[] = new byte[count];
- random.nextBytes(bytes);
- handler.post(() -> result.success(bytes));
- break;
- case "disableBatteryOptimization":
- disableBatteryOptimization();
- handler.post(() -> result.success(null));
- break;
- case "isBatteryOptimizationDisabled":
- boolean isDisabled = isBatteryOptimizationDisabled();
- handler.post(() -> result.success(isDisabled));
- break;
- default:
- handler.post(() -> result.notImplemented());
- }
- } catch (Exception e) {
- handler.post(() -> result.error("UNCAUGHT_ERROR", e.getMessage(), null));
- }
- }
-
- private void disableBatteryOptimization() {
- String packageName = getPackageName();
- PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
- if (!pm.isIgnoringBatteryOptimizations(packageName)) {
- Intent intent = new Intent();
- intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
- intent.setData(Uri.parse("package:" + packageName));
- startActivity(intent);
- }
- }
-
- private boolean isBatteryOptimizationDisabled() {
- String packageName = getPackageName();
- PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
- return pm.isIgnoringBatteryOptimizations(packageName);
- }
-
-}
\ No newline at end of file
### android/app/src/main/java/com/monero/app/Application.java
@@ -1,6 +0,0 @@
-package com.monero.app;
-
-import io.flutter.app.FlutterApplication;
-
-public class Application extends FlutterApplication {
-}
### android/app/src/main/java/com/monero/app/MainActivity.java
@@ -1,92 +0,0 @@
-package com.monero.app;
-
-import androidx.annotation.NonNull;
-
-import io.flutter.embedding.android.FlutterFragmentActivity;
-import io.flutter.embedding.engine.FlutterEngine;
-import io.flutter.plugins.GeneratedPluginRegistrant;
-
-import io.flutter.plugin.common.MethodCall;
-import io.flutter.plugin.common.MethodChannel;
-
-import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.WindowManager;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.PowerManager;
-import android.provider.Settings;
-
-import java.security.SecureRandom;
-
-public class MainActivity extends FlutterFragmentActivity {
- final String UTILS_CHANNEL = "com.cake_wallet/native_utils";
- boolean isAppSecure = false;
-
- @Override
- public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
- GeneratedPluginRegistrant.registerWith(flutterEngine);
-
- MethodChannel utilsChannel =
- new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(),
- UTILS_CHANNEL);
-
- utilsChannel.setMethodCallHandler(this::handle);
- }
-
- private void handle(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
- Handler handler = new Handler(Looper.getMainLooper());
-
- try {
- switch (call.method) {
- case "sec_random":
- int count = call.argument("count");
- SecureRandom random = new SecureRandom();
- byte bytes[] = new byte[count];
- random.nextBytes(bytes);
- handler.post(() -> result.success(bytes));
- break;
- case "setIsAppSecure":
- isAppSecure = call.argument("isAppSecure");
- if (isAppSecure) {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
- } else {
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
- }
- break;
- case "disableBatteryOptimization":
- disableBatteryOptimization();
- handler.post(() -> result.success(null));
- break;
- case "isBatteryOptimizationDisabled":
- boolean isDisabled = isBatteryOptimizationDisabled();
- handler.post(() -> result.success(isDisabled));
- break;
- default:
- handler.post(() -> result.notImplemented());
- }
- } catch (Exception e) {
- handler.post(() -> result.error("UNCAUGHT_ERROR", e.getMessage(), null));
- }
- }
-
- private void disableBatteryOptimization() {
- String packageName = getPackageName();
- PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
- if (!pm.isIgnoringBatteryOptimizations(packageName)) {
- Intent intent = new Intent();
- intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
- intent.setData(Uri.parse("package:" + packageName));
- startActivity(intent);
- }
- }
-
- private boolean isBatteryOptimizationDisabled() {
- String packageName = getPackageName();
- PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
- return pm.isIgnoringBatteryOptimizations(packageName);
- }
-
-}
\ No newline at end of fileWhy this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.