Search code examples
androidbroadcastreceiver

Android Receiver randomly becomes disabled


I have an application with a Receiver defined in the AndroidManifest.xml and it is, seemingly, randomly becoming disabled which causes the app to force close until the app is re-installed. App might work fine for a day, a week or a month before this happens.

Relevant output from adb shell dumpsys:

  Package [com.example.helloworld.debug] (34181cc):
    userId=10196 gids=[3003, 1028, 1015, 3002, 3001]
    pkg=Package{388362dc com.example.helloworld.debug}
    codePath=/data/app/com.example.helloworld.debug-1
    resourcePath=/data/app/com.example.helloworld.debug-1
    legacyNativeLibraryDir=/data/app/com.example.helloworld.debug-1/lib
    primaryCpuAbi=null
    secondaryCpuAbi=null
    versionCode=1 targetSdk=22
    versionName=1.0d
    splits=[base]
    applicationInfo=ApplicationInfo{2a384fe5 com.example.helloworld.debug}
    flags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA VM_SAFE_MODE ALLOW_BACKUP ]
    dataDir=/data/data/com.example.helloworld.debug
    supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
    timeStamp=2015-06-02 13:42:27
    firstInstallTime=2015-06-02 13:42:27
    lastUpdateTime=2015-06-02 13:42:27
    signatures=PackageSignatures{126ffaba [1dee9d6b]}
    permissionsFixed=true haveGids=true installStatus=1
    pkgFlags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA VM_SAFE_MODE ALLOW_BACKUP ]
    User 0:  installed=true hidden=false stopped=false notLaunched=false enabled=0
      disabledComponents:
      com.et.sdk.ETLocationReceiver
    grantedPermissions:
      com.example.helloworld.debug.permission.C2D_MESSAGE
      com.google.android.c2dm.permission.RECEIVE
      android.permission.ACCESS_FINE_LOCATION
      android.permission.RECEIVE_BOOT_COMPLETED
      android.permission.BLUETOOTH
      android.permission.INTERNET
      android.permission.BLUETOOTH_ADMIN
      android.permission.READ_EXTERNAL_STORAGE
      android.permission.ACCESS_COARSE_LOCATION
      android.permission.ACCESS_NETWORK_STATE
      android.permission.DISABLE_KEYGUARD
      android.permission.GET_ACCOUNTS
      android.permission.WRITE_EXTERNAL_STORAGE
      android.permission.VIBRATE
      android.permission.ACCESS_WIFI_STATE
      android.permission.WAKE_LOCK

Relevant portion of the AndroidManifest.xml:

<!-- ETLocationReceiver and Service -->
<receiver android:name="com.et.sdk.ETLocationReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.BATTERY_LOW" />
        <action android:name="android.intent.action.BATTERY_OKAY" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.location.PROVIDERS_CHANGED" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</receiver>

Full source can be found on GitHub https://github.com/androidfu/EtPushHelloWorld


Solution

  • Upon further review it turns out that a BATTERY_LOW condition was disabling the LocationReceiver. Thank you for the tip @CommonsWare which made me keep digging.