├── .gradle └── 2.8 │ └── taskArtifacts │ ├── cache.properties │ ├── cache.properties.lock │ ├── fileHashes.bin │ ├── fileSnapshots.bin │ ├── outputFileStates.bin │ └── taskArtifacts.bin ├── .idea └── vcs.xml ├── DemoMarsdaemon ├── .gitignore ├── DemoMarsdaemon.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── marswin89 │ │ └── marsdaemon │ │ └── demo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── marswin89 │ │ │ └── marsdaemon │ │ │ └── demo │ │ │ ├── MainActivity.java │ │ │ ├── MyApplication1.java │ │ │ ├── MyApplication2.java │ │ │ ├── Receiver1.java │ │ │ ├── Receiver2.java │ │ │ ├── Service1.java │ │ │ └── Service2.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── marswin89 │ └── marsdaemon │ └── demo │ └── ExampleUnitTest.java ├── LICENSE ├── LibMarsdaemon ├── .gitignore ├── LibMarsdaemon.iml ├── build.gradle ├── jni │ ├── Android.mk │ ├── Application.mk │ ├── com_marswin89_marsdaemon_nativ_NativeDaemonAPI20.h │ ├── com_marswin89_marsdaemon_nativ_NativeDaemonAPI21.h │ ├── common.c │ ├── constant.h │ ├── daemon.c │ ├── daemon_api20.c │ ├── daemon_api21.c │ └── log.h ├── libs │ ├── armeabi-v7a │ │ ├── libdaemon_api20.so │ │ └── libdaemon_api21.so │ ├── armeabi │ │ ├── libdaemon_api20.so │ │ └── libdaemon_api21.so │ └── x86 │ │ ├── libdaemon_api20.so │ │ └── libdaemon_api21.so ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── armeabi-v7a │ │ │ └── daemon │ │ ├── armeabi │ │ │ └── daemon │ │ └── x86 │ │ │ └── daemon │ ├── java │ │ └── com │ │ │ └── marswin89 │ │ │ └── marsdaemon │ │ │ ├── DaemonApplication.java │ │ │ ├── DaemonClient.java │ │ │ ├── DaemonConfigurations.java │ │ │ ├── IDaemonClient.java │ │ │ ├── IDaemonStrategy.java │ │ │ ├── NativeDaemonBase.java │ │ │ ├── PackageUtils.java │ │ │ ├── nativ │ │ │ ├── NativeDaemonAPI20.java │ │ │ └── NativeDaemonAPI21.java │ │ │ └── strategy │ │ │ ├── DaemonStrategy21.java │ │ │ ├── DaemonStrategy22.java │ │ │ ├── DaemonStrategy23.java │ │ │ ├── DaemonStrategyUnder21.java │ │ │ └── DaemonStrategyXiaomi.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── marswin89 │ └── marsdaemon │ └── ExampleUnitTest.java ├── Marsdaemon2.iml ├── README.md ├── build.gradle ├── build └── intermediates │ └── dex-cache │ └── cache.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle /.gradle/2.8/taskArtifacts/cache.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 24 18:13:42 CST 2015 2 | -------------------------------------------------------------------------------- /.gradle/2.8/taskArtifacts/cache.properties.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/.gradle/2.8/taskArtifacts/cache.properties.lock -------------------------------------------------------------------------------- /.gradle/2.8/taskArtifacts/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/.gradle/2.8/taskArtifacts/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/2.8/taskArtifacts/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/.gradle/2.8/taskArtifacts/fileSnapshots.bin -------------------------------------------------------------------------------- /.gradle/2.8/taskArtifacts/outputFileStates.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/.gradle/2.8/taskArtifacts/outputFileStates.bin -------------------------------------------------------------------------------- /.gradle/2.8/taskArtifacts/taskArtifacts.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/.gradle/2.8/taskArtifacts/taskArtifacts.bin -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DemoMarsdaemon/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /DemoMarsdaemon/DemoMarsdaemon.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /DemoMarsdaemon/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.marswin89.marsdaemon.demo" 9 | minSdkVersion 10 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | } 15 | 16 | dependencies { 17 | compile fileTree(dir: 'libs', include: ['*.jar']) 18 | testCompile 'junit:junit:4.12' 19 | compile 'com.android.support:appcompat-v7:23.1.1' 20 | compile 'com.android.support:design:23.1.1' 21 | compile project(':LibMarsdaemon') 22 | } 23 | -------------------------------------------------------------------------------- /DemoMarsdaemon/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/guoyang/Developer/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/androidTest/java/com/marswin89/marsdaemon/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | /** 8 | * 9 | * Created by Mars on 12/24/15. 10 | */ 11 | public class MainActivity extends Activity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | //you have to start the service once. 19 | startService(new Intent(MainActivity.this, Service1.class)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/MyApplication1.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.content.Context; 4 | 5 | import com.marswin89.marsdaemon.DaemonApplication; 6 | import com.marswin89.marsdaemon.DaemonConfigurations; 7 | 8 | /** 9 | * Implementation 1
10 | * override one method is ok.
11 | * 12 | * Created by Mars on 12/24/15. 13 | */ 14 | public class MyApplication1 extends DaemonApplication { 15 | 16 | /** 17 | * you can override this method instead of {@link android.app.Application attachBaseContext} 18 | * @param base 19 | */ 20 | @Override 21 | public void attachBaseContextByDaemon(Context base) { 22 | super.attachBaseContextByDaemon(base); 23 | } 24 | 25 | 26 | /** 27 | * give the configuration to lib in this callback 28 | * @return 29 | */ 30 | @Override 31 | protected DaemonConfigurations getDaemonConfigurations() { 32 | DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration( 33 | "com.marswin89.marsdaemon.demo:process1", 34 | Service1.class.getCanonicalName(), 35 | Receiver1.class.getCanonicalName()); 36 | 37 | DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration( 38 | "com.marswin89.marsdaemon.demo:process2", 39 | Service2.class.getCanonicalName(), 40 | Receiver2.class.getCanonicalName()); 41 | 42 | DaemonConfigurations.DaemonListener listener = new MyDaemonListener(); 43 | //return new DaemonConfigurations(configuration1, configuration2);//listener can be null 44 | return new DaemonConfigurations(configuration1, configuration2, listener); 45 | } 46 | 47 | 48 | class MyDaemonListener implements DaemonConfigurations.DaemonListener{ 49 | @Override 50 | public void onPersistentStart(Context context) { 51 | } 52 | 53 | @Override 54 | public void onDaemonAssistantStart(Context context) { 55 | } 56 | 57 | @Override 58 | public void onWatchDaemonDaed() { 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/MyApplication2.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.marswin89.marsdaemon.DaemonApplication; 7 | import com.marswin89.marsdaemon.DaemonClient; 8 | import com.marswin89.marsdaemon.DaemonConfigurations; 9 | 10 | /** 11 | * Implementation 2
12 | * if you have to extends other Application, use this method.
13 | * 14 | * Created by Mars on 12/24/15. 15 | */ 16 | public class MyApplication2 extends Application { 17 | 18 | private DaemonClient mDaemonClient; 19 | 20 | @Override 21 | protected void attachBaseContext(Context base) { 22 | super.attachBaseContext(base); 23 | mDaemonClient = new DaemonClient(createDaemonConfigurations()); 24 | mDaemonClient.onAttachBaseContext(base); 25 | } 26 | 27 | 28 | 29 | private DaemonConfigurations createDaemonConfigurations(){ 30 | DaemonConfigurations.DaemonConfiguration configuration1 = new DaemonConfigurations.DaemonConfiguration( 31 | "com.marswin89.marsdaemon.demo:process1", 32 | Service1.class.getCanonicalName(), 33 | Receiver1.class.getCanonicalName()); 34 | DaemonConfigurations.DaemonConfiguration configuration2 = new DaemonConfigurations.DaemonConfiguration( 35 | "com.marswin89.marsdaemon.demo:process2", 36 | Service2.class.getCanonicalName(), 37 | Receiver2.class.getCanonicalName()); 38 | DaemonConfigurations.DaemonListener listener = new MyDaemonListener(); 39 | //return new DaemonConfigurations(configuration1, configuration2);//listener can be null 40 | return new DaemonConfigurations(configuration1, configuration2, listener); 41 | } 42 | 43 | 44 | class MyDaemonListener implements DaemonConfigurations.DaemonListener{ 45 | @Override 46 | public void onPersistentStart(Context context) { 47 | } 48 | 49 | @Override 50 | public void onDaemonAssistantStart(Context context) { 51 | } 52 | 53 | @Override 54 | public void onWatchDaemonDaed() { 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/Receiver1.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | /** 8 | * DO NOT do anything in this Receiver!
9 | * 10 | * Created by Mars on 12/24/15. 11 | */ 12 | public class Receiver1 extends BroadcastReceiver { 13 | @Override 14 | public void onReceive(Context context, Intent intent) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/Receiver2.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | /** 8 | * DO NOT do anything in this Receiver!
9 | * 10 | * Created by Mars on 12/24/15. 11 | */ 12 | public class Receiver2 extends BroadcastReceiver { 13 | @Override 14 | public void onReceive(Context context, Intent intent) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/Service1.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | /** 8 | * This Service is Persistent Service. Do some what you want to do here.
9 | * 10 | * Created by Mars on 12/24/15. 11 | */ 12 | public class Service1 extends Service{ 13 | 14 | @Override 15 | public void onCreate() { 16 | super.onCreate(); 17 | //TODO do some thing what you want.. 18 | } 19 | 20 | @Override 21 | public IBinder onBind(Intent intent) { 22 | return null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/java/com/marswin89/marsdaemon/demo/Service2.java: -------------------------------------------------------------------------------- 1 | package com.marswin89.marsdaemon.demo; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | /** 8 | * DO NOT do anything in this Service!
9 | * 10 | * Created by Mars on 12/24/15. 11 | */ 12 | public class Service2 extends Service{ 13 | 14 | @Override 15 | public IBinder onBind(Intent intent) { 16 | return null; 17 | } 18 | 19 | @Override 20 | public int onStartCommand(Intent intent, int flags, int startId) { 21 | return Service.START_NOT_STICKY; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/DemoMarsdaemon/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/DemoMarsdaemon/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/DemoMarsdaemon/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/DemoMarsdaemon/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Marswin/MarsDaemon/dd04983a389d5db73e18849d8c48a5610cc1e27a/DemoMarsdaemon/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Hello, this is Mars. 3 | MarsDaemon 4 | 5 | -------------------------------------------------------------------------------- /DemoMarsdaemon/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |