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.java14
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java4
-rw-r--r--services/java/com/android/server/NetworkManagementService.java6
-rw-r--r--services/java/com/android/server/NetworkTimeUpdateService.java51
-rw-r--r--services/java/com/android/server/SerialService.java7
-rw-r--r--services/java/com/android/server/WifiService.java52
-rw-r--r--services/java/com/android/server/accessibility/AccessibilityManagerService.java64
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java4
-rw-r--r--services/java/com/android/server/am/ActivityStack.java12
-rw-r--r--services/java/com/android/server/display/LocalDisplayAdapter.java57
-rw-r--r--services/java/com/android/server/location/GpsLocationProvider.java13
-rw-r--r--services/java/com/android/server/power/RampAnimator.java18
-rw-r--r--services/java/com/android/server/wm/AppWindowAnimator.java4
-rw-r--r--services/java/com/android/server/wm/AppWindowToken.java3
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java65
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java9
16 files changed, 283 insertions, 100 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index a7c4d73..4c22ae8 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -2524,19 +2524,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
SystemProperties.set(key, "");
}
mNumDnsEntries = last;
+ if (SystemProperties.get("net.dns.search").equals(domains) == false) {
+ SystemProperties.set("net.dns.search", domains);
+ changed = true;
+ }
if (changed) {
try {
- mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses));
+ mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses), domains);
mNetd.setDefaultInterfaceForDns(iface);
} catch (Exception e) {
if (DBG) loge("exception setting default dns interface: " + e);
}
}
- if (!domains.equals(SystemProperties.get("net.dns.search"))) {
- SystemProperties.set("net.dns.search", domains);
- changed = true;
- }
return changed;
}
@@ -2552,13 +2552,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
String network = nt.getNetworkInfo().getTypeName();
synchronized (mDnsLock) {
if (!mDnsOverridden) {
- changed = updateDns(network, p.getInterfaceName(), dnses, "");
+ changed = updateDns(network, p.getInterfaceName(), dnses, p.getDomains());
}
}
} else {
try {
mNetd.setDnsServersForInterface(p.getInterfaceName(),
- NetworkUtils.makeStrings(dnses));
+ NetworkUtils.makeStrings(dnses), p.getDomains());
} catch (Exception e) {
if (DBG) loge("exception setting dns servers: " + e);
}
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 8eb532d..3b60526 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -2668,6 +2668,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
InputMethodInfo im = mIms[which];
int subtypeId = mSubtypeIds[which];
+ adapter.mCheckedItem = which;
+ adapter.notifyDataSetChanged();
hideInputMethodMenu();
if (im != null) {
if ((subtypeId < 0)
@@ -2765,7 +2767,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
private final LayoutInflater mInflater;
private final int mTextViewResourceId;
private final List<ImeSubtypeListItem> mItemsList;
- private final int mCheckedItem;
+ public int mCheckedItem;
public ImeSubtypeListAdapter(Context context, int textViewResourceId,
List<ImeSubtypeListItem> itemsList, int checkedItem) {
super(context, textViewResourceId, itemsList);
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 3ddae3e..9ce02e3 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -1398,10 +1398,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void setDnsServersForInterface(String iface, String[] servers) {
+ public void setDnsServersForInterface(String iface, String[] servers, String domains) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- final Command cmd = new Command("resolver", "setifdns", iface);
+ final Command cmd = new Command("resolver", "setifdns", iface,
+ (domains == null ? "" : domains));
+
for (String s : servers) {
InetAddress a = NetworkUtils.numericToInetAddress(s);
if (a.isAnyLocalAddress() == false) {
diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java
index 790be55..3bfd190 100644
--- a/services/java/com/android/server/NetworkTimeUpdateService.java
+++ b/services/java/com/android/server/NetworkTimeUpdateService.java
@@ -57,15 +57,6 @@ public class NetworkTimeUpdateService {
private static final int EVENT_POLL_NETWORK_TIME = 2;
private static final int EVENT_NETWORK_CONNECTED = 3;
- /** Normal polling frequency */
- private static final long POLLING_INTERVAL_MS = 24L * 60 * 60 * 1000; // 24 hrs
- /** Try-again polling interval, in case the network request failed */
- private static final long POLLING_INTERVAL_SHORTER_MS = 60 * 1000L; // 60 seconds
- /** Number of times to try again */
- private static final int TRY_AGAIN_TIMES_MAX = 3;
- /** If the time difference is greater than this threshold, then update the time. */
- private static final int TIME_ERROR_THRESHOLD_MS = 5 * 1000;
-
private static final String ACTION_POLL =
"com.android.server.NetworkTimeUpdateService.action.POLL";
private static int POLL_REQUEST = 0;
@@ -86,6 +77,15 @@ public class NetworkTimeUpdateService {
private SettingsObserver mSettingsObserver;
// The last time that we successfully fetched the NTP time.
private long mLastNtpFetchTime = NOT_SET;
+
+ // Normal polling frequency
+ private final long mPollingIntervalMs;
+ // Try-again polling interval, in case the network request failed
+ private final long mPollingIntervalShorterMs;
+ // Number of times to try again
+ private final int mTryAgainTimesMax;
+ // If the time difference is greater than this threshold, then update the time.
+ private final int mTimeErrorThresholdMs;
// Keeps track of how many quick attempts were made to fetch NTP time.
// During bootup, the network may not have been up yet, or it's taking time for the
// connection to happen.
@@ -97,6 +97,15 @@ public class NetworkTimeUpdateService {
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
Intent pollIntent = new Intent(ACTION_POLL, null);
mPendingPollIntent = PendingIntent.getBroadcast(mContext, POLL_REQUEST, pollIntent, 0);
+
+ mPollingIntervalMs = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_ntpPollingInterval);
+ mPollingIntervalShorterMs = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_ntpPollingIntervalShorter);
+ mTryAgainTimesMax = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_ntpRetry);
+ mTimeErrorThresholdMs = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_ntpThreshold);
}
/** Initialize the receivers and initiate the first NTP request */
@@ -143,35 +152,35 @@ public class NetworkTimeUpdateService {
if (!isAutomaticTimeRequested()) return;
final long refTime = SystemClock.elapsedRealtime();
- // If NITZ time was received less than POLLING_INTERVAL_MS time ago,
+ // If NITZ time was received less than mPollingIntervalMs time ago,
// no need to sync to NTP.
- if (mNitzTimeSetTime != NOT_SET && refTime - mNitzTimeSetTime < POLLING_INTERVAL_MS) {
- resetAlarm(POLLING_INTERVAL_MS);
+ if (mNitzTimeSetTime != NOT_SET && refTime - mNitzTimeSetTime < mPollingIntervalMs) {
+ resetAlarm(mPollingIntervalMs);
return;
}
final long currentTime = System.currentTimeMillis();
if (DBG) Log.d(TAG, "System time = " + currentTime);
// Get the NTP time
- if (mLastNtpFetchTime == NOT_SET || refTime >= mLastNtpFetchTime + POLLING_INTERVAL_MS
+ if (mLastNtpFetchTime == NOT_SET || refTime >= mLastNtpFetchTime + mPollingIntervalMs
|| event == EVENT_AUTO_TIME_CHANGED) {
if (DBG) Log.d(TAG, "Before Ntp fetch");
// force refresh NTP cache when outdated
- if (mTime.getCacheAge() >= POLLING_INTERVAL_MS) {
+ if (mTime.getCacheAge() >= mPollingIntervalMs) {
mTime.forceRefresh();
}
// only update when NTP time is fresh
- if (mTime.getCacheAge() < POLLING_INTERVAL_MS) {
+ if (mTime.getCacheAge() < mPollingIntervalMs) {
final long ntp = mTime.currentTimeMillis();
mTryAgainCounter = 0;
// If the clock is more than N seconds off or this is the first time it's been
// fetched since boot, set the current time.
- if (Math.abs(ntp - currentTime) > TIME_ERROR_THRESHOLD_MS
+ if (Math.abs(ntp - currentTime) > mTimeErrorThresholdMs
|| mLastNtpFetchTime == NOT_SET) {
// Set the system time
if (DBG && mLastNtpFetchTime == NOT_SET
- && Math.abs(ntp - currentTime) <= TIME_ERROR_THRESHOLD_MS) {
+ && Math.abs(ntp - currentTime) <= mTimeErrorThresholdMs) {
Log.d(TAG, "For initial setup, rtc = " + currentTime);
}
if (DBG) Log.d(TAG, "Ntp time to be set = " + ntp);
@@ -186,17 +195,17 @@ public class NetworkTimeUpdateService {
} else {
// Try again shortly
mTryAgainCounter++;
- if (mTryAgainCounter <= TRY_AGAIN_TIMES_MAX) {
- resetAlarm(POLLING_INTERVAL_SHORTER_MS);
+ if (mTryAgainTimesMax < 0 || mTryAgainCounter <= mTryAgainTimesMax) {
+ resetAlarm(mPollingIntervalShorterMs);
} else {
// Try much later
mTryAgainCounter = 0;
- resetAlarm(POLLING_INTERVAL_MS);
+ resetAlarm(mPollingIntervalMs);
}
return;
}
}
- resetAlarm(POLLING_INTERVAL_MS);
+ resetAlarm(mPollingIntervalMs);
}
/**
diff --git a/services/java/com/android/server/SerialService.java b/services/java/com/android/server/SerialService.java
index 5d2b2a0..1abe458 100644
--- a/services/java/com/android/server/SerialService.java
+++ b/services/java/com/android/server/SerialService.java
@@ -51,7 +51,12 @@ public class SerialService extends ISerialManager.Stub {
public ParcelFileDescriptor openSerialPort(String path) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SERIAL_PORT, null);
- return native_open(path);
+ for (int i = 0; i < mSerialPorts.length; i++) {
+ if (mSerialPorts[i].equals(path)) {
+ return native_open(path);
+ }
+ }
+ throw new IllegalArgumentException("Invalid serial port " + path);
}
private native ParcelFileDescriptor native_open(String path);
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 98794c9..2da951e 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -43,9 +43,14 @@ import android.net.wifi.WpsInfo;
import android.net.wifi.WpsResult;
import android.net.ConnectivityManager;
import android.net.DhcpInfo;
+import android.net.DhcpResults;
+import android.net.LinkAddress;
+import android.net.LinkProperties;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.NetworkInfo.DetailedState;
+import android.net.NetworkUtils;
+import android.net.RouteInfo;
import android.net.TrafficStats;
import android.os.Binder;
import android.os.Handler;
@@ -64,6 +69,8 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
+import java.net.InetAddress;
+import java.net.Inet4Address;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -923,10 +930,53 @@ public class WifiService extends IWifiManager.Stub {
* Return the DHCP-assigned addresses from the last successful DHCP request,
* if any.
* @return the DHCP information
+ * @deprecated
*/
public DhcpInfo getDhcpInfo() {
enforceAccessPermission();
- return mWifiStateMachine.syncGetDhcpInfo();
+ DhcpResults dhcpResults = mWifiStateMachine.syncGetDhcpResults();
+ if (dhcpResults.linkProperties == null) return null;
+
+ DhcpInfo info = new DhcpInfo();
+ for (LinkAddress la : dhcpResults.linkProperties.getLinkAddresses()) {
+ InetAddress addr = la.getAddress();
+ if (addr instanceof Inet4Address) {
+ info.ipAddress = NetworkUtils.inetAddressToInt((Inet4Address)addr);
+ break;
+ }
+ }
+ for (RouteInfo r : dhcpResults.linkProperties.getRoutes()) {
+ if (r.isDefaultRoute()) {
+ InetAddress gateway = r.getGateway();
+ if (gateway instanceof Inet4Address) {
+ info.gateway = NetworkUtils.inetAddressToInt((Inet4Address)gateway);
+ }
+ } else if (r.isHostRoute()) {
+ LinkAddress dest = r.getDestination();
+ if (dest.getAddress() instanceof Inet4Address) {
+ info.netmask = NetworkUtils.prefixLengthToNetmaskInt(
+ dest.getNetworkPrefixLength());
+ }
+ }
+ }
+ int dnsFound = 0;
+ for (InetAddress dns : dhcpResults.linkProperties.getDnses()) {
+ if (dns instanceof Inet4Address) {
+ if (dnsFound == 0) {
+ info.dns1 = NetworkUtils.inetAddressToInt((Inet4Address)dns);
+ } else {
+ info.dns2 = NetworkUtils.inetAddressToInt((Inet4Address)dns);
+ }
+ if (++dnsFound > 1) break;
+ }
+ }
+ InetAddress serverAddress = dhcpResults.serverAddress;
+ if (serverAddress instanceof Inet4Address) {
+ info.serverAddress = NetworkUtils.inetAddressToInt((Inet4Address)serverAddress);
+ }
+ info.leaseDuration = dhcpResults.leaseDuration;
+
+ return info;
}
/**
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 671cbfe..65bfa7e 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -87,7 +87,9 @@ import com.android.internal.statusbar.IStatusBarService;
import org.xmlpull.v1.XmlPullParserException;
+import java.io.FileDescriptor;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -122,6 +124,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
private static final String TEMPORARY_ENABLE_ACCESSIBILITY_UNTIL_KEYGUARD_REMOVED =
"temporaryEnableAccessibilityStateUntilKeyguardRemoved";
+ private static final String FUNCTION_DUMP = "dump";
+
private static final char COMPONENT_NAME_SEPARATOR = ':';
private static final int OWN_PROCESS_ID = android.os.Process.myPid();
@@ -1258,6 +1262,46 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
}
}
+ @Override
+ public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
+ mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP);
+ synchronized (mLock) {
+ pw.println("ACCESSIBILITY MANAGER (dumpsys accessibility)");
+ pw.println();
+ pw.println("Ui automation service: bound=" + (mUiAutomationService != null));
+ pw.println();
+ if (mUiAutomationService != null) {
+ mUiAutomationService.dump(fd, pw, args);
+ pw.println();
+ }
+ final int userCount = mUserStates.size();
+ for (int i = 0; i < userCount; i++) {
+ UserState userState = mUserStates.valueAt(i);
+ pw.append("User state[attributes:{id=" + userState.mUserId);
+ pw.append(", currentUser=" + (userState.mUserId == mCurrentUserId));
+ pw.append(", accessibilityEnabled=" + userState.mIsAccessibilityEnabled);
+ pw.append(", touchExplorationEnabled=" + userState.mIsTouchExplorationEnabled);
+ pw.append(", displayMagnificationEnabled="
+ + userState.mIsDisplayMagnificationEnabled);
+ pw.append("}");
+ pw.println();
+ pw.append(" services:{");
+ final int serviceCount = userState.mServices.size();
+ for (int j = 0; j < serviceCount; j++) {
+ if (j > 0) {
+ pw.append(", ");
+ pw.println();
+ pw.append(" ");
+ }
+ Service service = userState.mServices.get(j);
+ service.dump(fd, pw, args);
+ }
+ pw.println("}]");
+ pw.println();
+ }
+ }
+ }
+
private class AccessibilityConnectionWrapper implements DeathRecipient {
private final int mWindowId;
private final int mUserId;
@@ -1894,6 +1938,23 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
}
}
+ @Override
+ public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
+ mSecurityPolicy.enforceCallingPermission(Manifest.permission.DUMP, FUNCTION_DUMP);
+ synchronized (mLock) {
+ pw.append("Service[label=" + mAccessibilityServiceInfo.getResolveInfo()
+ .loadLabel(mContext.getPackageManager()));
+ pw.append(", feedbackType"
+ + AccessibilityServiceInfo.feedbackTypeToString(mFeedbackType));
+ pw.append(", canRetrieveScreenContent=" + mCanRetrieveScreenContent);
+ pw.append(", eventTypes="
+ + AccessibilityEvent.eventTypeToString(mEventTypes));
+ pw.append(", notificationTimeout=" + mNotificationTimeout);
+ pw.append("]");
+ }
+ }
+
+ @Override
public void onServiceDisconnected(ComponentName componentName) {
/* do nothing - #binderDied takes care */
}
@@ -2313,7 +2374,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
}
if (!hasPermission(permission)) {
throw new SecurityException("You do not have " + permission
- + " required to call " + function);
+ + " required to call " + function + " from pid="
+ + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 82c9030..271ebb5 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -1423,7 +1423,7 @@ public final class ActivityManagerService extends ActivityManagerNative
context.setTheme(android.R.style.Theme_Holo);
m.mContext = context;
m.mFactoryTest = factoryTest;
- m.mMainStack = new ActivityStack(m, context, true);
+ m.mMainStack = new ActivityStack(m, context, true, thr.mLooper);
m.mBatteryStatsService.publish(context);
m.mUsageStatsService.publish(context);
@@ -1444,6 +1444,7 @@ public final class ActivityManagerService extends ActivityManagerNative
static class AThread extends Thread {
ActivityManagerService mService;
+ Looper mLooper;
boolean mReady = false;
public AThread() {
@@ -1461,6 +1462,7 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized (this) {
mService = m;
+ mLooper = Looper.myLooper();
notifyAll();
}
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 4546dc3..b007bc8 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -49,6 +49,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
@@ -306,11 +307,17 @@ final class ActivityStack {
}
}
- final Handler mHandler = new Handler() {
+ final Handler mHandler;
+
+ final class ActivityStackHandler extends Handler {
//public Handler() {
// if (localLOGV) Slog.v(TAG, "Handler started!");
//}
+ public ActivityStackHandler(Looper looper) {
+ super(looper);
+ }
+ @Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SLEEP_TIMEOUT_MSG: {
@@ -410,7 +417,8 @@ final class ActivityStack {
}
};
- ActivityStack(ActivityManagerService service, Context context, boolean mainStack) {
+ ActivityStack(ActivityManagerService service, Context context, boolean mainStack, Looper looper) {
+ mHandler = new ActivityStackHandler(looper);
mService = service;
mContext = context;
mMainStack = mainStack;
diff --git a/services/java/com/android/server/display/LocalDisplayAdapter.java b/services/java/com/android/server/display/LocalDisplayAdapter.java
index b37d57f..ee2d617 100644
--- a/services/java/com/android/server/display/LocalDisplayAdapter.java
+++ b/services/java/com/android/server/display/LocalDisplayAdapter.java
@@ -60,31 +60,38 @@ final class LocalDisplayAdapter extends DisplayAdapter {
super.registerLocked();
mHotplugReceiver = new HotplugDisplayEventReceiver(getHandler().getLooper());
- scanDisplaysLocked();
- }
- private void scanDisplaysLocked() {
for (int builtInDisplayId : BUILT_IN_DISPLAY_IDS_TO_SCAN) {
- IBinder displayToken = Surface.getBuiltInDisplay(builtInDisplayId);
- if (displayToken != null && Surface.getDisplayInfo(displayToken, mTempPhys)) {
- LocalDisplayDevice device = mDevices.get(builtInDisplayId);
- if (device == null) {
- // Display was added.
- device = new LocalDisplayDevice(displayToken, builtInDisplayId, mTempPhys);
- mDevices.put(builtInDisplayId, device);
- sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
- } else if (device.updatePhysicalDisplayInfoLocked(mTempPhys)) {
- // Display properties changed.
- sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
- }
- } else {
- LocalDisplayDevice device = mDevices.get(builtInDisplayId);
- if (device != null) {
- // Display was removed.
- mDevices.remove(builtInDisplayId);
- sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED);
- }
+ tryConnectDisplayLocked(builtInDisplayId);
+ }
+ }
+
+ private void tryConnectDisplayLocked(int builtInDisplayId) {
+ IBinder displayToken = Surface.getBuiltInDisplay(builtInDisplayId);
+ if (displayToken != null && Surface.getDisplayInfo(displayToken, mTempPhys)) {
+ LocalDisplayDevice device = mDevices.get(builtInDisplayId);
+ if (device == null) {
+ // Display was added.
+ device = new LocalDisplayDevice(displayToken, builtInDisplayId, mTempPhys);
+ mDevices.put(builtInDisplayId, device);
+ sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
+ } else if (device.updatePhysicalDisplayInfoLocked(mTempPhys)) {
+ // Display properties changed.
+ sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
}
+ } else {
+ // The display is no longer available. Ignore the attempt to add it.
+ // If it was connected but has already been disconnected, we'll get a
+ // disconnect event that will remove it from mDevices.
+ }
+ }
+
+ private void tryDisconnectDisplayLocked(int builtInDisplayId) {
+ LocalDisplayDevice device = mDevices.get(builtInDisplayId);
+ if (device != null) {
+ // Display was removed.
+ mDevices.remove(builtInDisplayId);
+ sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED);
}
}
@@ -191,7 +198,11 @@ final class LocalDisplayAdapter extends DisplayAdapter {
@Override
public void onHotplug(long timestampNanos, int builtInDisplayId, boolean connected) {
synchronized (getSyncRoot()) {
- scanDisplaysLocked();
+ if (connected) {
+ tryConnectDisplayLocked(builtInDisplayId);
+ } else {
+ tryDisconnectDisplayLocked(builtInDisplayId);
+ }
}
}
}
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index c272da4..efba10d 100644
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -1452,11 +1452,11 @@ public class GpsLocationProvider implements LocationProviderInterface {
private void requestRefLocation(int flags) {
TelephonyManager phone = (TelephonyManager)
mContext.getSystemService(Context.TELEPHONY_SERVICE);
- if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
+ final int phoneType = phone.getPhoneType();
+ if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
GsmCellLocation gsm_cell = (GsmCellLocation) phone.getCellLocation();
- if ((gsm_cell != null) && (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) &&
- (phone.getNetworkOperator() != null) &&
- (phone.getNetworkOperator().length() > 3)) {
+ if ((gsm_cell != null) && (phone.getNetworkOperator() != null)
+ && (phone.getNetworkOperator().length() > 3)) {
int type;
int mcc = Integer.parseInt(phone.getNetworkOperator().substring(0,3));
int mnc = Integer.parseInt(phone.getNetworkOperator().substring(3));
@@ -1474,9 +1474,8 @@ public class GpsLocationProvider implements LocationProviderInterface {
} else {
Log.e(TAG,"Error getting cell location info.");
}
- }
- else {
- Log.e(TAG,"CDMA not supported.");
+ } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
+ Log.e(TAG, "CDMA not supported.");
}
}
diff --git a/services/java/com/android/server/power/RampAnimator.java b/services/java/com/android/server/power/RampAnimator.java
index 6f063c3..4a4f080 100644
--- a/services/java/com/android/server/power/RampAnimator.java
+++ b/services/java/com/android/server/power/RampAnimator.java
@@ -102,20 +102,26 @@ final class RampAnimator<T> {
final long frameTimeNanos = mChoreographer.getFrameTimeNanos();
final float timeDelta = (frameTimeNanos - mLastFrameTimeNanos)
* 0.000000001f;
- final float amount = timeDelta * mRate / ValueAnimator.getDurationScale();
mLastFrameTimeNanos = frameTimeNanos;
// Advance the animated value towards the target at the specified rate
// and clamp to the target. This gives us the new current value but
// we keep the animated value around to allow for fractional increments
// towards the target.
- int oldCurrentValue = mCurrentValue;
- if (mTargetValue > mCurrentValue) {
- mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
+ final float scale = ValueAnimator.getDurationScale();
+ if (scale == 0) {
+ // Animation off.
+ mAnimatedValue = mTargetValue;
} else {
- mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
+ final float amount = timeDelta * mRate / scale;
+ if (mTargetValue > mCurrentValue) {
+ mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
+ } else {
+ mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
+ }
}
- mCurrentValue = (int)Math.round(mAnimatedValue);
+ final int oldCurrentValue = mCurrentValue;
+ mCurrentValue = Math.round(mAnimatedValue);
if (oldCurrentValue != mCurrentValue) {
mProperty.setValue(mObject, mCurrentValue);
diff --git a/services/java/com/android/server/wm/AppWindowAnimator.java b/services/java/com/android/server/wm/AppWindowAnimator.java
index ca94d04..e044c6d 100644
--- a/services/java/com/android/server/wm/AppWindowAnimator.java
+++ b/services/java/com/android/server/wm/AppWindowAnimator.java
@@ -100,6 +100,10 @@ public class AppWindowAnimator {
animInitialized = false;
}
clearThumbnail();
+ if (mAppToken.deferClearAllDrawn) {
+ mAppToken.allDrawn = false;
+ mAppToken.deferClearAllDrawn = false;
+ }
}
public void clearThumbnail() {
diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java
index 7efffe5..3ec6d26 100644
--- a/services/java/com/android/server/wm/AppWindowToken.java
+++ b/services/java/com/android/server/wm/AppWindowToken.java
@@ -64,6 +64,9 @@ class AppWindowToken extends WindowToken {
int numDrawnWindows;
boolean inPendingTransaction;
boolean allDrawn;
+ // Set to true when this app creates a surface while in the middle of an animation. In that
+ // case do not clear allDrawn until the animation completes.
+ boolean deferClearAllDrawn;
// Is this token going to be hidden in a little while? If so, it
// won't be taken into account for setting the screen orientation.
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c3fc19c..a838fa8 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -821,7 +821,7 @@ public class WindowManagerService extends IWindowManager.Stub
mTransitionAnimationScale = Settings.Global.getFloat(context.getContentResolver(),
Settings.Global.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
setAnimatorDurationScale(Settings.Global.getFloat(context.getContentResolver(),
- Settings.Global.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale));
+ Settings.Global.ANIMATOR_DURATION_SCALE, mAnimatorDurationScale));
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
@@ -4296,6 +4296,7 @@ public class WindowManagerService extends IWindowManager.Stub
// the new one.
if (ttoken.allDrawn) {
wtoken.allDrawn = true;
+ wtoken.deferClearAllDrawn = ttoken.deferClearAllDrawn;
}
if (ttoken.firstWindowDrawn) {
wtoken.firstWindowDrawn = true;
@@ -4426,6 +4427,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ @Override
public void setAppWillBeHidden(IBinder token) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppWillBeHidden()")) {
@@ -4549,6 +4551,7 @@ public class WindowManagerService extends IWindowManager.Stub
return delayed;
}
+ @Override
public void setAppVisibility(IBinder token, boolean visible) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppVisibility()")) {
@@ -4603,6 +4606,7 @@ public class WindowManagerService extends IWindowManager.Stub
// its windows to be ready.
if (wtoken.hidden) {
wtoken.allDrawn = false;
+ wtoken.deferClearAllDrawn = false;
wtoken.waitingToShow = true;
if (wtoken.clientHidden) {
@@ -4701,6 +4705,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ @Override
public void startAppFreezingScreen(IBinder token, int configChanges) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppFreezingScreen()")) {
@@ -4724,6 +4729,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ @Override
public void stopAppFreezingScreen(IBinder token, boolean force) {
if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
"setAppFreezingScreen()")) {
@@ -5584,7 +5590,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (!mSystemBooted && !haveBootMsg) {
return;
}
-
+
// If we are turning on the screen after the boot is completed
// normally, don't do so until we have the application and
// wallpaper.
@@ -5734,7 +5740,7 @@ public class WindowManagerService extends IWindowManager.Stub
* Takes a snapshot of the screen. In landscape mode this grabs the whole screen.
* In portrait mode, it grabs the upper region of the screen based on the vertical dimension
* of the target image.
- *
+ *
* @param displayId the Display to take a screenshot of.
* @param width the width of the target bitmap
* @param height the height of the target bitmap
@@ -5809,7 +5815,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (maxLayer < ws.mWinAnimator.mSurfaceLayer) {
maxLayer = ws.mWinAnimator.mSurfaceLayer;
}
-
+
// Don't include wallpaper in bounds calculation
if (!ws.mIsWallpaper) {
final Rect wf = ws.mFrame;
@@ -8363,7 +8369,7 @@ public class WindowManagerService extends IWindowManager.Stub
// soon won't be visible, to avoid wasting time and funky
// changes while a window is animating away.
final boolean gone = (behindDream && mPolicy.canBeForceHidden(win, win.mAttrs))
- || win.isGoneForLayoutLw();
+ || (win.isGoneForLayoutLw() && !win.isOnScreen());
if (DEBUG_LAYOUT && !win.mLayoutAttached) {
Slog.v(TAG, "1ST PASS " + win
@@ -8391,8 +8397,7 @@ public class WindowManagerService extends IWindowManager.Stub
// windows, since that means "perform layout as normal,
// just don't display").
if (!gone || !win.mHaveFrame || win.mLayoutNeeded
- || ((win.mAttrs.type == TYPE_KEYGUARD || win.mAttrs.type == TYPE_WALLPAPER) &&
- win.isConfigChanged())
+ || (win.mAttrs.type == TYPE_KEYGUARD && win.isConfigChanged())
|| win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
if (!win.mLayoutAttached) {
if (initial) {
@@ -8710,6 +8715,7 @@ public class WindowManagerService extends IWindowManager.Stub
// this guy's animations regardless of whether it's
// gotten drawn.
wtoken.allDrawn = true;
+ wtoken.deferClearAllDrawn = false;
}
if (mNextAppTransitionThumbnail != null && topOpeningApp != null
@@ -8880,6 +8886,7 @@ public class WindowManagerService extends IWindowManager.Stub
winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
if (w.mAppToken != null) {
w.mAppToken.allDrawn = false;
+ w.mAppToken.deferClearAllDrawn = false;
}
}
if (!mResizingWindows.contains(w)) {
@@ -8955,27 +8962,29 @@ public class WindowManagerService extends IWindowManager.Stub
// so we want to leave all of them as undimmed (for
// performance reasons).
mInnerFields.mObscured = true;
- } else if (canBeSeen && (attrFlags & FLAG_DIM_BEHIND) != 0
- && !(w.mAppToken != null && w.mAppToken.hiddenRequested)
+ }
+ }
+
+ private void handleFlagDimBehind(WindowState w, int innerDw, int innerDh) {
+ final WindowManager.LayoutParams attrs = w.mAttrs;
+ if ((attrs.flags & FLAG_DIM_BEHIND) != 0
+ && w.isDisplayedLw()
&& !w.mExiting) {
- if (localLOGV) Slog.v(TAG, "Win " + w + " obscured=" + mInnerFields.mObscured);
- if (!mInnerFields.mDimming) {
- //Slog.i(TAG, "DIM BEHIND: " + w);
- mInnerFields.mDimming = true;
- final WindowStateAnimator winAnimator = w.mWinAnimator;
- if (!mAnimator.isDimmingLocked(winAnimator)) {
- final int width, height;
- if (attrs.type == TYPE_BOOT_PROGRESS) {
- final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo();
- width = displayInfo.logicalWidth;
- height = displayInfo.logicalHeight;
- } else {
- width = innerDw;
- height = innerDh;
- }
- startDimmingLocked(
- winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height);
+ mInnerFields.mDimming = true;
+ final WindowStateAnimator winAnimator = w.mWinAnimator;
+ if (!mAnimator.isDimmingLocked(winAnimator)) {
+ final int width, height;
+ if (attrs.type == TYPE_BOOT_PROGRESS) {
+ final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo();
+ width = displayInfo.logicalWidth;
+ height = displayInfo.logicalHeight;
+ } else {
+ width = innerDw;
+ height = innerDh;
}
+ if (localLOGV) Slog.v(TAG, "Win " + w + " start dimming.");
+ startDimmingLocked(
+ winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height);
}
}
}
@@ -9154,6 +9163,10 @@ public class WindowManagerService extends IWindowManager.Stub
handleNotObscuredLocked(w, currentTime, innerDw, innerDh);
}
+ if (!mInnerFields.mDimming) {
+ handleFlagDimBehind(w, innerDw, innerDh);
+ }
+
if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w)
&& w.isVisibleLw()) {
// This is the wallpaper target and its obscured state
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index e33b7b7..c2178e4 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -626,7 +626,14 @@ class WindowStateAnimator {
"createSurface " + this + ": mDrawState=DRAW_PENDING");
mDrawState = DRAW_PENDING;
if (mWin.mAppToken != null) {
- mWin.mAppToken.allDrawn = false;
+ if (mWin.mAppToken.mAppAnimator.animation == null) {
+ mWin.mAppToken.allDrawn = false;
+ mWin.mAppToken.deferClearAllDrawn = false;
+ } else {
+ // Currently animating, persist current state of allDrawn until animation
+ // is complete.
+ mWin.mAppToken.deferClearAllDrawn = true;
+ }
}
mService.makeWindowFreezingScreenIfNeededLocked(mWin);