Skip to content

Commit

Permalink
Removes the broadcast receiver for survey control and updates the dir…
Browse files Browse the repository at this point in the history
…ect service intent approach for 3rd party app survey control
  • Loading branch information
christianrowlands committed Aug 5, 2024
1 parent e418d73 commit d0053d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 162 deletions.
10 changes: 0 additions & 10 deletions networksurvey/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@
</intent-filter>
</receiver>

<receiver
android:name=".SurveyControlReceiver"
android:label="SurveyControlReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.craxiom.networksurvey.START_SURVEY" />
</intent-filter>
</receiver>

<receiver
android:name=".CdrSmsReceiver"
android:label="CdrSmsReceiver"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ public NetworkSurveyService()
@Override
public void onCreate()
{
super.onCreate();

Timber.i("Creating the Network Survey Service");

final Context context = getApplicationContext();
Expand Down Expand Up @@ -261,6 +259,13 @@ public int onStartCommand(Intent intent, int flags, int startId)
}
} else if (ACTION_START_SURVEY.equals(intent.getAction()))
{
boolean allowIntentControl = PreferenceUtils.getAllowIntentControlPreference(this);
if (!allowIntentControl)
{
Timber.w("Received a start survey control intent, but the user has disabled intent control");
return START_REDELIVER_INTENT;
}

Timber.i("The Network Survey Service was started via an external intent");

final boolean startCellular = intent.getBooleanExtra(NetworkSurveyConstants.EXTRA_CELLULAR_FILE_LOGGING, false);
Expand Down Expand Up @@ -312,16 +317,16 @@ public int onStartCommand(Intent intent, int flags, int startId)
}
} else if (ACTION_STOP_SURVEY.equals(intent.getAction()))
{
boolean allowIntentControl = PreferenceUtils.getAllowIntentControlPreference(this);
if (!allowIntentControl)
{
Timber.w("Received a stop survey control intent, but the user has disabled intent control");
return START_REDELIVER_INTENT;
}

Timber.i("The Network Survey Service is being stopped via an external intent");

// This whole else-if block is really unnecessary because the caller should just use
// stopService(stopNetworkSurveyIntent) instead of sending this intent. But, we'll
// handle it just in case.
if (cellularController.isLoggingEnabled()) cellularController.toggleLogging(false);
if (wifiController.isLoggingEnabled()) wifiController.toggleLogging(false);
if (bluetoothController.isLoggingEnabled()) bluetoothController.toggleLogging(false);
if (gnssController.isLoggingEnabled()) gnssController.toggleLogging(false);
if (isCdrLoggingEnabled()) toggleCdrLogging(false);
stopAllLogging();
disconnectFromMqttBroker();

if (!isBeingUsed()) stopSelf();
Expand Down Expand Up @@ -1750,10 +1755,12 @@ private Notification buildNotification()
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this, NetworkSurveyConstants.NOTIFICATION_CHANNEL_ID)
.setContentTitle(notificationTitle)
.setOngoing(true)
.setOnlyAlertOnce(true)
.setSmallIcon(mqttConnectionActive ? R.drawable.ic_cloud_connection : (logging ? R.drawable.logging_thick_icon : R.drawable.gps_map_icon))
.setContentIntent(pendingIntent)
.setTicker(notificationTitle)
.setContentText(notificationText)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText));

if (connectionState == ConnectionState.CONNECTING)
Expand Down

0 comments on commit d0053d4

Please sign in to comment.