Merge "Allow doze dream package to start a DreamActivity" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
45387676fc
@@ -268,6 +268,7 @@ import android.os.storage.StorageManager;
|
|||||||
import android.service.dreams.DreamActivity;
|
import android.service.dreams.DreamActivity;
|
||||||
import android.service.dreams.DreamManagerInternal;
|
import android.service.dreams.DreamManagerInternal;
|
||||||
import android.service.voice.IVoiceInteractionSession;
|
import android.service.voice.IVoiceInteractionSession;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -2054,23 +2055,28 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean canLaunchDreamActivity(String packageName) {
|
static boolean canLaunchDreamActivity(String packageName) {
|
||||||
final DreamManagerInternal dreamManager =
|
if (packageName == null) {
|
||||||
LocalServices.getService(DreamManagerInternal.class);
|
|
||||||
|
|
||||||
// Verify that the package is the current active dream. The getActiveDreamComponent()
|
|
||||||
// call path does not acquire the DreamManager lock and thus is safe to use.
|
|
||||||
final ComponentName activeDream = dreamManager.getActiveDreamComponent(false /* doze */);
|
|
||||||
if (activeDream == null || activeDream.getPackageName() == null
|
|
||||||
|| !activeDream.getPackageName().equals(packageName)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the device is dreaming.
|
|
||||||
if (!LocalServices.getService(ActivityTaskManagerInternal.class).isDreaming()) {
|
if (!LocalServices.getService(ActivityTaskManagerInternal.class).isDreaming()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
final DreamManagerInternal dreamManager =
|
||||||
|
LocalServices.getService(DreamManagerInternal.class);
|
||||||
|
|
||||||
|
// Verify that the package is the current active dream or doze component. The
|
||||||
|
// getActiveDreamComponent() call path does not acquire the DreamManager lock and thus
|
||||||
|
// is safe to use.
|
||||||
|
final ComponentName activeDream = dreamManager.getActiveDreamComponent(false /* doze */);
|
||||||
|
final ComponentName activeDoze = dreamManager.getActiveDreamComponent(true /* doze */);
|
||||||
|
return TextUtils.equals(packageName, getPackageName(activeDream))
|
||||||
|
|| TextUtils.equals(packageName, getPackageName(activeDoze));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPackageName(ComponentName componentName) {
|
||||||
|
return componentName != null ? componentName.getPackageName() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActivityType(boolean componentSpecified, int launchedFromUid, Intent intent,
|
private void setActivityType(boolean componentSpecified, int launchedFromUid, Intent intent,
|
||||||
|
|||||||
Reference in New Issue
Block a user