Skip to content

Commit 675814d

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Maybe fix issue #7596986: Frequent runtime restarts; IAE at..." into jb-mr1.1-dev
2 parents 849f518 + 6c5406a commit 675814d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

services/java/com/android/server/LocationManagerService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public boolean callLocationChangedLocked(Location location) {
531531
synchronized (this) {
532532
// synchronize to ensure incrementPendingBroadcastsLocked()
533533
// is called before decrementPendingBroadcasts()
534-
mListener.onLocationChanged(location);
534+
mListener.onLocationChanged(new Location(location));
535535
// call this after broadcasting so we do not increment
536536
// if we throw an exeption.
537537
incrementPendingBroadcastsLocked();
@@ -1323,10 +1323,10 @@ public Location getLastLocation(LocationRequest request, String packageName) {
13231323
if (allowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
13241324
Location noGPSLocation = location.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
13251325
if (noGPSLocation != null) {
1326-
return mLocationFudger.getOrCreate(noGPSLocation);
1326+
return new Location(mLocationFudger.getOrCreate(noGPSLocation));
13271327
}
13281328
} else {
1329-
return location;
1329+
return new Location(location);
13301330
}
13311331
}
13321332
return null;

services/java/com/android/server/am/BroadcastQueue.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import android.os.SystemClock;
3939
import android.os.UserHandle;
4040
import android.util.EventLog;
41+
import android.util.Log;
4142
import android.util.Slog;
4243

4344
/**
@@ -779,6 +780,21 @@ final void processNextBroadcast(boolean fromMsg) {
779780
} catch (RemoteException e) {
780781
Slog.w(TAG, "Exception when sending broadcast to "
781782
+ r.curComponent, e);
783+
} catch (RuntimeException e) {
784+
Log.wtf(TAG, "Failed sending broadcast to "
785+
+ r.curComponent + " with " + r.intent, e);
786+
// If some unexpected exception happened, just skip
787+
// this broadcast. At this point we are not in the call
788+
// from a client, so throwing an exception out from here
789+
// will crash the entire system instead of just whoever
790+
// sent the broadcast.
791+
logBroadcastReceiverDiscardLocked(r);
792+
finishReceiverLocked(r, r.resultCode, r.resultData,
793+
r.resultExtras, r.resultAbort, true);
794+
scheduleBroadcastsLocked();
795+
// We need to reset the state if we failed to start the receiver.
796+
r.state = BroadcastRecord.IDLE;
797+
return;
782798
}
783799

784800
// If a dead object exception was thrown -- fall through to

0 commit comments

Comments
 (0)