├── android
├── .gradle
│ ├── 5.0
│ │ ├── gc.properties
│ │ ├── fileChanges
│ │ │ └── last-build.bin
│ │ └── fileHashes
│ │ │ ├── fileHashes.bin
│ │ │ └── fileHashes.lock
│ └── vcs-1
│ │ └── gc.properties
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── ssg
│ │ └── autostart
│ │ ├── AutostartPackage.java
│ │ └── AutostartModule.java
├── .classpath
├── .project
└── build.gradle
├── .gitattributes
├── index.js
├── package.json
├── LICENSE.md
└── README.md
/android/.gradle/5.0/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/android/.gradle/vcs-1/gc.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/android/.gradle/5.0/fileChanges/last-build.bin:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/android/.gradle/5.0/fileHashes/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stepsetgo/react-native-autostart/HEAD/android/.gradle/5.0/fileHashes/fileHashes.bin
--------------------------------------------------------------------------------
/android/.gradle/5.0/fileHashes/fileHashes.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stepsetgo/react-native-autostart/HEAD/android/.gradle/5.0/fileHashes/fileHashes.lock
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 |
2 | import { NativeModules, Platform } from 'react-native';
3 |
4 | const { Autostart } = NativeModules;
5 |
6 | export default AutoStart = {
7 | startAutostartSettings: () => {
8 | if(Platform.OS === 'android') {
9 | return Autostart.startAutostartSettings()
10 | }
11 | },
12 | isCustomAndroid: () => {
13 | if(Platform.OS === 'android') {
14 | return Autostart.isCustomAndroid
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.1.3'
10 | }
11 | }
12 |
13 | apply plugin: 'com.android.library'
14 |
15 | android {
16 | compileSdkVersion 27
17 | buildToolsVersion "28.0.3"
18 |
19 | defaultConfig {
20 | minSdkVersion 16
21 | targetSdkVersion 22
22 | versionCode 1
23 | versionName "1.0"
24 | }
25 | lintOptions {
26 | abortOnError false
27 | }
28 | }
29 |
30 | repositories {
31 | mavenCentral()
32 | }
33 |
34 | dependencies {
35 | implementation 'com.facebook.react:react-native:+'
36 | }
37 |
--------------------------------------------------------------------------------
/android/src/main/java/com/ssg/autostart/AutostartPackage.java:
--------------------------------------------------------------------------------
1 | package com.ssg.autostart;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.bridge.NativeModule;
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.uimanager.ViewManager;
11 | import com.facebook.react.bridge.JavaScriptModule;
12 |
13 |
14 | public class AutostartPackage implements ReactPackage {
15 | @Override
16 | public List createNativeModules(ReactApplicationContext reactContext) {
17 | return Arrays.asList(
18 | new AutostartModule(reactContext)
19 | );
20 | }
21 |
22 |
23 | public List createViewManagers(ReactApplicationContext reactContext) {
24 | return Collections.emptyList();
25 | }
26 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-autostart",
3 | "version": "1.0.7",
4 | "description": "Autostart for custom skin androids",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [
10 | "react-native",
11 | "stepsetgo",
12 | "pepkit-media-pvt"
13 | ],
14 | "peerDependencies": {
15 | "react-native": "^0.57.0"
16 | },
17 | "contributors": [
18 | {
19 | "name": "Nilava",
20 | "email": "nilava@ownlab.in",
21 | "url": "https://www.ownlab.in"
22 | }
23 | ],
24 | "author": "StepSetGo",
25 | "license": "MIT",
26 | "repository": {
27 | "type": "git",
28 | "url": "git+https://github.com/stepsetgo/react-native-autostart.git"
29 | },
30 | "bugs": {
31 | "url": "https://github.com/stepsetgo/react-native-autostart/issues"
32 | },
33 | "homepage": "https://github.com/stepsetgo/react-native-autostart#readme"
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright 2019 Pepkit Media Private Limited
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-autostart
2 | [](https://www.npmjs.com/package/react-native-autostart)
3 | []()
4 | []()
5 | []()
6 | []()
7 |
8 |
9 | ## Getting started
10 |
11 | ```
12 | # npm
13 |
14 | npm install react-native-autostart --save
15 | ```
16 |
17 | ### Automatic Installation
18 |
19 | `$ react-native link react-native-autostart`
20 |
21 | ### Manual Installation
22 |
23 |
24 | #### Android
25 |
26 | 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
27 | - Add `import com.ssg.autostart.AutostartPackage;` to the imports at the top of the file
28 | - Add `new AutostartPackage()` to the list returned by the `getPackages()` method
29 | 2. Append the following lines to `android/settings.gradle`:
30 | ```
31 | include ':react-native-autostart'
32 | project(':react-native-autostart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-autostart/android')
33 | ```
34 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
35 | ```
36 | compile project(':react-native-autostart')
37 | ```
38 |
39 |
40 | ## Usage
41 | ```javascript
42 | import AutoStart from 'react-native-autostart';
43 |
44 | if(AutoStart.isCustomAndroid()) {
45 | AutoStart.startAutostartSettings();
46 | }
47 | ```
48 |
--------------------------------------------------------------------------------
/android/src/main/java/com/ssg/autostart/AutostartModule.java:
--------------------------------------------------------------------------------
1 | package com.ssg.autostart;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.net.Uri;
7 |
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
10 | import com.facebook.react.bridge.ReactMethod;
11 |
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 |
16 | public class AutostartModule extends ReactContextBaseJavaModule {
17 |
18 | private final ReactApplicationContext reactContext;
19 |
20 | public AutostartModule(ReactApplicationContext reactContext) {
21 | super(reactContext);
22 | this.reactContext = reactContext;
23 | }
24 |
25 | @Override
26 | public String getName() {
27 | return "Autostart";
28 | }
29 |
30 |
31 | private static final Intent[] AUTOSTART_INTENTS =
32 | {
33 | new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")), //MIUI
34 | new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
35 | new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")), //EMUI
36 | new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
37 | new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
38 | new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
39 | new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
40 | new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.entry.FunctionActivity")).setData(Uri.parse("mobilemanager://function/entry/AutoStart")),
41 | new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity"))
42 | };
43 |
44 | @ReactMethod
45 | public void startAutostartSettings() {
46 | for (Intent intent : AUTOSTART_INTENTS)
47 | if (reactContext.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
48 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
49 | reactContext.startActivity(intent);
50 | break;
51 | }
52 | }
53 |
54 | public Boolean isCustomAndroid() {
55 | for (Intent intent : AUTOSTART_INTENTS) {
56 | if (reactContext.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
57 | return true;
58 | }
59 | }
60 | return false;
61 | }
62 |
63 | @Override
64 | public Map getConstants() {
65 | final Map constants = new HashMap<>();
66 | constants.put("isCustomAndroid", isCustomAndroid());
67 | return constants;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------