Merge "Tell each VM to flush their DNS cache."
This commit is contained in:
committed by
Android (Google) Code Review
commit
1678246710
@@ -85,6 +85,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -585,6 +586,11 @@ public final class ActivityThread {
|
||||
TimeZone.setDefault(null);
|
||||
}
|
||||
|
||||
public void clearDnsCache() {
|
||||
// a non-standard API to get this to libcore
|
||||
InetAddress.clearDnsCache();
|
||||
}
|
||||
|
||||
public void processInBackground() {
|
||||
mH.removeMessages(H.GC_WHEN_IDLE);
|
||||
mH.sendMessage(mH.obtainMessage(H.GC_WHEN_IDLE));
|
||||
|
||||
@@ -291,6 +291,12 @@ public abstract class ApplicationThreadNative extends Binder
|
||||
return true;
|
||||
}
|
||||
|
||||
case CLEAR_DNS_CACHE_TRANSACTION: {
|
||||
data.enforceInterface(IApplicationThread.descriptor);
|
||||
clearDnsCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
case PROCESS_IN_BACKGROUND_TRANSACTION: {
|
||||
data.enforceInterface(IApplicationThread.descriptor);
|
||||
processInBackground();
|
||||
@@ -744,6 +750,14 @@ class ApplicationThreadProxy implements IApplicationThread {
|
||||
data.recycle();
|
||||
}
|
||||
|
||||
public void clearDnsCache() throws RemoteException {
|
||||
Parcel data = Parcel.obtain();
|
||||
data.writeInterfaceToken(IApplicationThread.descriptor);
|
||||
mRemote.transact(CLEAR_DNS_CACHE_TRANSACTION, data, null,
|
||||
IBinder.FLAG_ONEWAY);
|
||||
data.recycle();
|
||||
}
|
||||
|
||||
public void processInBackground() throws RemoteException {
|
||||
Parcel data = Parcel.obtain();
|
||||
data.writeInterfaceToken(IApplicationThread.descriptor);
|
||||
@@ -884,4 +898,3 @@ class ApplicationThreadProxy implements IApplicationThread {
|
||||
data.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ public interface IApplicationThread extends IInterface {
|
||||
void requestThumbnail(IBinder token) throws RemoteException;
|
||||
void scheduleConfigurationChanged(Configuration config) throws RemoteException;
|
||||
void updateTimeZone() throws RemoteException;
|
||||
void clearDnsCache() throws RemoteException;
|
||||
void processInBackground() throws RemoteException;
|
||||
void dumpService(FileDescriptor fd, IBinder servicetoken, String[] args)
|
||||
throws RemoteException;
|
||||
@@ -146,4 +147,5 @@ public interface IApplicationThread extends IInterface {
|
||||
int SCHEDULE_CRASH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+34;
|
||||
int DUMP_HEAP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+35;
|
||||
int DUMP_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
|
||||
int CLEAR_DNS_CACHE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
|
||||
}
|
||||
|
||||
@@ -1222,6 +1222,13 @@ public class Intent implements Parcelable, Cloneable {
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
|
||||
/**
|
||||
* Clear DNS Cache Action: This is broadcast when networks have changed and old
|
||||
* DNS entries should be tossed.
|
||||
* @hide
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
|
||||
/**
|
||||
* Alarm Changed Action: This is broadcast when the AlarmClock
|
||||
* application's alarm is set or unset. It is used by the
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<protected-broadcast android:name="android.nfc.action.TAG_DISCOVERED" />
|
||||
<protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
|
||||
<protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" />
|
||||
<protected-broadcast android:name="android.intent.action.CLEAR_DNS_CACHE" />
|
||||
|
||||
<!-- ====================================== -->
|
||||
<!-- Permissions for things that cost money -->
|
||||
|
||||
@@ -1596,6 +1596,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
} catch (NumberFormatException e) {}
|
||||
}
|
||||
SystemProperties.set("net.dnschange", "" + (n+1));
|
||||
/*
|
||||
* Tell the VMs to toss their DNS caches
|
||||
*/
|
||||
Intent intent = new Intent(Intent.ACTION_CLEAR_DNS_CACHE);
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void handleDnsConfigurationChange(int netType) {
|
||||
|
||||
@@ -959,6 +959,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
static final int CANCEL_HEAVY_NOTIFICATION_MSG = 25;
|
||||
static final int SHOW_STRICT_MODE_VIOLATION_MSG = 26;
|
||||
static final int CHECK_EXCESSIVE_WAKE_LOCKS_MSG = 27;
|
||||
static final int CLEAR_DNS_CACHE = 28;
|
||||
|
||||
AlertDialog mUidAlert;
|
||||
|
||||
@@ -1110,6 +1111,20 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case CLEAR_DNS_CACHE: {
|
||||
synchronized (ActivityManagerService.this) {
|
||||
for (int i = mLruProcesses.size() - 1 ; i >= 0 ; i--) {
|
||||
ProcessRecord r = mLruProcesses.get(i);
|
||||
if (r.thread != null) {
|
||||
try {
|
||||
r.thread.clearDnsCache();
|
||||
} catch (RemoteException ex) {
|
||||
Slog.w(TAG, "Failed to clear dns cache for: " + r.info.processName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case SHOW_UID_ERROR_MSG: {
|
||||
// XXX This is a temporary dialog, no need to localize.
|
||||
AlertDialog d = new BaseErrorDialog(mContext);
|
||||
@@ -10373,6 +10388,10 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
mHandler.sendEmptyMessage(UPDATE_TIME_ZONE);
|
||||
}
|
||||
|
||||
if (intent.ACTION_CLEAR_DNS_CACHE.equals(intent.getAction())) {
|
||||
mHandler.sendEmptyMessage(CLEAR_DNS_CACHE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent non-system code (defined here to be non-persistent
|
||||
* processes) from sending protected broadcasts.
|
||||
|
||||
Reference in New Issue
Block a user