summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/ConnectivityService.java39
-rw-r--r--services/java/com/android/server/MountService.java26
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java53
3 files changed, 52 insertions, 66 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 72d249a..6dcb403 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -2256,26 +2256,27 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (resetMask != 0 || resetDns) {
LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties();
if (linkProperties != null) {
- String iface = linkProperties.getInterfaceName();
- if (TextUtils.isEmpty(iface) == false) {
- if (resetMask != 0) {
- if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")");
- NetworkUtils.resetConnections(iface, resetMask);
-
- // Tell VPN the interface is down. It is a temporary
- // but effective fix to make VPN aware of the change.
- if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) {
- mVpn.interfaceStatusChanged(iface, false);
+ for (String iface : linkProperties.getAllInterfaceNames()) {
+ if (TextUtils.isEmpty(iface) == false) {
+ if (resetMask != 0) {
+ if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")");
+ NetworkUtils.resetConnections(iface, resetMask);
+
+ // Tell VPN the interface is down. It is a temporary
+ // but effective fix to make VPN aware of the change.
+ if ((resetMask & NetworkUtils.RESET_IPV4_ADDRESSES) != 0) {
+ mVpn.interfaceStatusChanged(iface, false);
+ }
}
- }
- if (resetDns) {
- flushVmDnsCache();
- if (VDBG) log("resetting DNS cache for " + iface);
- try {
- mNetd.flushInterfaceDnsCache(iface);
- } catch (Exception e) {
- // never crash - catch them all
- if (DBG) loge("Exception resetting dns cache: " + e);
+ if (resetDns) {
+ flushVmDnsCache();
+ if (VDBG) log("resetting DNS cache for " + iface);
+ try {
+ mNetd.flushInterfaceDnsCache(iface);
+ } catch (Exception e) {
+ // never crash - catch them all
+ if (DBG) loge("Exception resetting dns cache: " + e);
+ }
}
}
}
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 2e0c977..c6aca2f 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -596,6 +596,26 @@ class MountService extends IMountService.Stub
}
};
+ private final BroadcastReceiver mIdleMaintenanceReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ waitForReady();
+ String action = intent.getAction();
+ // Since fstrim will be run on a daily basis we do not expect
+ // fstrim to be too long, so it is not interruptible. We will
+ // implement interruption only in case we see issues.
+ if (Intent.ACTION_IDLE_MAINTENANCE_START.equals(action)) {
+ try {
+ // This method runs on the handler thread,
+ // so it is safe to directly call into vold.
+ mConnector.execute("fstrim", "dotrim");
+ } catch (NativeDaemonConnectorException ndce) {
+ Slog.e(TAG, "Failed to run fstrim!");
+ }
+ }
+ }
+ };
+
private final class MountServiceBinderListener implements IBinder.DeathRecipient {
final IMountServiceListener mListener;
@@ -1301,6 +1321,12 @@ class MountService extends IMountService.Stub
mUsbReceiver, new IntentFilter(UsbManager.ACTION_USB_STATE), null, mHandler);
}
+ // Watch for idle maintenance changes
+ IntentFilter idleMaintenanceFilter = new IntentFilter();
+ idleMaintenanceFilter.addAction(Intent.ACTION_IDLE_MAINTENANCE_START);
+ mContext.registerReceiverAsUser(mIdleMaintenanceReceiver, UserHandle.ALL,
+ idleMaintenanceFilter, null, mHandler);
+
// Add OBB Action Handler to MountService thread.
mObbActionHandler = new ObbActionHandler(mHandlerThread.getLooper());
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 3ae652a..a82f421 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -63,13 +63,13 @@ import static android.telephony.TelephonyManager.SIM_STATE_READY;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static com.android.internal.util.ArrayUtils.appendInt;
import static com.android.internal.util.Preconditions.checkNotNull;
+import static com.android.internal.util.XmlUtils.readBooleanAttribute;
+import static com.android.internal.util.XmlUtils.readIntAttribute;
+import static com.android.internal.util.XmlUtils.readLongAttribute;
+import static com.android.internal.util.XmlUtils.writeBooleanAttribute;
+import static com.android.internal.util.XmlUtils.writeIntAttribute;
+import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.server.NetworkManagementService.LIMIT_GLOBAL_ALERT;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.readBooleanAttribute;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.readIntAttribute;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.readLongAttribute;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.writeBooleanAttribute;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.writeIntAttribute;
-import static com.android.server.net.NetworkPolicyManagerService.XmlUtils.writeLongAttribute;
import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_UPDATED;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
@@ -149,7 +149,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
-import java.net.ProtocolException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -2088,44 +2087,4 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
fout.print("]");
}
-
- public static class XmlUtils {
- public static int readIntAttribute(XmlPullParser in, String name) throws IOException {
- final String value = in.getAttributeValue(null, name);
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException e) {
- throw new ProtocolException("problem parsing " + name + "=" + value + " as int");
- }
- }
-
- public static void writeIntAttribute(XmlSerializer out, String name, int value)
- throws IOException {
- out.attribute(null, name, Integer.toString(value));
- }
-
- public static long readLongAttribute(XmlPullParser in, String name) throws IOException {
- final String value = in.getAttributeValue(null, name);
- try {
- return Long.parseLong(value);
- } catch (NumberFormatException e) {
- throw new ProtocolException("problem parsing " + name + "=" + value + " as long");
- }
- }
-
- public static void writeLongAttribute(XmlSerializer out, String name, long value)
- throws IOException {
- out.attribute(null, name, Long.toString(value));
- }
-
- public static boolean readBooleanAttribute(XmlPullParser in, String name) {
- final String value = in.getAttributeValue(null, name);
- return Boolean.parseBoolean(value);
- }
-
- public static void writeBooleanAttribute(XmlSerializer out, String name, boolean value)
- throws IOException {
- out.attribute(null, name, Boolean.toString(value));
- }
- }
}