11

Smart manager kills an app that hasn't been used for 3 days. My app does some background work and hence, the user doesn't need to open it.

What can I do so that it doesn't enter app optimization mode ( Android OS 5.0.2, 5.1.1)

lyc001
  • 697
  • 9
  • 23
  • I found a workaround, see my answer here: https://stackoverflow.com/a/54945943/704872 – izio Mar 04 '19 at 07:40

2 Answers2

9

I found an array with the packages that are in the whitelist from Smart Manager. There is some kind of partnership with developers and Samsung.

Galaxy S7 Android N, Smart Manager its package name now is "com.samsung.android.lool"

Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.setClassName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity");
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);


<string-array name="exclude_from_spcm">
    <item>com.sds.mdmain</item>
    <item>com.whatsapp</item>
    <item>com.facebook.orca</item>
    <item>com.tencent.mm</item>
    <item>com.skype.raider</item>
    <item>com.viber.voip</item>
    <item>jp.naver.line.android</item>
    <item>com.kakao.talk</item>
    <item>com.snapchat.android</item>
    <item>com.sgiggle.production</item>
    <item>kik.android</item>
    <item>com.kakao.story</item>
    <item>com.nhn.android.band</item>
    <item>com.btb.minihompy</item>
    <item>com.sec.chatonblue</item>
    <item>com.sds.mobiledesk</item>
    <item>com.samsung.android.spay</item>
    <item>com.sec.android.app.shealth</item>
    <item>com.z7.samsung.mobiledesk.z7</item>
    <item>com.z7.samsung.mobiledesk.Z7</item>
    <item>com.sds.mysinglesquare</item>
    <item>com.samsung.uready.agent</item>
    <item>com.sds.mobile.mdm.client.MDMManager</item>
    <item>com.samsung.android.app.watchmanager</item>
    <item>com.samsung.android.wms</item>
    <item>com.samsung.accessory.goproviders</item>
    <item>com.samsung.accessory.saproviders</item>
    <item>com.sec.android.sidesync30</item>
    <item>com.amc.ui</item>
    <item>com.sec.wecontacts</item>
    <item>com.bns.wecontacts</item>
    <item>com.sec.weagent</item>
    <item>com.sec.wetester</item>
    <item>com.samsung.dbs.service</item>
    <item>com.kddi.android.videopass</item>
    <item>com.ktcs.whowho</item>
    <item>com.google.android.wearable.app</item>
    <item>com.google.android.projection.gearhead</item>
    <item>com.sec.chaton.secure</item>
    <item>com.estsoft.alyac</item>
    <item>com.estsoft.alyac.tablet</item>
    <item>com.coremobility.app.vnotes</item>
    <item>com.kineto.smartwifi</item>
    <item>msgplus.jibe.sca</item>
    <item>com.locationlabs.sparkle.yellow.pre</item>
    <item>com.locationlabs.v3client</item>
    <item>com.oem.smartwifisupport</item>
    <item>com.wsandroid.suite.vodaemea</item>
    <item>com.vodafone.sn.vpn</item>
    <item>com.vodafone.smhs</item>
    <item>com.vodafone.vodafone360updates</item>
    <item>com.vodafone.netperform.full</item>
    <item>com.vf_nqt.client</item>
    <item>com.vodafone.messaging</item>
    <item>com.vodafone.safetynet.core</item>
    <item>at.mobilkom.android.meina1</item>
    <item>al.myvodafone.android</item>
    <item>com.zentity.vodafone</item>
    <item>com.appseleration.android.selfcare</item>
    <item>com.myvodafone.android</item>
    <item>hu.mito.android.vodafone</item>
    <item>com.VodafoneIreland.MyVodafone</item>
    <item>it.vodafone.my190</item>
    <item>com.vodafone.android</item>
    <item>com.vodafone.mCare</item>
    <item>be.belgacom.hello</item>
    <item>ro.vodafone.mcare.android</item>
    <item>es.vodafone.mobile.mivodafone</item>
    <item>com.swisscom.myswisscom</item>
    <item>com.myvodafoneapp</item>
    <item>za.co.vodacom.android.app</item>
    <item>com.appseleration.speedtest</item>
    <item>com.radioopt.tmplus</item>
    <item>com.radioopt.widget</item>
    <item>com.radioopt.engineering</item>
    <item>com.radioopt.enterprise</item>
    <item>com.radioopt.apc</item>
    <item>com.radioopt.network</item>
    <item>com.vodafone.accesorystore</item>
    <item>at.mobilkom.android.a1apps</item>
    <item>com.vodafone.myaccessories</item>
    <item>com.swisscom.scappslauncher</item>
    <item>com.vodafone.directaccessories</item>
    <item>hr.infinum.mojvip</item>
    <item>com.vodafone.appstore.sa</item>
    <item>com.skt.skaf.a000as00tm</item>
    <item>com.kt.mtmoney</item>
    <item>com.lgt.tmoney</item>
    <item>com.ebcard.skcashbee</item>
    <item>com.kt.cashbee</item>
    <item>com.lguplus.cashbee</item>
    <item>com.hs.govsns.mobile</item>
    <item>com.oculus.home</item>
    <item>com.samsung.android.hmt.vrsvc</item>
    <item>com.oculus.oculus360photos</item>
    <item>com.oculus.oculus360videos</item>
    <item>com.samsung.android.app.vrsetupwizard</item>
    <item>com.samsung.android.app.vrsetupwizardstub</item>
    <item>com.oculus.horizon</item>
    <item>com.samsung.android.app.vr.gallery</item>
    <item>com.samsung.android.app.vr.video</item>
    <item>com.oculus.cinema</item>
    <item>com.oculus.systemactivities</item>
    <item>com.facebook.appmanager</item>
    <item>com.facebook.system</item>
    <item>com.ipg.gguide.dcm_app.android</item>
    <item>com.ipg.gguide.dcm_wifi_app.android</item>
    <item>com.nttdocomo.android.iconcier</item>
    <item>jp.co.nttdocomo.ichannel</item>
    <item>com.nttdocomo.android.osv</item>
    <item>com.nttdocomo.android.anmane</item>
    <item>com.nttdocomo.android.anmane2</item>
    <item>com.rsupport.rs.activity.ntt</item>
    <item>jp.co.nttdocomo.android.gs.utility2_sha2</item>
    <item>jp.co.nttdocomo.android.gs.utility2</item>
    <item>com.nttdocomo.android.mascot</item>
    <item>com.nttdocomo.android.docomosimplehome</item>
    <item>com.nttdocomo.android.lac</item>
    <item>com.nttdocomo.android.settings.lac</item>
    <item>com.nttdocomo.android.cloudstorageservice</item>
    <item>com.mcafee.vsm_android_dcm</item>
    <item>com.nttdocomo.android.gs.utility_sha2</item>
    <item>com.nttdocomo.android.gs.utility</item>
    <item>com.nttdocomo.android.accountwipe</item>
    <item>com.nttdocomo.android.messagedl</item>
    <item>com.nttdocomo.android.homeagent</item>
    <item>com.nttdocomo.android.toruca</item>
    <item>com.nttdocomo.android.photocollection</item>
    <item>com.nttdocomo.android.photoviewer</item>
    <item>jp.id_credit_sp.android</item>
    <item>com.nttdocomo.android.apnmng</item>
    <item>jp.co.nttdocomo.contentsheadline</item>
    <item>com.mcafee.safecall.docomo</item>
    <item>jp.dmapnavi.navi02</item>
    <item>com.uievolution.gguide.android</item>
    <item>com.showcasegig.devlawson</item>
    <item>jp.co.mcdonalds.android</item>
    <item>jp.co.lawson.activity</item>
    <item>kr.co.nexdigm.mdm.s</item>
    <item>kr.co.nexdigm.mdm.agent</item>
    <item>com.sktelecom.ssm</item>
    <item>com.sktelecom.ssmpush</item>
    <item>com.ebcard.cashbeew.s</item>
    <item>com.life360.android.safetymapd</item>
    <item>com.fsp.android.friendlocator</item>
    <item>com.fsp.android.c</item>
    <item>com.fsp.android.h</item>
    <item>com.fsp.android.phonetracker</item>
    <item>com.life360.android.note4</item>
    <item>com.life360.android.s6</item>
    <item>fr.freemobile.android.vvm</item>
    <item>fr.freemobile.android.mobilecompagnon</item>
    <item>kr.co.bnkbank.push.customer</item>
    <item>kr.co.bnkbank.push.employee</item>
    <item>com.shinhan.sbanking</item>
    <item>com.shinhan.speedup</item>
    <item>com.shinhan.smartcaremgr</item>
    <item>com.shinhan.smartfund</item>
    <item>com.shinhan.missionbanking</item>
    <item>com.shinhan.mobilebankbook</item>
    <item>com.safeon.approval</item>
    <item>com.shinhan.sbizbank</item>
    <item>com.shinhan.trade.copper</item>
    <item>com.shinhan.dingdong</item>
    <item>com.shinhan.shb2chd</item>
    <item>com.shcard.smartpay</item>
    <item>com.shinhancard.smartshinhan</item>
    <item>com.shinhancard.smartshinhan.mini</item>
    <item>com.wr.alrim</item>
    <item>com.IBK.SmartPush.app</item>
    <item>com.hanafn.push.agent</item>
    <item>com.hanabank.ebk.channel.android.hananbank</item>
    <item>com.samsung.android.app.memo</item>
    <item>com.samsung.android.snote</item>
    <item>com.samsung.android.app.pinboard</item>
    <item>com.sds.mobile.mdm.client.MDMManager</item>
    <item>com.sds.emm.client</item>
    <item>com.sds.emm.client.visitor</item>
    <item>gogolook.callgogolook2</item>
    <item>com.nhn.android.webtoon</item>
    <item>com.naver.linewebtoon</item>
    <item>com.naver.vapp</item>
    <item>com.navercorp.android.ttsapp</item>
    <item>com.nhn.android.music</item>
    <item>net.daum.android.daum</item>
    <item>com.daumkakao.android.brunchapp</item>
    <item>com.kakao.page</item>
    <item>com.vaultmicro.kidsnote</item>
    <item>com.orange.vvm</item>
    <item>com.telenor.mbedriftsnett</item>
    <item>com.samsung.android.app.scharm</item>
    <item>net.ib.android.smcard</item>
    <item>com.samsungcard.certi</item>
    <item>kr.co.samsungcard.mpocket</item>
    <item>com.samsungcard.shopping</item>
    <item>com.samsungcard.baby</item>
    <item>sc.chn.hom.msa.ga</item>
    <item>com.samsung.android.email.provider</item>
    <item>com.samsung.oh</item>
    <item>com.sec.android.app.sbrowser</item>
    <item>com.microsoft.windowsintune.companyportal</item>
    <item>com.icq.mobile.client</item>
    <item>com.my.mail</item>
    <item>com.vkontakte.android</item>
    <item>ru.mail.mailapp</item>
    <item>ru.ok.android</item>
    <item>com.google.android.apps.tachyon</item>
    <item>ru.mail</item>
    <item>com.lacoon.security.fox</item>
    <item>com.google.android.apps.fireball</item>
    <item>com.sds.mms.ui</item>
    <item>com.mcafee.android.scanservice</item>
    <item>com.android.services.telephony.common</item>
    <item>com.samsungcard.android.oap</item>
    <item>com.sec.android.app.ocr3</item>
    <item>com.sec.android.app.ocr4</item>
    <item>com.mediatek.BlueMagpie</item>
    <item>com.samsung.android.game.gametools</item>
    <item>it.h3g.areaclienti3</item>
    <item>com.skt.prod.cloud</item>
    <item>com.turkcell.bip</item>
    <item>com.samsung.android.intelligence.executormanager</item>
    <item>com.nttdocomo.android.hcebridge</item>
    <item>jp.id_credit_sp.android.devappli</item>
    <item>com.knb.psb</item>
    <item>com.knb.csb</item>
    <item>com.knb.bsp</item>
    <item>com.knb.bdr</item>
    <item>com.diotek.sec.lookup.dictionary</item>
    <item>com.samsung.android.onlinevideo</item>
    <item>com.oculus.systemdriver</item>
    <item>com.oculus.gearchina</item>
    <item>com.oculus.systemservices</item>
    <item>com.nttdocomo.android.iconcier_contents</item>
    <item>com.nttdocomo.android.socialphonebook</item>
    <item>com.nttdocomo.android.portablesim</item>
    <item>com.sktelecom.ttalk</item>
