Skip to content

Commit ade9723

Browse files
author
Ted Schmidt
committed
Merge pull request #145 from senseobservationsystems/hotfix/implicit_intents_lollipop_setpackage
Hotfix/implicit intents lollipop setpackage
2 parents 73f0dc4 + a1737a7 commit ade9723

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+94
-20
lines changed

sense-android-library/src/nl/sense_os/platform/SensePlatform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public boolean addDataPoint(String sensorName, String displayName, String descri
198198
intent.putExtra(DataPoint.VALUE, (String) value);
199199
}
200200
intent.putExtra(DataPoint.TIMESTAMP, timestamp);
201+
intent.setPackage(mContext.getPackageName());
201202
ComponentName serviceName = mContext.startService(intent);
202203

203204
if (null != serviceName) {
@@ -255,6 +256,7 @@ public void close() {
255256
public boolean flushData() throws IllegalStateException {
256257
checkSenseService();
257258
Intent flush = new Intent(mContext.getString(R.string.action_sense_send_data));
259+
flush.setPackage(mContext.getPackageName());
258260
ComponentName started = mContext.startService(flush);
259261
return null != started;
260262
}

sense-android-library/src/nl/sense_os/service/AliveChecker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void onReceive(Context context, Intent intent) {
4141
Log.v(TAG, "Sense should be alive: poke it");
4242
final Intent serviceIntent = new Intent(
4343
context.getString(R.string.action_sense_service));
44+
serviceIntent.setPackage(context.getPackageName());
4445
if (null == context.startService(serviceIntent)) {
4546
Log.w(TAG, "Could not start Sense service!");
4647
}

sense-android-library/src/nl/sense_os/service/BootRx.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void onReceive(Context context, Intent intent) {
3434
if (true == autostart) {
3535
Log.i(TAG, "Autostart Sense Platform service");
3636
Intent startService = new Intent(context.getString(R.string.action_sense_service));
37+
startService.setPackage(context.getPackageName());
3738
ComponentName service = context.startService(startService);
3839
if (null == service) {
3940
Log.w(TAG, "Failed to start Sense Platform service");

sense-android-library/src/nl/sense_os/service/DataTransmitter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public void stopTransmissions() {
150150
public void transmissionService() {
151151
Log.v(TAG, "Start transmission");
152152
Intent task = new Intent(mContext.getString(R.string.action_sense_send_data));
153+
task.setPackage(mContext.getPackageName());
153154
mLastTxTime = SystemClock.elapsedRealtime();
154155
ComponentName service = mContext.startService(task);
155156
if (null == service) {

sense-android-library/src/nl/sense_os/service/NetworkMonitor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ public void onReceive(final Context context, Intent intent) {
3535

3636
// check that we are not logged in yet before logging in
3737
if (false == state.isLoggedIn()) {
38-
Log.i(TAG, "Regained connectivity! Try to log in");
39-
context.startService(new Intent(context.getString(R.string.action_sense_service)));
38+
Log.i(TAG, "Regained connectivity! Try to log in");
39+
Intent i = new Intent(context.getString(R.string.action_sense_service));
40+
i.setPackage(context.getPackageName());
41+
context.startService(i);
42+
4043

4144
} else {
4245
// still connected, stay logged in

sense-android-library/src/nl/sense_os/service/SenseService.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,12 @@ private void onLogOut() {
388388
transmitter.stopTransmissions();
389389

390390
// completely stop the MsgHandler service
391-
stopService(new Intent(getString(R.string.action_sense_new_data)));
392-
stopService(new Intent(getString(R.string.action_sense_send_data)));
391+
Intent newDataIntent = new Intent(getString(R.string.action_sense_new_data));
392+
newDataIntent.setPackage(getPackageName());
393+
stopService(newDataIntent);
394+
Intent sendDataIntent = new Intent(getString(R.string.action_sense_send_data));
395+
sendDataIntent.setPackage(getPackageName());
396+
stopService(sendDataIntent);
393397
}
394398

395399
void onSampleRateChange() {
@@ -482,7 +486,9 @@ void onSyncRateChange() {
482486
}
483487

484488
// update any widgets
485-
startService(new Intent(getString(R.string.action_widget_update)));
489+
Intent i = new Intent(getString(R.string.action_widget_update));
490+
i.setPackage(getPackageName());
491+
startService(i);
486492
}
487493

488494
/**
@@ -1189,7 +1195,9 @@ synchronized void toggleMain(boolean active) {
11891195
if (true == active) {
11901196
// properly start the service to start sensing
11911197
Log.i(TAG, "Start service");
1192-
startService(new Intent(getString(R.string.action_sense_service)));
1198+
Intent serviceIntent = new Intent(getString(R.string.action_sense_service));
1199+
serviceIntent.setPackage(getPackageName());
1200+
startService(serviceIntent);
11931201

11941202
} else {
11951203
Log.i(TAG, "Stop service");

sense-android-library/src/nl/sense_os/service/ServiceStateHelper.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,17 @@ public boolean isStarted() {
180180
}
181181

182182
public void setAmbienceActive(boolean active) {
183-
ambienceActive = active;
184-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
183+
ambienceActive = active;
184+
Intent i = new Intent(context.getString(R.string.action_widget_update));
185+
i.setPackage(context.getPackageName());
186+
context.startService(i);
185187
}
186188

187189
public void setDevProxActive(boolean active) {
188190
devProxActive = active;
189-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
191+
Intent i = new Intent(context.getString(R.string.action_widget_update));
192+
i.setPackage(context.getPackageName());
193+
context.startService(i);
190194
}
191195

192196
public void setExternalActive(boolean active) {
@@ -201,12 +205,16 @@ public void setForeground(boolean foreground) {
201205
// : "Sense Platform Service is in background...");
202206
updateNotification();
203207
}
204-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
208+
Intent i = new Intent(context.getString(R.string.action_widget_update));
209+
i.setPackage(context.getPackageName());
210+
context.startService(i);
205211
}
206212

207213
public void setLocationActive(boolean active) {
208214
locationActive = active;
209-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
215+
Intent i = new Intent(context.getString(R.string.action_widget_update));
216+
i.setPackage(context.getPackageName());
217+
context.startService(i);
210218
}
211219

212220
public void setLoggedIn(boolean loggedIn) {
@@ -216,17 +224,23 @@ public void setLoggedIn(boolean loggedIn) {
216224
// : "Sense Platform Service logged out...");
217225
updateNotification();
218226
}
219-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
227+
Intent i = new Intent(context.getString(R.string.action_widget_update));
228+
i.setPackage(context.getPackageName());
229+
context.startService(i);
220230
}
221231

222232
public void setMotionActive(boolean active) {
223233
motionActive = active;
224-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
234+
Intent i = new Intent(context.getString(R.string.action_widget_update));
235+
i.setPackage(context.getPackageName());
236+
context.startService(i);
225237
}
226238

227239
public void setPhoneStateActive(boolean active) {
228240
phoneStateActive = active;
229-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
241+
Intent i = new Intent(context.getString(R.string.action_widget_update));
242+
i.setPackage(context.getPackageName());
243+
context.startService(i);
230244
}
231245

232246
public void setQuizActive(boolean active) {
@@ -241,7 +255,9 @@ public void setStarted(boolean started) {
241255
// : "Sense Platform Service stopped...");
242256
updateNotification();
243257
}
244-
context.startService(new Intent(context.getString(R.string.action_widget_update)));
258+
Intent i = new Intent(context.getString(R.string.action_widget_update));
259+
i.setPackage(context.getPackageName());
260+
context.startService(i);
245261
}
246262

247263
/**

sense-android-library/src/nl/sense_os/service/ambience/AutoCalibratedNoiseSensor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private void sendSensorValue(double value, long ms) {
109109
sensorData.putExtra(DataPoint.VALUE, (float)value);
110110
sensorData.putExtra(DataPoint.DATA_TYPE, SenseDataTypes.FLOAT);
111111
sensorData.putExtra(DataPoint.TIMESTAMP, ms);
112+
sensorData.setPackage(context.getPackageName());
112113
context.startService(sensorData);
113114
}
114115
}

sense-android-library/src/nl/sense_os/service/ambience/CameraLightSensor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void lightValueCallback(float lightValue, int camera_id) {
6363
i.putExtra(DataPoint.SENSOR_DESCRIPTION, sensorDescription);
6464
i.putExtra(DataPoint.DATA_TYPE, SenseDataTypes.JSON);
6565
i.putExtra(DataPoint.TIMESTAMP, dataPoint.timeStamp);
66+
i.setPackage(context.getPackageName());
6667
context.startService(i);
6768
// Log.e(TAG, "Sent new camera licht values, camera: "+camera_id+" value: "+lightValue);
6869
nextUpdate(camera_id);

sense-android-library/src/nl/sense_os/service/ambience/HumiditySensor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public void onSensorChanged(SensorEvent event) {
111111
i.putExtra(DataPoint.SENSOR_NAME, sensorName);
112112
i.putExtra(DataPoint.SENSOR_DESCRIPTION, sensor.getName());
113113
i.putExtra(DataPoint.TIMESTAMP, dataPoint.timeStamp);
114+
i.setPackage(mContext.getPackageName());
114115
mContext.startService(i);
115116

116117
// done with sample

0 commit comments

Comments
 (0)