diff --git a/app/src/main/java/com/xypower/mpapp/BootBroadcastReceiver.java b/app/src/main/java/com/xypower/mpapp/BootBroadcastReceiver.java
index dfbd4448..4b6d56d3 100644
--- a/app/src/main/java/com/xypower/mpapp/BootBroadcastReceiver.java
+++ b/app/src/main/java/com/xypower/mpapp/BootBroadcastReceiver.java
@@ -1,5 +1,6 @@
package com.xypower.mpapp;
+import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -9,14 +10,16 @@ import com.xypower.common.MicroPhotoContext;
public class BootBroadcastReceiver extends BroadcastReceiver {
private static final String ACTION = "android.intent.action.BOOT_COMPLETED";
+ private static final String TAG = "MPLOG";
@Override
public void onReceive(Context context, Intent intent) {
- Log.i("BootBroadcastReceiver", intent.getAction());
+ Log.i(TAG, intent.getAction());
if (ACTION.equals(intent.getAction())) {
+ Log.i(TAG, "Start MainActivity");
/*
Intent mainIntent = new Intent(context, MainActivity.class);
@@ -28,12 +31,13 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
+
+
*/
+ // MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getAppConfig(context);
- MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getAppConfig(context);
+ // MainActivity.startMicroPhotoService(context, appConfig, null);
- MainActivity.startMicroPhotoService(context, appConfig, null);
- /*
Intent mainIntent = new Intent(context, MainActivity.class);
mainIntent.putExtra("reboot", 1);
//Intent.FLAG_ACTIVITY_NEW_TASK
@@ -41,7 +45,6 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mainIntent);
- */
}
}
}
diff --git a/app/src/main/java/com/xypower/mpapp/MainActivity.java b/app/src/main/java/com/xypower/mpapp/MainActivity.java
index 63dfd0e3..e86e3412 100644
--- a/app/src/main/java/com/xypower/mpapp/MainActivity.java
+++ b/app/src/main/java/com/xypower/mpapp/MainActivity.java
@@ -46,7 +46,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class MainActivity extends AppCompatActivity {
- public static final String TAG = "MainActivity";
+ public static final String TAG = "MPLOG";
private static int MY_PERMISSIONS_REQUEST_FOREGROUND_SERVICE = 100;
public static final int MSG_WHAT_LOG_OBSERVER = MicroPhotoService.MSG_WHAT_MAX + 10;
@@ -215,6 +215,7 @@ public class MainActivity extends AppCompatActivity {
int rebootFlag = intent.getIntExtra("reboot", 0);
if (rebootFlag == 1) {
// SysApi.enableAirPlane(MainActivity.this, true);
+ Log.i(TAG, "After Reboot");
}
Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay);
diff --git a/app/src/main/java/com/xypower/mpapp/ScreenActionReceiver.java b/app/src/main/java/com/xypower/mpapp/ScreenActionReceiver.java
index ccbf6334..e563744d 100644
--- a/app/src/main/java/com/xypower/mpapp/ScreenActionReceiver.java
+++ b/app/src/main/java/com/xypower/mpapp/ScreenActionReceiver.java
@@ -24,49 +24,44 @@ public class ScreenActionReceiver extends BroadcastReceiver {
Toast.makeText(context, log, Toast.LENGTH_SHORT).show();
String action = intent.getAction();
+ try {
- if(Intent.ACTION_SCREEN_ON.equals(action))
- {
- Log.d(TAG, "screen is on...");
- Toast.makeText(context,"screen ON",Toast.LENGTH_SHORT);
+ if (Intent.ACTION_SCREEN_ON.equals(action)) {
+ Log.d(TAG, "screen is on...");
+ Toast.makeText(context, "screen ON", Toast.LENGTH_SHORT);
- //Run the locker
+ //Run the locker
- context.startService(new Intent(context, FloatingWindow.class));
- }
-
- else if(Intent.ACTION_SCREEN_OFF.equals(action))
- {
- Log.d(TAG, "screen is off...");
- Toast.makeText(context,"screen OFF",Toast.LENGTH_SHORT);
-
- }
-
- else if(Intent.ACTION_USER_PRESENT.equals(action))
- {
- Log.d(TAG, "screen is unlock...");
- Toast.makeText(context,"screen UNLOCK",Toast.LENGTH_SHORT);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- context.startForegroundService(new Intent(context, FloatingWindow.class));
- } else {
context.startService(new Intent(context, FloatingWindow.class));
- }
-
- }
-
- else if(Intent.ACTION_BOOT_COMPLETED.equals(action)){
- Log.d(TAG, "boot completed...");
- Toast.makeText(context,"BOOTED..",Toast.LENGTH_SHORT);
- //Run the locker
+ } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
+ Log.d(TAG, "screen is off...");
+ Toast.makeText(context, "screen OFF", Toast.LENGTH_SHORT);
+
+ } else if (Intent.ACTION_USER_PRESENT.equals(action)) {
+ Log.d(TAG, "screen is unlock...");
+ Toast.makeText(context, "screen UNLOCK", Toast.LENGTH_SHORT);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ context.startForegroundService(new Intent(context, FloatingWindow.class));
+ } else {
+ context.startService(new Intent(context, FloatingWindow.class));
+ }
+
+ } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
+ Log.d(TAG, "boot completed...");
+ Toast.makeText(context, "BOOTED..", Toast.LENGTH_SHORT);
+ //Run the locker
/* Intent i = new Intent(context, FloatingWindow.class);
context.startService(i);
*/
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- context.startForegroundService(new Intent(context, FloatingWindow.class));
- } else {
- context.startService(new Intent(context, FloatingWindow.class));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ // context.startForegroundService(new Intent(context, FloatingWindow.class));
+ } else {
+ // context.startService(new Intent(context, FloatingWindow.class));
+ }
}
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
diff --git a/mpmaster/src/main/AndroidManifest.xml b/mpmaster/src/main/AndroidManifest.xml
index 2e0fbb11..a4819bbe 100644
--- a/mpmaster/src/main/AndroidManifest.xml
+++ b/mpmaster/src/main/AndroidManifest.xml
@@ -109,6 +109,18 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/BootBroadcastReceiver.java b/mpmaster/src/main/java/com/xypower/mpmaster/BootBroadcastReceiver.java
new file mode 100644
index 00000000..92388256
--- /dev/null
+++ b/mpmaster/src/main/java/com/xypower/mpmaster/BootBroadcastReceiver.java
@@ -0,0 +1,47 @@
+package com.xypower.mpmaster;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class BootBroadcastReceiver extends BroadcastReceiver {
+ private static final String ACTION = "android.intent.action.BOOT_COMPLETED";
+ private static final String TAG = "MPMasterLOG";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ Log.i(TAG, intent.getAction());
+
+ if (ACTION.equals(intent.getAction())) {
+
+ Log.i(TAG, "Start MainActivity");
+
+ /*
+ Intent mainIntent = new Intent(context, MainActivity.class);
+ mainIntent.putExtra("reboot", 1);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+ try {
+ pendingIntent.send();
+ } catch (PendingIntent.CanceledException e) {
+ e.printStackTrace();
+ }
+
+
+ */
+ // MicroPhotoContext.AppConfig appConfig = MicroPhotoContext.getAppConfig(context);
+
+ // MainActivity.startMicroPhotoService(context, appConfig, null);
+
+ Intent mainIntent = new Intent(context, MainActivity.class);
+ mainIntent.putExtra("reboot", 1);
+ //Intent.FLAG_ACTIVITY_NEW_TASK
+ // Intent.FLAG_ACTIVITY_CLEAR_TOP
+ mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(mainIntent);
+
+ }
+ }
+}