start stuff when package replaced

And: Don't start the foreground service with its user-visible
notification, as that's too obtrusive and the ACL_CONNECTED stuff seems
to work well enough. Launching timers on a new install is mostly for my
own dev use, but won't hurt user experience either.
This commit is contained in:
Eric House 2018-12-17 08:26:39 -08:00
parent d8d0065e90
commit 5467941d45
2 changed files with 13 additions and 6 deletions

View file

@ -115,6 +115,7 @@
<receiver android:name="OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver android:name="RelayReceiver"/>

View file

@ -30,12 +30,18 @@ public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive( Context context, Intent intent )
{
if ( null != intent
&& null != intent.getAction()
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
Log.d( TAG, "got ACTION_BOOT_COMPLETED" );
startTimers( context );
BTService.onAppToBackground( context );
if ( null != intent ) {
String action = intent.getAction();
Log.d( TAG, "got %s", action );
switch( action ) {
case Intent.ACTION_BOOT_COMPLETED:
case Intent.ACTION_MY_PACKAGE_REPLACED:
startTimers( context );
// Let's not put up the foreground service notification on
// boot. Too likely to annoy.
// BTService.onAppToBackground( context );
break;
}
}
}