Guide - How to add applications into the "Battery - Restricted apps" list.

Search This thread

tomogo

Senior Member
Nov 12, 2007
295
72
Prague
www.tomogo.cz
Hi all,
I have been using Samsung for many years and I used to do things right in the setting menu.

But with Sony XZ1c are thinghs slightly complicated. Like setting applications to "Restricted apps" in battery menu.
When you wan to add app as restricted you have to go to Settings>Apps>See all apps>{chose the app}>Advanced>Battery>Background restriction>Restrict.

It is really crazy for me so I prepare easy way how to do it in bulk by ADB:

Requirements:
  1. ADB installed on your PC.
  2. Enabled: Developer options>USB debugging
  3. Shell started on your PC, for example cmd in Windows, bash or another in Linux

Tested on:
47.2.A.10.80 but it should work on all versions.

How to:
First of all you have to get list of your applications in your phone:

Code:
adb shell pm list packages
package:com.amazon.mShop.android.shopping
package:com.sonymobile.whitebalance
.
.
.
package:com.android.cts.priv.ctsshim
package:com.qualcomm.qti.qms.service.telemetry

If you want (it is not necessarily) use these switches to filter list or show more information:

Code:
pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-l] [-u] [-U]
    [--uid UID] [--user USER_ID] [FILTER]
  Prints all packages; optionally only those whose name contains
  the text in FILTER.  Options are:
    -f: see their associated file
    -d: filter to only show disabled packages
    -e: filter to only show enabled packages
    -s: filter to only show system packages
    -3: filter to only show third party packages
    -i: see the installer for the packages
    -l: ignored (used for compatibility with older releases)
    -U: also show the package UID
    -u: also include uninstalled packages
    --uid UID: filter to only show packages with the given UID
    --user USER_ID: only list packages belonging to the given user

Chose which application you want to restrinct and type:

Code:
adb shell appops set <PACKAGE> RUN_ANY_IN_BACKGROUND ignore

like:
adb shell appops set com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND ignore

To check status of the app:

Code:
adb shell appops <PACKAGE> RUN_ANY_IN_BACKGROUND

like:
adb shell appops com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND

To restrict more than one application:

Code:
adb shell
appops set com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND ignore
appops set com.sonymobile.scan3d RUN_ANY_IN_BACKGROUND ignore
appops set com.google.android.youtube RUN_ANY_IN_BACKGROUND ignore
appops set net.languagecourse.vt.de RUN_ANY_IN_BACKGROUND ignore
.
.
.
.
appops set com.touchtype.swiftkey RUN_ANY_IN_BACKGROUND ignore
appops set com.FireproofStudios.TheRoom2 RUN_ANY_IN_BACKGROUND ignore
appops set com.FireproofStudios.TheRoom3 RUN_ANY_IN_BACKGROUND ignore
appops set com.FireproofStudios.TheRoom RUN_ANY_IN_BACKGROUND ignore
exit

How to revert your changes:

Code:
appops set <PACKAGE> RUN_ANY_IN_BACKGROUND allow

Like:
appops set com.FireproofStudios.TheRoom RUN_ANY_IN_BACKGROUND allow

Disclaimer:
I'm not responsible when you brick or damage your phone. Please chose <PACKAGE> carefully. Also do not restrict all packages!
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Hi all,
    I have been using Samsung for many years and I used to do things right in the setting menu.

    But with Sony XZ1c are thinghs slightly complicated. Like setting applications to "Restricted apps" in battery menu.
    When you wan to add app as restricted you have to go to Settings>Apps>See all apps>{chose the app}>Advanced>Battery>Background restriction>Restrict.

    It is really crazy for me so I prepare easy way how to do it in bulk by ADB:

    Requirements:
    1. ADB installed on your PC.
    2. Enabled: Developer options>USB debugging
    3. Shell started on your PC, for example cmd in Windows, bash or another in Linux

    Tested on:
    47.2.A.10.80 but it should work on all versions.

    How to:
    First of all you have to get list of your applications in your phone:

    Code:
    adb shell pm list packages
    package:com.amazon.mShop.android.shopping
    package:com.sonymobile.whitebalance
    .
    .
    .
    package:com.android.cts.priv.ctsshim
    package:com.qualcomm.qti.qms.service.telemetry

    If you want (it is not necessarily) use these switches to filter list or show more information:

    Code:
    pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-l] [-u] [-U]
        [--uid UID] [--user USER_ID] [FILTER]
      Prints all packages; optionally only those whose name contains
      the text in FILTER.  Options are:
        -f: see their associated file
        -d: filter to only show disabled packages
        -e: filter to only show enabled packages
        -s: filter to only show system packages
        -3: filter to only show third party packages
        -i: see the installer for the packages
        -l: ignored (used for compatibility with older releases)
        -U: also show the package UID
        -u: also include uninstalled packages
        --uid UID: filter to only show packages with the given UID
        --user USER_ID: only list packages belonging to the given user

    Chose which application you want to restrinct and type:

    Code:
    adb shell appops set <PACKAGE> RUN_ANY_IN_BACKGROUND ignore
    
    like:
    adb shell appops set com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND ignore

    To check status of the app:

    Code:
    adb shell appops <PACKAGE> RUN_ANY_IN_BACKGROUND
    
    like:
    adb shell appops com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND

    To restrict more than one application:

    Code:
    adb shell
    appops set com.amazon.mShop.android.shopping RUN_ANY_IN_BACKGROUND ignore
    appops set com.sonymobile.scan3d RUN_ANY_IN_BACKGROUND ignore
    appops set com.google.android.youtube RUN_ANY_IN_BACKGROUND ignore
    appops set net.languagecourse.vt.de RUN_ANY_IN_BACKGROUND ignore
    .
    .
    .
    .
    appops set com.touchtype.swiftkey RUN_ANY_IN_BACKGROUND ignore
    appops set com.FireproofStudios.TheRoom2 RUN_ANY_IN_BACKGROUND ignore
    appops set com.FireproofStudios.TheRoom3 RUN_ANY_IN_BACKGROUND ignore
    appops set com.FireproofStudios.TheRoom RUN_ANY_IN_BACKGROUND ignore
    exit

    How to revert your changes:

    Code:
    appops set <PACKAGE> RUN_ANY_IN_BACKGROUND allow
    
    Like:
    appops set com.FireproofStudios.TheRoom RUN_ANY_IN_BACKGROUND allow

    Disclaimer:
    I'm not responsible when you brick or damage your phone. Please chose <PACKAGE> carefully. Also do not restrict all packages!