summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/AlarmManagerService.java10
-rw-r--r--services/java/com/android/server/ConnectivityService.java1
-rw-r--r--services/java/com/android/server/MountService.java3
-rw-r--r--services/java/com/android/server/NetworkManagementService.java2
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java18
-rwxr-xr-xservices/java/com/android/server/VibratorService.java18
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java20
-rwxr-xr-xservices/java/com/android/server/location/GpsLocationProvider.java13
8 files changed, 61 insertions, 24 deletions
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java
index 8c07e15..5e54d61 100644
--- a/services/java/com/android/server/AlarmManagerService.java
+++ b/services/java/com/android/server/AlarmManagerService.java
@@ -255,10 +255,7 @@ class AlarmManagerService extends IAlarmManager.Stub {
// Update the kernel timezone information
// Kernel tracks time offsets as 'minutes west of GMT'
- int gmtOffset = zone.getRawOffset();
- if (zone.inDaylightTime(new Date(System.currentTimeMillis()))) {
- gmtOffset += zone.getDSTSavings();
- }
+ int gmtOffset = zone.getOffset(System.currentTimeMillis());
setKernelTimezone(mDescriptor, -(gmtOffset / 60000));
}
@@ -759,9 +756,8 @@ class AlarmManagerService extends IAlarmManager.Stub {
// based off of the current Zone gmt offset + userspace tracked
// daylight savings information.
TimeZone zone = TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY));
- int gmtOffset = (zone.getRawOffset() + zone.getDSTSavings()) / 60000;
-
- setKernelTimezone(mDescriptor, -(gmtOffset));
+ int gmtOffset = zone.getOffset(System.currentTimeMillis());
+ setKernelTimezone(mDescriptor, -(gmtOffset / 60000));
scheduleDateChangedEvent();
}
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 8ad9f91..2f6bbec 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1438,6 +1438,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
if (!teardown(otherNet)) {
loge("Network declined teardown request");
+ teardown(thisNet);
return;
}
}
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 1f2ac2b..8570e6e 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -1653,7 +1653,8 @@ class MountService extends IMountService.Stub implements INativeDaemonConnectorC
} catch (NativeDaemonConnectorException e) {
int code = e.getCode();
if (code == VoldResponseCode.OpFailedStorageNotFound) {
- throw new IllegalArgumentException(String.format("Container '%s' not found", id));
+ Slog.i(TAG, String.format("Container '%s' not found", id));
+ return null;
} else {
throw new IllegalStateException(String.format("Unexpected response code %d", code));
}
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 9a5d0be..1c4f780 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -993,7 +993,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
mConnector.doCommand(cmd);
} catch (NativeDaemonConnectorException e) {
throw new IllegalStateException(
- "Error communicating with native daemon to flush default interface", e);
+ "Error communicating with native deamon to flush default interface", e);
}
}
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index e738145..37b6611 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -483,6 +483,24 @@ public class NotificationManagerService extends INotificationManager.Stub
record = mToastQueue.get(index);
record.update(duration);
} else {
+ // Limit the number of toasts that any given package except the android
+ // package can enqueue. Prevents DOS attacks and deals with leaks.
+ if (!"android".equals(pkg)) {
+ int count = 0;
+ final int N = mToastQueue.size();
+ for (int i=0; i<N; i++) {
+ final ToastRecord r = mToastQueue.get(i);
+ if (r.pkg.equals(pkg)) {
+ count++;
+ if (count >= MAX_PACKAGE_NOTIFICATIONS) {
+ Slog.e(TAG, "Package has already posted " + count
+ + " toasts. Not showing more. Package=" + pkg);
+ return;
+ }
+ }
+ }
+ }
+
record = new ToastRecord(callingPid, pkg, callback, duration);
mToastQueue.add(record);
index = mToastQueue.size() - 1;
diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java
index 2fcdb5d..de25747 100755
--- a/services/java/com/android/server/VibratorService.java
+++ b/services/java/com/android/server/VibratorService.java
@@ -247,6 +247,7 @@ public class VibratorService extends IVibratorService.Stub {
// Lock held on mVibrations
private void startNextVibrationLocked() {
if (mVibrations.size() <= 0) {
+ mCurrentVibration = null;
return;
}
mCurrentVibration = mVibrations.getFirst();
@@ -273,17 +274,27 @@ public class VibratorService extends IVibratorService.Stub {
Vibration vib = iter.next();
if (vib.mToken == token) {
iter.remove();
+ unlinkVibration(vib);
return vib;
}
}
// We might be looking for a simple vibration which is only stored in
// mCurrentVibration.
if (mCurrentVibration != null && mCurrentVibration.mToken == token) {
+ unlinkVibration(mCurrentVibration);
return mCurrentVibration;
}
return null;
}
+ private void unlinkVibration(Vibration vib) {
+ if (vib.mPattern != null) {
+ // If Vibration object has a pattern,
+ // the Vibration object has also been linkedToDeath.
+ vib.mToken.unlinkToDeath(vib, 0);
+ }
+ }
+
private class VibrateThread extends Thread {
final Vibration mVibration;
boolean mDone;
@@ -360,6 +371,7 @@ public class VibratorService extends IVibratorService.Stub {
// If this vibration finished naturally, start the next
// vibration.
mVibrations.remove(mVibration);
+ unlinkVibration(mVibration);
startNextVibrationLocked();
}
}
@@ -371,6 +383,12 @@ public class VibratorService extends IVibratorService.Stub {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
synchronized (mVibrations) {
doCancelVibrateLocked();
+
+ int size = mVibrations.size();
+ for(int i = 0; i < size; i++) {
+ unlinkVibration(mVibrations.get(i));
+ }
+
mVibrations.clear();
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 01bd7a9..67dc862 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -7049,8 +7049,9 @@ public final class ActivityManagerService extends ActivityManagerNative
addErrorToDropBox("wtf", r, null, null, tag, null, null, crashInfo);
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.WTF_IS_FATAL, 0) != 0) {
+ if (r != null && r.pid != Process.myPid() &&
+ Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.WTF_IS_FATAL, 0) != 0) {
crashApplication(r, crashInfo);
return true;
} else {
@@ -7090,18 +7091,25 @@ public final class ActivityManagerService extends ActivityManagerNative
* to append various headers to the dropbox log text.
*/
private void appendDropBoxProcessHeaders(ProcessRecord process, StringBuilder sb) {
+ // Watchdog thread ends up invoking this function (with
+ // a null ProcessRecord) to add the stack file to dropbox.
+ // Do not acquire a lock on this (am) in such cases, as it
+ // could cause a potential deadlock, if and when watchdog
+ // is invoked due to unavailability of lock on am and it
+ // would prevent watchdog from killing system_server.
+ if (process == null) {
+ sb.append("Process: system_server\n");
+ return;
+ }
// Note: ProcessRecord 'process' is guarded by the service
// instance. (notably process.pkgList, which could otherwise change
// concurrently during execution of this method)
synchronized (this) {
- if (process == null || process.pid == MY_PID) {
+ if (process.pid == MY_PID) {
sb.append("Process: system_server\n");
} else {
sb.append("Process: ").append(process.processName).append("\n");
}
- if (process == null) {
- return;
- }
int flags = process.info.flags;
IPackageManager pm = AppGlobals.getPackageManager();
sb.append("Flags: 0x").append(Integer.toString(flags, 16)).append("\n");
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index f3a2a62..67e73f5 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -47,30 +47,25 @@ import android.os.SystemClock;
import android.os.WorkSource;
import android.provider.Settings;
import android.provider.Telephony.Sms.Intents;
+import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
-import android.telephony.SmsMessage;
import android.util.Log;
import android.util.SparseIntArray;
import com.android.internal.app.IBatteryStats;
-import com.android.internal.telephony.Phone;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
-import com.android.internal.telephony.GsmAlphabet;
-import com.android.internal.telephony.SmsHeader;
-import com.android.internal.util.HexDump;
+import com.android.internal.telephony.Phone;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringBufferInputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Properties;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.concurrent.CountDownLatch;
/**
@@ -203,7 +198,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
// flags to trigger NTP or XTRA data download when network becomes available
// initialized to true so we do NTP and XTRA when the network comes up after booting
private boolean mInjectNtpTimePending = true;
- private boolean mDownloadXtraDataPending = false;
+ private boolean mDownloadXtraDataPending = true;
// true if GPS is navigating
private boolean mNavigating;