</string-array>
F4bioo
  • 181
  • 1
  • 4
  • 9
8

Sadly, there is currently no way to prevent this.

The only thing you can do is instruct users to disable optimization for your app.

I did some research about this myself not long ago, here are some links I saved that might be interesting for you

https://news.samsung.com/global/smart-manager-the-way-to-keep-your-galaxy-smartphone-as-good-as-new-always

http://developer.samsung.com/forum/thread/smart-manager-kills-my-alarms/202/288300?boardName=General&listLines=15&startId=zzzzz~&curPage=3

http://developer.samsung.com/forum/thread/samsung-smart-manager-is-preventing-alarmmanager-to-work-correctly/201/288546?boardName=SDK&startId=zzzzz~&searchSubId=0000000001

Also, here is a code snippet that launches the smart manager app's BatteryActivity (if it's installed) to help users to disable the optimization:

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.samsung.android.sm", "com.samsung.android.sm.ui.battery.BatteryActivity"));
try {
    getActivity().startActivity(intent);
} catch (ActivityNotFoundException ex) {
    Toast.makeText(getActivity(), "Smart manager not installed on this device", Toast.LENGTH_LONG)
            .show();
}
Tim
  • 38,263
  • 17
  • 115
  • 131
  • So even if you run a foreground service that shows a notification in the notification tray, but you don't open the app for many days, you can still go into app optimization? @Tim Castelijns – lyc001 May 13 '16 at 09:09
  • 1
    @lyc001 I'm not 100% sure about foreground services, since I use a background service myself. But yes all my testing and reseach show that if a user does not open the app within X days then samsung will stop all activity belonging to that your app – Tim May 13 '16 at 09:16
  • 2
    If I want to simulate the behavior, by going to battery optimization and choosing "always optimizing" for my app, I still can connect to it and do some background work. Do you know how we can simulate app optimization mode without having to wait for 3 days? @Tim Castelijns – lyc001 May 13 '16 at 09:33
  • @lyc001 sorry, I don't know if that's possible. Perhaps there is an option in the ddms tool, but I haven't used that much so I can't tell you any details – Tim May 13 '16 at 09:40
  • Thanks for this answer. Do you know how to go to the list of apps using battery instead of battery manager. com.samsung.android.sm.ui.applocking.AppLockingViewActivity – Fakher Dec 05 '16 at 13:18
  • @Fakher same way just replaced the string. If it doesn't work, the screen is not externally accessible. – Tim Dec 05 '16 at 13:22
  • I try it, it throws a securityException !!! saying that permission denial ! – Fakher Dec 05 '16 at 13:32
  • @TimCastelijns, Is there any way to set app by default "Turned Off". Because i installed the `viber`, `whatsapp` and `Messenger` (facebook) these app's "Power saving" setting is by default `Turned off`. – Mukesh Kumar Singh Apr 24 '17 at 14:49
  • @MukeshKumar As far as I know everything is turned on by default. If these apps are not, perhaps SmartManager has criteria by which it decides what to do with an app, or maybe facebook etc have deals with Samsung. I don't know – Tim Apr 24 '17 at 14:59
  • Thanks @TimCastelijns. – Mukesh Kumar Singh Apr 24 '17 at 15:06
  • If battery optimization is enabled, push notification will work? – phnmnn Aug 22 '17 at 09:21
  • @phnmnn push notifications (at least high priority ones) always work – Tim Aug 22 '17 at 09:29
  • @TimCastelijns, I have a navigation application. Geofences on Samsung devices after a certain time stop working(on other devices works perfect), seems the problem caused by Smart manager. Can i use push notification to update geofence topology after my app got deactivated by Smart manager? – phnmnn Aug 22 '17 at 09:35
  • Is there not any API so that an application can automatically read the list of apps that have been put to sleep? – user3289695 Mar 15 '18 at 08:12
  • use `"com.samsung.android.sm", "com.samsung.android.sm.ui.battery.BatteryActivity"` on Android L and `"com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity"` on Android N Source https://code.briarproject.org/briar/briar/issues/1100 – schlenger Jul 11 '19 at 15:16
  • use `"com.samsung.android.lool", "com.samsung.android.sm.battery.ui.BatteryActivity"` on Android 10 (at least on my Samsung S10e) – Mark Jul 06 '20 at 12:22