Separate ambient display triggers

Allows configuring notification and sensor triggers
separately. Introduces a helper class that hosts the
logic for determining what kinds of triggers a device
supports.

Bug: 32073185
Change-Id: Ie7e8eb6b895dcc54e6f972e70642c7248b9e223a
Test: disable "ambient display", sensor triggers should still work
This commit is contained in:
Adrian Roos
2016-10-14 13:03:45 -07:00
parent 92bd012829
commit b7e4e10618
7 changed files with 117 additions and 41 deletions

View File

@@ -18,6 +18,7 @@ package com.android.server.dreams;
import static android.Manifest.permission.BIND_DREAM_SERVICE;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.util.DumpUtils;
import com.android.server.FgThread;
import com.android.server.LocalServices;
@@ -88,6 +89,8 @@ public final class DreamManagerService extends SystemService {
private int mCurrentDreamDozeScreenState = Display.STATE_UNKNOWN;
private int mCurrentDreamDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT;
private AmbientDisplayConfiguration mDozeConfig;
public DreamManagerService(Context context) {
super(context);
mContext = context;
@@ -97,6 +100,7 @@ public final class DreamManagerService extends SystemService {
mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mPowerManagerInternal = getLocalService(PowerManagerInternal.class);
mDozeWakeLock = mPowerManager.newWakeLock(PowerManager.DOZE_WAKE_LOCK, TAG);
mDozeConfig = new AmbientDisplayConfiguration(mContext);
}
@Override
@@ -121,7 +125,7 @@ public final class DreamManagerService extends SystemService {
}
}, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.DOZE_ENABLED), false,
Settings.Secure.getUriFor(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP), false,
mDozeEnabledObserver, UserHandle.USER_ALL);
writePulseGestureEnabled();
}
@@ -326,19 +330,12 @@ public final class DreamManagerService extends SystemService {
}
private ComponentName getDozeComponent(int userId) {
// Read the component from a system property to facilitate debugging.
// Note that for production devices, the dream should actually be declared in
// a config.xml resource.
String name = Build.IS_DEBUGGABLE ? SystemProperties.get("debug.doze.component") : null;
if (TextUtils.isEmpty(name)) {
// Read the component from a config.xml resource.
// The value should be specified in a resource overlay for the product.
name = mContext.getResources().getString(
com.android.internal.R.string.config_dozeComponent);
if (mDozeConfig.enabled(userId)) {
return ComponentName.unflattenFromString(mDozeConfig.ambientDisplayComponent());
} else {
return null;
}
boolean enabled = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.DOZE_ENABLED, 1, userId) != 0;
return TextUtils.isEmpty(name) || !enabled ? null : ComponentName.unflattenFromString(name);
}
private ServiceInfo getServiceInfo(ComponentName name) {