Merge "Fix deadlock." into jb-mr1-dev
This commit is contained in:
@@ -42,6 +42,7 @@ abstract class DisplayAdapter {
|
|||||||
public static final int DISPLAY_DEVICE_EVENT_CHANGED = 2;
|
public static final int DISPLAY_DEVICE_EVENT_CHANGED = 2;
|
||||||
public static final int DISPLAY_DEVICE_EVENT_REMOVED = 3;
|
public static final int DISPLAY_DEVICE_EVENT_REMOVED = 3;
|
||||||
|
|
||||||
|
// Called with SyncRoot lock held.
|
||||||
public DisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
public DisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
||||||
Context context, Handler handler, Listener listener, String name) {
|
Context context, Handler handler, Listener listener, String name) {
|
||||||
mSyncRoot = syncRoot;
|
mSyncRoot = syncRoot;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.util.DisplayMetrics;
|
|||||||
final class HeadlessDisplayAdapter extends DisplayAdapter {
|
final class HeadlessDisplayAdapter extends DisplayAdapter {
|
||||||
private static final String TAG = "HeadlessDisplayAdapter";
|
private static final String TAG = "HeadlessDisplayAdapter";
|
||||||
|
|
||||||
|
// Called with SyncRoot lock held.
|
||||||
public HeadlessDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
public HeadlessDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
||||||
Context context, Handler handler, Listener listener) {
|
Context context, Handler handler, Listener listener) {
|
||||||
super(syncRoot, context, handler, listener, TAG);
|
super(syncRoot, context, handler, listener, TAG);
|
||||||
|
|||||||
@@ -44,21 +44,21 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
|||||||
|
|
||||||
private final SparseArray<LocalDisplayDevice> mDevices =
|
private final SparseArray<LocalDisplayDevice> mDevices =
|
||||||
new SparseArray<LocalDisplayDevice>();
|
new SparseArray<LocalDisplayDevice>();
|
||||||
private final HotplugDisplayEventReceiver mHotplugReceiver;
|
private HotplugDisplayEventReceiver mHotplugReceiver;
|
||||||
|
|
||||||
private final PhysicalDisplayInfo mTempPhys = new PhysicalDisplayInfo();
|
private final PhysicalDisplayInfo mTempPhys = new PhysicalDisplayInfo();
|
||||||
|
|
||||||
|
// Called with SyncRoot lock held.
|
||||||
public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
public LocalDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
||||||
Context context, Handler handler, Listener listener) {
|
Context context, Handler handler, Listener listener) {
|
||||||
super(syncRoot, context, handler, listener, TAG);
|
super(syncRoot, context, handler, listener, TAG);
|
||||||
mHotplugReceiver = new HotplugDisplayEventReceiver(handler.getLooper());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLocked() {
|
public void registerLocked() {
|
||||||
// TODO: listen for notifications from Surface Flinger about
|
|
||||||
// built-in displays being added or removed and rescan as needed.
|
|
||||||
super.registerLocked();
|
super.registerLocked();
|
||||||
|
|
||||||
|
mHotplugReceiver = new HotplugDisplayEventReceiver(getHandler().getLooper());
|
||||||
scanDisplaysLocked();
|
scanDisplaysLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
|
|||||||
new ArrayList<OverlayDisplayHandle>();
|
new ArrayList<OverlayDisplayHandle>();
|
||||||
private String mCurrentOverlaySetting = "";
|
private String mCurrentOverlaySetting = "";
|
||||||
|
|
||||||
|
// Called with SyncRoot lock held.
|
||||||
public OverlayDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
public OverlayDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
||||||
Context context, Handler handler, Listener listener, Handler uiHandler) {
|
Context context, Handler handler, Listener listener, Handler uiHandler) {
|
||||||
super(syncRoot, context, handler, listener, TAG);
|
super(syncRoot, context, handler, listener, TAG);
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
private final boolean mSupportsProtectedBuffers;
|
private final boolean mSupportsProtectedBuffers;
|
||||||
private final NotificationManager mNotificationManager;
|
private final NotificationManager mNotificationManager;
|
||||||
|
|
||||||
private final PendingIntent mSettingsPendingIntent;
|
private PendingIntent mSettingsPendingIntent;
|
||||||
private final PendingIntent mDisconnectPendingIntent;
|
private PendingIntent mDisconnectPendingIntent;
|
||||||
|
|
||||||
private WifiDisplayController mDisplayController;
|
private WifiDisplayController mDisplayController;
|
||||||
private WifiDisplayDevice mDisplayDevice;
|
private WifiDisplayDevice mDisplayDevice;
|
||||||
@@ -90,6 +90,7 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
private boolean mPendingStatusChangeBroadcast;
|
private boolean mPendingStatusChangeBroadcast;
|
||||||
private boolean mPendingNotificationUpdate;
|
private boolean mPendingNotificationUpdate;
|
||||||
|
|
||||||
|
// Called with SyncRoot lock held.
|
||||||
public WifiDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
public WifiDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
|
||||||
Context context, Handler handler, Listener listener,
|
Context context, Handler handler, Listener listener,
|
||||||
PersistentDataStore persistentDataStore) {
|
PersistentDataStore persistentDataStore) {
|
||||||
@@ -100,20 +101,6 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
com.android.internal.R.bool.config_wifiDisplaySupportsProtectedBuffers);
|
com.android.internal.R.bool.config_wifiDisplaySupportsProtectedBuffers);
|
||||||
mNotificationManager = (NotificationManager)context.getSystemService(
|
mNotificationManager = (NotificationManager)context.getSystemService(
|
||||||
Context.NOTIFICATION_SERVICE);
|
Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
Intent settingsIntent = new Intent(Settings.ACTION_WIFI_DISPLAY_SETTINGS);
|
|
||||||
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
mSettingsPendingIntent = PendingIntent.getActivityAsUser(
|
|
||||||
context, 0, settingsIntent, 0, null, UserHandle.CURRENT);
|
|
||||||
|
|
||||||
Intent disconnectIntent = new Intent(ACTION_DISCONNECT);
|
|
||||||
mDisconnectPendingIntent = PendingIntent.getBroadcastAsUser(
|
|
||||||
context, 0, disconnectIntent, 0, UserHandle.CURRENT);
|
|
||||||
|
|
||||||
context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
|
||||||
new IntentFilter(ACTION_DISCONNECT), null, mHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,6 +140,9 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
public void run() {
|
public void run() {
|
||||||
mDisplayController = new WifiDisplayController(
|
mDisplayController = new WifiDisplayController(
|
||||||
getContext(), getHandler(), mWifiDisplayListener);
|
getContext(), getHandler(), mWifiDisplayListener);
|
||||||
|
|
||||||
|
getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
||||||
|
new IntentFilter(ACTION_DISCONNECT), null, mHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -366,12 +356,31 @@ final class WifiDisplayAdapter extends DisplayAdapter {
|
|||||||
isConnected = (mDisplayDevice != null);
|
isConnected = (mDisplayDevice != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel the old notification if there is one.
|
||||||
mNotificationManager.cancelAsUser(null,
|
mNotificationManager.cancelAsUser(null,
|
||||||
R.string.wifi_display_notification_title, UserHandle.ALL);
|
R.string.wifi_display_notification_title, UserHandle.ALL);
|
||||||
|
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
|
||||||
|
// Initialize pending intents for the notification outside of the lock because
|
||||||
|
// creating a pending intent requires a call into the activity manager.
|
||||||
|
if (mSettingsPendingIntent == null) {
|
||||||
|
Intent settingsIntent = new Intent(Settings.ACTION_WIFI_DISPLAY_SETTINGS);
|
||||||
|
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
mSettingsPendingIntent = PendingIntent.getActivityAsUser(
|
||||||
|
context, 0, settingsIntent, 0, null, UserHandle.CURRENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDisconnectPendingIntent == null) {
|
||||||
|
Intent disconnectIntent = new Intent(ACTION_DISCONNECT);
|
||||||
|
mDisconnectPendingIntent = PendingIntent.getBroadcastAsUser(
|
||||||
|
context, 0, disconnectIntent, 0, UserHandle.CURRENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Post the notification.
|
||||||
Resources r = context.getResources();
|
Resources r = context.getResources();
|
||||||
Notification notification = new Notification.Builder(context)
|
Notification notification = new Notification.Builder(context)
|
||||||
.setContentTitle(r.getString(
|
.setContentTitle(r.getString(
|
||||||
|
|||||||
Reference in New Issue
Block a user