Merge "Dismiss dream when activities are started while dreaming." into tm-dev am: 964c0704c5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17988655 Change-Id: Ie8f79a2616567e5a8e1022033414291ee35d7464 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2415,8 +2415,12 @@
|
||||
<!-- Is the system user the only user allowed to dream. -->
|
||||
<bool name="config_dreamsOnlyEnabledForSystemUser">false</bool>
|
||||
|
||||
<!-- Whether to dismiss the active dream when an activity is started. Doesn't apply to
|
||||
assistant activities (ACTIVITY_TYPE_ASSISTANT) -->
|
||||
<bool name="config_dismissDreamOnActivityStart">true</bool>
|
||||
|
||||
<!-- The prefix of dream component names that are loggable. If empty, logs "other" for all. -->
|
||||
<string name ="config_loggable_dream_prefix" translatable="false"></string>
|
||||
<string name="config_loggable_dream_prefix" translatable="false"></string>
|
||||
|
||||
<!-- ComponentName of a dream to show whenever the system would otherwise have
|
||||
gone to sleep. When the PowerManager is asked to go to sleep, it will instead
|
||||
|
||||
@@ -2221,6 +2221,7 @@
|
||||
<java-symbol type="array" name="config_supportedDreamComplications" />
|
||||
<java-symbol type="array" name="config_dreamComplicationsEnabledByDefault" />
|
||||
<java-symbol type="array" name="config_disabledDreamComponents" />
|
||||
<java-symbol type="bool" name="config_dismissDreamOnActivityStart" />
|
||||
<java-symbol type="string" name="config_loggable_dream_prefix" />
|
||||
<java-symbol type="string" name="config_dozeComponent" />
|
||||
<java-symbol type="string" name="enable_explore_by_touch_warning_title" />
|
||||
|
||||
@@ -17,13 +17,21 @@
|
||||
package com.android.server.dreams;
|
||||
|
||||
import static android.Manifest.permission.BIND_DREAM_SERVICE;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
|
||||
|
||||
import static com.android.server.wm.ActivityInterceptorCallback.DREAM_MANAGER_ORDERED_ID;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.TaskInfo;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ServiceInfo;
|
||||
@@ -54,6 +62,7 @@ import com.android.internal.util.DumpUtils;
|
||||
import com.android.server.FgThread;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.wm.ActivityInterceptorCallback;
|
||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -83,6 +92,7 @@ public final class DreamManagerService extends SystemService {
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
private final DreamUiEventLogger mDreamUiEventLogger;
|
||||
private final ComponentName mAmbientDisplayComponent;
|
||||
private final boolean mDismissDreamOnActivityStart;
|
||||
|
||||
private Binder mCurrentDreamToken;
|
||||
private ComponentName mCurrentDreamName;
|
||||
@@ -99,6 +109,26 @@ public final class DreamManagerService extends SystemService {
|
||||
private ComponentName mDreamOverlayServiceName;
|
||||
|
||||
private AmbientDisplayConfiguration mDozeConfig;
|
||||
private final ActivityInterceptorCallback mActivityInterceptorCallback =
|
||||
new ActivityInterceptorCallback() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ActivityInterceptResult intercept(ActivityInterceptorInfo info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityLaunched(TaskInfo taskInfo, ActivityInfo activityInfo,
|
||||
ActivityInterceptorInfo info) {
|
||||
final int activityType = taskInfo.getActivityType();
|
||||
final boolean activityAllowed = activityType == ACTIVITY_TYPE_HOME
|
||||
|| activityType == ACTIVITY_TYPE_DREAM
|
||||
|| activityType == ACTIVITY_TYPE_ASSISTANT;
|
||||
if (mCurrentDreamToken != null && !mCurrentDreamIsWaking && !activityAllowed) {
|
||||
stopDreamInternal(false, "activity starting: " + activityInfo.name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public DreamManagerService(Context context) {
|
||||
super(context);
|
||||
@@ -118,6 +148,8 @@ public final class DreamManagerService extends SystemService {
|
||||
mAmbientDisplayComponent = ComponentName.unflattenFromString(adc.ambientDisplayComponent());
|
||||
mDreamsOnlyEnabledForSystemUser =
|
||||
mContext.getResources().getBoolean(R.bool.config_dreamsOnlyEnabledForSystemUser);
|
||||
mDismissDreamOnActivityStart = mContext.getResources().getBoolean(
|
||||
R.bool.config_dismissDreamOnActivityStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +177,12 @@ public final class DreamManagerService extends SystemService {
|
||||
Settings.Secure.getUriFor(Settings.Secure.DOZE_DOUBLE_TAP_GESTURE), false,
|
||||
mDozeEnabledObserver, UserHandle.USER_ALL);
|
||||
writePulseGestureEnabled();
|
||||
|
||||
if (mDismissDreamOnActivityStart) {
|
||||
mAtmInternal.registerActivityStartInterceptor(
|
||||
DREAM_MANAGER_ORDERED_ID,
|
||||
mActivityInterceptorCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public abstract class ActivityInterceptorCallback {
|
||||
PERMISSION_POLICY_ORDERED_ID,
|
||||
INTENT_RESOLVER_ORDERED_ID,
|
||||
VIRTUAL_DEVICE_SERVICE_ORDERED_ID,
|
||||
DREAM_MANAGER_ORDERED_ID,
|
||||
LAST_ORDERED_ID // Update this when adding new ids
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@@ -87,11 +88,16 @@ public abstract class ActivityInterceptorCallback {
|
||||
*/
|
||||
public static final int VIRTUAL_DEVICE_SERVICE_ORDERED_ID = 3;
|
||||
|
||||
/**
|
||||
* The identifier for {@link com.android.server.dreams.DreamManagerService} interceptor.
|
||||
*/
|
||||
public static final int DREAM_MANAGER_ORDERED_ID = 4;
|
||||
|
||||
/**
|
||||
* The final id, used by the framework to determine the valid range of ids. Update this when
|
||||
* adding new ids.
|
||||
*/
|
||||
static final int LAST_ORDERED_ID = VIRTUAL_DEVICE_SERVICE_ORDERED_ID;
|
||||
static final int LAST_ORDERED_ID = DREAM_MANAGER_ORDERED_ID;
|
||||
|
||||
/**
|
||||
* Data class for storing the various arguments needed for activity interception.
|
||||
|
||||
Reference in New Issue
Block a user