Merge changes Id71b4cbc,I8dff0a12,Ife3d1390 into rvc-dev am: a72d7e53e6
Change-Id: I9acb6efd6324b8e7b4ae6bc74fdb6287199ed911
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.service.dreams;
|
||||
|
||||
import android.content.ComponentName;
|
||||
|
||||
/**
|
||||
* Dream manager local system service interface.
|
||||
*
|
||||
@@ -42,4 +44,13 @@ public abstract class DreamManagerInternal {
|
||||
* Called by the power manager to determine whether a dream is running.
|
||||
*/
|
||||
public abstract boolean isDreaming();
|
||||
|
||||
/**
|
||||
* Called by the ActivityTaskManagerService to verify that the startDreamActivity
|
||||
* request comes from the current active dream component.
|
||||
*
|
||||
* @param doze If true returns the current active doze component. Otherwise, returns the
|
||||
* active dream component.
|
||||
*/
|
||||
public abstract ComponentName getActiveDreamComponent(boolean doze);
|
||||
}
|
||||
|
||||
@@ -608,6 +608,8 @@ public class DreamService extends Service implements Window.Callback {
|
||||
* Marks this dream as windowless. Only available to doze dreams.
|
||||
*
|
||||
* @hide
|
||||
*
|
||||
* TODO: Remove @UnsupportedAppUsage.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public void setWindowless(boolean windowless) {
|
||||
@@ -904,12 +906,9 @@ public class DreamService extends Service implements Window.Callback {
|
||||
|
||||
if (mActivity == null) {
|
||||
Slog.w(TAG, "Finish was called before the dream was attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
// In case the activity is not finished yet, do it now. This can happen if someone calls
|
||||
// finish() directly, without going through wakeUp().
|
||||
if (!mActivity.isFinishing()) {
|
||||
} else if (!mActivity.isFinishing()) {
|
||||
// In case the activity is not finished yet, do it now. This can happen if someone calls
|
||||
// finish() directly, without going through wakeUp().
|
||||
mActivity.finishAndRemoveTask();
|
||||
return;
|
||||
}
|
||||
@@ -924,7 +923,6 @@ public class DreamService extends Service implements Window.Callback {
|
||||
} catch (RemoteException ex) {
|
||||
// system server died
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,6 +993,8 @@ public class DreamService extends Service implements Window.Callback {
|
||||
|
||||
if (mActivity != null && !mActivity.isFinishing()) {
|
||||
mActivity.finishAndRemoveTask();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
mDreamToken = null;
|
||||
|
||||
@@ -268,6 +268,10 @@ public final class DreamManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
private ComponentName getActiveDreamComponentInternal(boolean doze) {
|
||||
return chooseDreamForUser(doze, ActivityManager.getCurrentUser());
|
||||
}
|
||||
|
||||
private ComponentName chooseDreamForUser(boolean doze, int userId) {
|
||||
if (doze) {
|
||||
ComponentName dozeComponent = getDozeComponent(userId);
|
||||
@@ -671,6 +675,11 @@ public final class DreamManagerService extends SystemService {
|
||||
public boolean isDreaming() {
|
||||
return isDreamingInternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName getActiveDreamComponent(boolean doze) {
|
||||
return getActiveDreamComponentInternal(doze);
|
||||
}
|
||||
}
|
||||
|
||||
private final Runnable mSystemPropertiesChanged = new Runnable() {
|
||||
|
||||
@@ -213,6 +213,7 @@ import android.os.storage.IStorageManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.provider.Settings;
|
||||
import android.service.dreams.DreamActivity;
|
||||
import android.service.dreams.DreamManagerInternal;
|
||||
import android.service.voice.IVoiceInteractionSession;
|
||||
import android.service.voice.VoiceInteractionManagerInternal;
|
||||
import android.sysprop.DisplayProperties;
|
||||
@@ -1233,12 +1234,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
|
||||
@Override
|
||||
public boolean startDreamActivity(Intent intent) {
|
||||
final WindowProcessController process = mProcessMap.getProcess(Binder.getCallingPid());
|
||||
final long origId = Binder.clearCallingIdentity();
|
||||
|
||||
// The dream activity is only called for non-doze dreams.
|
||||
final ComponentName currentDream = LocalServices.getService(DreamManagerInternal.class)
|
||||
.getActiveDreamComponent(/* doze= */ false);
|
||||
|
||||
if (currentDream == null || currentDream.getPackageName() == null
|
||||
|| !currentDream.getPackageName().equals(process.mInfo.packageName)) {
|
||||
Slog.e(TAG, "Calling package is not the current dream package. "
|
||||
+ "Aborting startDreamActivity...");
|
||||
return false;
|
||||
}
|
||||
|
||||
final ActivityInfo a = new ActivityInfo();
|
||||
a.theme = com.android.internal.R.style.Theme_Dream;
|
||||
a.exported = true;
|
||||
a.name = DreamActivity.class.getName();
|
||||
|
||||
final WindowProcessController process = mProcessMap.getProcess(Binder.getCallingPid());
|
||||
|
||||
a.packageName = process.mInfo.packageName;
|
||||
a.applicationInfo = process.mInfo;
|
||||
@@ -1253,7 +1267,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
a.colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
|
||||
a.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS;
|
||||
|
||||
final long origId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
getActivityStartController().obtainStarter(intent, "dream")
|
||||
.setActivityInfo(a)
|
||||
|
||||
Reference in New Issue
Block a user