summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java5
-rw-r--r--services/core/java/com/android/server/BluetoothManagerService.java31
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java40
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java7
-rw-r--r--services/core/java/com/android/server/am/ProcessList.java12
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java1
-rw-r--r--services/core/java/com/android/server/notification/ZenModeHelper.java45
-rw-r--r--services/core/java/com/android/server/wm/KeyguardDisableHandler.java45
8 files changed, 99 insertions, 87 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 89aebe8..63a0cf6 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -3421,7 +3421,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
return false;
}
- // Windows are ordered in z order so start from the botton and find
+ // Windows are ordered in z order so start from the bottom and find
// the window of interest. After that all windows that cover it should
// be subtracted from the resulting region. Note that for accessibility
// we are returning only interactive windows.
@@ -3439,7 +3439,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
windowInteractiveRegion = outRegion;
continue;
}
- } else {
+ } else if (currentWindow.getType()
+ != AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY) {
Rect currentWindowBounds = mTempRect;
currentWindow.getBoundsInScreen(currentWindowBounds);
if (windowInteractiveRegion.op(currentWindowBounds, Region.Op.DIFFERENCE)) {
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 3117a17..ca376fd 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -535,15 +535,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
Log.d(TAG, "Creating new ProfileServiceConnections object for"
+ " profile: " + bluetoothProfile);
}
- Intent intent = null;
- if (bluetoothProfile == BluetoothProfile.HEADSET) {
- intent = new Intent(IBluetoothHeadset.class.getName());
- } else {
- return false;
- }
+
+ if (bluetoothProfile != BluetoothProfile.HEADSET) return false;
+
+ Intent intent = new Intent(IBluetoothHeadset.class.getName());
psc = new ProfileServiceConnections(intent);
+ if (!psc.bindService()) return false;
+
mProfileServices.put(new Integer(bluetoothProfile), psc);
- psc.bindService();
}
}
@@ -571,7 +570,11 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
synchronized (mProfileServices) {
for (Integer i : mProfileServices.keySet()) {
ProfileServiceConnections psc = mProfileServices.get(i);
- mContext.unbindService(psc);
+ try {
+ mContext.unbindService(psc);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Unable to unbind service with intent: " + psc.mIntent, e);
+ }
psc.removeAllProxies();
}
mProfileServices.clear();
@@ -596,16 +599,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mIntent = intent;
}
- private void bindService() {
- if (mIntent != null && mService == null) {
- if (!doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) {
- Log.w(TAG, "Unable to bind with intent: " + mIntent
- + ". Triggering retry.");
- }
+ private boolean bindService() {
+ if (mIntent != null && mService == null &&
+ doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) {
Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);
msg.obj = this;
mHandler.sendMessageDelayed(msg, TIMEOUT_BIND_MS);
+ return true;
}
+ Log.w(TAG, "Unable to bind with intent: " + mIntent);
+ return false;
}
private void addProxy(IBluetoothProfileServiceConnection proxy) {
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index a86d564..e11fa93 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -782,17 +782,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
throw new IllegalStateException("No free netIds");
}
- private int getConnectivityChangeDelay() {
- final ContentResolver cr = mContext.getContentResolver();
-
- /** Check system properties for the default value then use secure settings value, if any. */
- int defaultDelay = SystemProperties.getInt(
- "conn." + Settings.Global.CONNECTIVITY_CHANGE_DELAY,
- ConnectivityManager.CONNECTIVITY_CHANGE_DELAY_DEFAULT);
- return Settings.Global.getInt(cr, Settings.Global.CONNECTIVITY_CHANGE_DELAY,
- defaultDelay);
- }
-
private boolean teardown(NetworkStateTracker netTracker) {
if (netTracker.teardown()) {
netTracker.setTeardownRequested(true);
@@ -1454,11 +1443,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
sendGeneralBroadcast(info, CONNECTIVITY_ACTION);
}
- private void sendConnectedBroadcastDelayed(NetworkInfo info, int delayMs) {
- sendGeneralBroadcast(info, CONNECTIVITY_ACTION_IMMEDIATE);
- sendGeneralBroadcastDelayed(info, CONNECTIVITY_ACTION, delayMs);
- }
-
private void sendInetConditionBroadcast(NetworkInfo info) {
sendGeneralBroadcast(info, ConnectivityManager.INET_CONDITION_ACTION);
}
@@ -1490,10 +1474,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
sendStickyBroadcast(makeGeneralIntent(info, bcastType));
}
- private void sendGeneralBroadcastDelayed(NetworkInfo info, String bcastType, int delayMs) {
- sendStickyBroadcastDelayed(makeGeneralIntent(info, bcastType), delayMs);
- }
-
private void sendDataActivityBroadcast(int deviceType, boolean active, long tsNanos) {
Intent intent = new Intent(ConnectivityManager.ACTION_DATA_ACTIVITY_CHANGE);
intent.putExtra(ConnectivityManager.EXTRA_DEVICE_TYPE, deviceType);
@@ -1538,19 +1518,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
- private void sendStickyBroadcastDelayed(Intent intent, int delayMs) {
- if (delayMs <= 0) {
- sendStickyBroadcast(intent);
- } else {
- if (VDBG) {
- log("sendStickyBroadcastDelayed: delayMs=" + delayMs + ", action="
- + intent.getAction());
- }
- mHandler.sendMessageDelayed(mHandler.obtainMessage(
- EVENT_SEND_STICKY_BROADCAST_INTENT, intent), delayMs);
- }
- }
-
void systemReady() {
// start network sampling ..
Intent intent = new Intent(ACTION_PKT_CNT_SAMPLE_INTERVAL_ELAPSED);
@@ -4331,7 +4298,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
info.setType(type);
if (connected) {
info.setDetailedState(DetailedState.CONNECTED, null, info.getExtraInfo());
- sendConnectedBroadcastDelayed(info, getConnectivityChangeDelay());
+ sendConnectedBroadcast(info);
} else {
info.setDetailedState(DetailedState.DISCONNECTED, null, info.getExtraInfo());
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
@@ -4362,10 +4329,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
final Intent immediateIntent = new Intent(intent);
immediateIntent.setAction(CONNECTIVITY_ACTION_IMMEDIATE);
sendStickyBroadcast(immediateIntent);
- sendStickyBroadcastDelayed(intent, getConnectivityChangeDelay());
+ sendStickyBroadcast(intent);
if (newDefaultAgent != null) {
- sendConnectedBroadcastDelayed(newDefaultAgent.networkInfo,
- getConnectivityChangeDelay());
+ sendConnectedBroadcast(newDefaultAgent.networkInfo);
}
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1227148..82afeed 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1841,7 +1841,9 @@ public final class ActivityManagerService extends ActivityManagerNative
proc = mPendingPssProcesses.remove(0);
procState = proc.pssProcState;
lastPssTime = proc.lastPssTime;
- if (proc.thread != null && procState == proc.setProcState) {
+ if (proc.thread != null && procState == proc.setProcState
+ && (lastPssTime+ProcessList.PSS_SAFE_TIME_FROM_STATE_CHANGE)
+ < SystemClock.uptimeMillis()) {
pid = proc.pid;
} else {
proc = null;
@@ -17746,7 +17748,8 @@ public final class ActivityManagerService extends ActivityManagerNative
+ (app.nextPssTime-now) + ": " + app);
} else {
if (now > app.nextPssTime || (now > (app.lastPssTime+ProcessList.PSS_MAX_INTERVAL)
- && now > (app.lastStateTime+ProcessList.PSS_MIN_TIME_FROM_STATE_CHANGE))) {
+ && now > (app.lastStateTime+ProcessList.minTimeFromStateChange(
+ mTestPssMode)))) {
requestPssLocked(app, app.setProcState);
app.nextPssTime = ProcessList.computeNextPssTime(app.curProcState, false,
mTestPssMode, isSleeping(), now);
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index d6b28d4..ae4af5f 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -411,7 +411,10 @@ final class ProcessList {
sb.append(ramKb);
}
- // The minimum amount of time after a state change it is safe ro collect PSS.
+ // How long after a state change that it is safe to collect PSS without it being dirty.
+ public static final int PSS_SAFE_TIME_FROM_STATE_CHANGE = 1000;
+
+ // The minimum time interval after a state change it is safe to collect PSS.
public static final int PSS_MIN_TIME_FROM_STATE_CHANGE = 15*1000;
// The maximum amount of time we want to go between PSS collections.
@@ -441,6 +444,9 @@ final class ProcessList {
// The amount of time until PSS when a cached process stays in the same state.
private static final int PSS_SAME_CACHED_INTERVAL = 30*60*1000;
+ // The minimum time interval after a state change it is safe to collect PSS.
+ public static final int PSS_TEST_MIN_TIME_FROM_STATE_CHANGE = 10*1000;
+
// The amount of time during testing until PSS when a process first becomes top.
private static final int PSS_TEST_FIRST_TOP_INTERVAL = 3*1000;
@@ -548,6 +554,10 @@ final class ProcessList {
return sProcStateToProcMem[procState1] != sProcStateToProcMem[procState2];
}
+ public static long minTimeFromStateChange(boolean test) {
+ return test ? PSS_TEST_MIN_TIME_FROM_STATE_CHANGE : PSS_MIN_TIME_FROM_STATE_CHANGE;
+ }
+
public static long computeNextPssTime(int procState, boolean first, boolean test,
boolean sleeping, long now) {
final long[] table = test
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index bb99916..650f0e2 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1028,6 +1028,7 @@ public class NotificationManagerService extends SystemService {
? mListenersDisablingEffects.valueAt(0).component : null;
if (Objects.equals(suppressor, mEffectsSuppressor)) return;
mEffectsSuppressor = suppressor;
+ mZenModeHelper.setEffectsSuppressed(suppressor != null);
getContext().sendBroadcast(new Intent(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED)
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY));
}
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 012e22f..31d5cd7 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -17,6 +17,7 @@
package com.android.server.notification;
import static android.media.AudioAttributes.USAGE_ALARM;
+import static android.media.AudioAttributes.USAGE_NOTIFICATION;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
import android.app.AppOpsManager;
@@ -77,6 +78,7 @@ public class ZenModeHelper implements AudioManagerInternal.RingerModeDelegate {
private ZenModeConfig mConfig;
private AudioManagerInternal mAudioManager;
private int mPreviousRingerMode = -1;
+ private boolean mEffectsSuppressed;
public ZenModeHelper(Context context, Looper looper) {
mContext = context;
@@ -153,6 +155,12 @@ public class ZenModeHelper implements AudioManagerInternal.RingerModeDelegate {
}
}
+ public void setEffectsSuppressed(boolean effectsSuppressed) {
+ if (mEffectsSuppressed == effectsSuppressed) return;
+ mEffectsSuppressed = effectsSuppressed;
+ applyRestrictions();
+ }
+
public boolean shouldIntercept(NotificationRecord record) {
if (isSystem(record)) {
return false;
@@ -225,29 +233,35 @@ public class ZenModeHelper implements AudioManagerInternal.RingerModeDelegate {
ZenLog.traceUpdateZenMode(oldMode, newMode);
}
mZenMode = newMode;
+ applyRestrictions();
+ onZenUpdated(oldMode, newMode);
+ dispatchOnZenModeChanged();
+ }
+
+ private void applyRestrictions() {
final boolean zen = mZenMode != Global.ZEN_MODE_OFF;
- final String[] exceptionPackages = null; // none (for now)
+
+ // notification restrictions
+ final boolean muteNotifications = mEffectsSuppressed;
+ applyRestrictions(muteNotifications, USAGE_NOTIFICATION);
// call restrictions
- final boolean muteCalls = zen && !mConfig.allowCalls;
- mAppOps.setRestriction(AppOpsManager.OP_VIBRATE, USAGE_NOTIFICATION_RINGTONE,
- muteCalls ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
- exceptionPackages);
- mAppOps.setRestriction(AppOpsManager.OP_PLAY_AUDIO, USAGE_NOTIFICATION_RINGTONE,
- muteCalls ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
- exceptionPackages);
+ final boolean muteCalls = zen && !mConfig.allowCalls || mEffectsSuppressed;
+ applyRestrictions(muteCalls, USAGE_NOTIFICATION_RINGTONE);
// alarm restrictions
final boolean muteAlarms = mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS;
- mAppOps.setRestriction(AppOpsManager.OP_VIBRATE, USAGE_ALARM,
- muteAlarms ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
+ applyRestrictions(muteAlarms, USAGE_ALARM);
+ }
+
+ private void applyRestrictions(boolean mute, int usage) {
+ final String[] exceptionPackages = null; // none (for now)
+ mAppOps.setRestriction(AppOpsManager.OP_VIBRATE, usage,
+ mute ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
exceptionPackages);
- mAppOps.setRestriction(AppOpsManager.OP_PLAY_AUDIO, USAGE_ALARM,
- muteAlarms ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
+ mAppOps.setRestriction(AppOpsManager.OP_PLAY_AUDIO, usage,
+ mute ? AppOpsManager.MODE_IGNORED : AppOpsManager.MODE_ALLOWED,
exceptionPackages);
-
- onZenUpdated(oldMode, newMode);
- dispatchOnZenModeChanged();
}
public void dump(PrintWriter pw, String prefix) {
@@ -257,6 +271,7 @@ public class ZenModeHelper implements AudioManagerInternal.RingerModeDelegate {
pw.print(prefix); pw.print("mDefaultConfig="); pw.println(mDefaultConfig);
pw.print(prefix); pw.print("mPreviousRingerMode="); pw.println(mPreviousRingerMode);
pw.print(prefix); pw.print("mDefaultPhoneApp="); pw.println(mDefaultPhoneApp);
+ pw.print(prefix); pw.print("mEffectsSuppressed="); pw.println(mEffectsSuppressed);
}
public void readXml(XmlPullParser parser) throws XmlPullParserException, IOException {
diff --git a/services/core/java/com/android/server/wm/KeyguardDisableHandler.java b/services/core/java/com/android/server/wm/KeyguardDisableHandler.java
index c1420a8..37d811f 100644
--- a/services/core/java/com/android/server/wm/KeyguardDisableHandler.java
+++ b/services/core/java/com/android/server/wm/KeyguardDisableHandler.java
@@ -68,9 +68,18 @@ public class KeyguardDisableHandler extends Handler {
break;
case KEYGUARD_POLICY_CHANGED:
- mPolicy.enableKeyguard(true);
- // lazily evaluate this next time we're asked to disable keyguard
mAllowDisableKeyguard = ALLOW_DISABLE_UNKNOWN;
+ if (mKeyguardTokenWatcher.isAcquired()) {
+ // If we are currently disabled we need to know if the keyguard
+ // should be re-enabled, so determine the allow state immediately.
+ mKeyguardTokenWatcher.updateAllowState();
+ if (mAllowDisableKeyguard != ALLOW_DISABLE_YES) {
+ mPolicy.enableKeyguard(true);
+ }
+ } else {
+ // lazily evaluate this next time we're asked to disable keyguard
+ mPolicy.enableKeyguard(true);
+ }
break;
}
}
@@ -81,24 +90,28 @@ public class KeyguardDisableHandler extends Handler {
super(handler, TAG);
}
- @Override
- public void acquired() {
+ public void updateAllowState() {
// We fail safe and prevent disabling keyguard in the unlikely event this gets
// called before DevicePolicyManagerService has started.
- if (mAllowDisableKeyguard == ALLOW_DISABLE_UNKNOWN) {
- DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
- if (dpm != null) {
- try {
- mAllowDisableKeyguard = dpm.getPasswordQuality(null,
- ActivityManagerNative.getDefault().getCurrentUser().id)
- == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED ?
- ALLOW_DISABLE_YES : ALLOW_DISABLE_NO;
- } catch (RemoteException re) {
- // Nothing much we can do
- }
+ DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (dpm != null) {
+ try {
+ mAllowDisableKeyguard = dpm.getPasswordQuality(null,
+ ActivityManagerNative.getDefault().getCurrentUser().id)
+ == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED ?
+ ALLOW_DISABLE_YES : ALLOW_DISABLE_NO;
+ } catch (RemoteException re) {
+ // Nothing much we can do
}
}
+ }
+
+ @Override
+ public void acquired() {
+ if (mAllowDisableKeyguard == ALLOW_DISABLE_UNKNOWN) {
+ updateAllowState();
+ }
if (mAllowDisableKeyguard == ALLOW_DISABLE_YES) {
mPolicy.enableKeyguard(false);
} else {