Skip to content

Commit 157b34f

Browse files
committed
Create app start intents at runtime
1 parent 5f6072e commit 157b34f

File tree

2 files changed

+65
-60
lines changed

2 files changed

+65
-60
lines changed

src/android/BackgroundMode.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*
2-
Copyright 2013-2017 appPlant GmbH
3-
4-
Licensed to the Apache Software Foundation (ASF) under one
5-
or more contributor license agreements. See the NOTICE file
6-
distributed with this work for additional information
7-
regarding copyright ownership. The ASF licenses this file
8-
to you under the Apache License, Version 2.0 (the
9-
"License"); you may not use this file except in compliance
10-
with the License. You may obtain a copy of the License at
11-
12-
http://www.apache.org/licenses/LICENSE-2.0
13-
14-
Unless required by applicable law or agreed to in writing,
15-
software distributed under the License is distributed on an
16-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17-
KIND, either express or implied. See the License for the
18-
specific language governing permissions and limitations
19-
under the License.
2+
Copyright 2013 Sebastián Katzer
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
2020
*/
2121

2222
package de.appplant.cordova.plugin.background;

src/android/BackgroundModeExt.java

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*
2-
Copyright 2013-2017 appPlant GmbH
3-
4-
Licensed to the Apache Software Foundation (ASF) under one
5-
or more contributor license agreements. See the NOTICE file
6-
distributed with this work for additional information
7-
regarding copyright ownership. The ASF licenses this file
8-
to you under the Apache License, Version 2.0 (the
9-
"License"); you may not use this file except in compliance
10-
with the License. You may obtain a copy of the License at
11-
12-
http://www.apache.org/licenses/LICENSE-2.0
13-
14-
Unless required by applicable law or agreed to in writing,
15-
software distributed under the License is distributed on an
16-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17-
KIND, either express or implied. See the License for the
18-
specific language governing permissions and limitations
19-
under the License.
2+
Copyright 2013 Sebastián Katzer
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
2020
*/
2121

2222
package de.appplant.cordova.plugin.background;
@@ -66,29 +66,6 @@ Licensed to the Apache Software Foundation (ASF) under one
6666
*/
6767
public class BackgroundModeExt extends CordovaPlugin {
6868

69-
// List of intents for various manufactures to adjust the power saver mode.
70-
private static final List<Intent> APPSTART_INTENTS = Arrays.asList(
71-
new Intent().setComponent(new ComponentName("com.miui.securitycenter","com.miui.permcenter.autostart.AutoStartManagementActivity")),
72-
new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
73-
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")),
74-
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
75-
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
76-
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
77-
new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
78-
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
79-
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
80-
new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
81-
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.autostart.AutoStartActivity")),
82-
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.entry.FunctionActivity")).setData(android.net.Uri.parse("mobilemanager://function/entry/AutoStart")),
83-
new Intent().setAction("com.letv.android.permissionautoboot"),
84-
new Intent().setComponent(new ComponentName("com.samsung.android.sm_cn", "com.samsung.android.sm.ui.ram.AutoRunActivity")),
85-
new Intent().setComponent(ComponentName.unflattenFromString("com.iqoo.secure/.MainActivity")),
86-
new Intent().setComponent(ComponentName.unflattenFromString("com.meizu.safe/.permission.SmartBGActivity")),
87-
new Intent().setComponent(new ComponentName("com.yulong.android.coolsafe", ".ui.activity.autorun.AutoRunListActivity")),
88-
new Intent().setComponent(new ComponentName("cn.nubia.security2", "cn.nubia.security.appmanage.selfstart.ui.SelfStartActivity")),
89-
new Intent().setComponent(new ComponentName("com.zui.safecenter", "com.lenovo.safecenter.MainTab.LeSafeMainActivity"))
90-
);
91-
9269
// To keep the device awake
9370
private PowerManager.WakeLock wakeLock;
9471

@@ -243,7 +220,7 @@ private void openAppStart (Object arg)
243220
Activity activity = cordova.getActivity();
244221
PackageManager pm = activity.getPackageManager();
245222

246-
for (Intent intent : APPSTART_INTENTS)
223+
for (Intent intent : getAppstartIntents())
247224
{
248225
if (pm.resolveActivity(intent, MATCH_DEFAULT_ONLY) != null)
249226
{
@@ -437,4 +414,32 @@ private Object getService(String name)
437414
{
438415
return getApp().getSystemService(name);
439416
}
417+
418+
/**
419+
* Returns list of all possible intents to present the app start settings.
420+
*/
421+
private List<Intent> getAppstartIntents()
422+
{
423+
return Arrays.asList(
424+
new Intent().setComponent(new ComponentName("com.miui.securitycenter","com.miui.permcenter.autostart.AutoStartManagementActivity")),
425+
new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
426+
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")),
427+
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
428+
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
429+
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
430+
new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
431+
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
432+
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
433+
new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
434+
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.autostart.AutoStartActivity")),
435+
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.entry.FunctionActivity")).setData(android.net.Uri.parse("mobilemanager://function/entry/AutoStart")),
436+
new Intent().setAction("com.letv.android.permissionautoboot"),
437+
new Intent().setComponent(new ComponentName("com.samsung.android.sm_cn", "com.samsung.android.sm.ui.ram.AutoRunActivity")),
438+
new Intent().setComponent(ComponentName.unflattenFromString("com.iqoo.secure/.MainActivity")),
439+
new Intent().setComponent(ComponentName.unflattenFromString("com.meizu.safe/.permission.SmartBGActivity")),
440+
new Intent().setComponent(new ComponentName("com.yulong.android.coolsafe", ".ui.activity.autorun.AutoRunListActivity")),
441+
new Intent().setComponent(new ComponentName("cn.nubia.security2", "cn.nubia.security.appmanage.selfstart.ui.SelfStartActivity")),
442+
new Intent().setComponent(new ComponentName("com.zui.safecenter", "com.lenovo.safecenter.MainTab.LeSafeMainActivity"))
443+
);
444+
}
440445
}

0 commit comments

Comments
 (0)