Loading core/java/android/hardware/display/DisplayManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,7 @@ public final class DisplayManager { * The status is provided as a {@link WifiDisplayStatus} object in the * {@link #EXTRA_WIFI_DISPLAY_STATUS} extra. * </p><p> * This broadcast is only sent to registered receivers with the * {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} permission and can * only be sent by the system. * This broadcast is only sent to registered receivers and can only be sent by the system. * </p> * @hide */ Loading Loading @@ -163,6 +161,9 @@ public final class DisplayManager { * <p> * Automatically remembers the display after a successful connection, if not * already remembered. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} to connect * to unknown displays. No permissions are required to connect to already known displays. * </p> * * @param deviceAddress The MAC address of the device to which we should connect. Loading @@ -187,6 +188,8 @@ public final class DisplayManager { * The display must already be remembered for this call to succeed. In other words, * we must already have successfully connected to the display at least once and then * not forgotten it. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to rename. Loading @@ -202,6 +205,8 @@ public final class DisplayManager { * Forgets a previously remembered Wifi display. * <p> * Automatically disconnects from the display if currently connected to it. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to forget. Loading core/java/android/hardware/display/IDisplayManager.aidl +5 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ interface IDisplayManager { void registerCallback(in IDisplayManagerCallback callback); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. void scanWifiDisplays(); // Requires CONFIGURE_WIFI_DISPLAY permission. // Requires CONFIGURE_WIFI_DISPLAY permission to connect to an unknown device. // No permissions required to connect to a known device. void connectWifiDisplay(String address); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. void disconnectWifiDisplay(); // Requires CONFIGURE_WIFI_DISPLAY permission. Loading @@ -43,6 +44,6 @@ interface IDisplayManager { // Requires CONFIGURE_WIFI_DISPLAY permission. void forgetWifiDisplay(String address); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. WifiDisplayStatus getWifiDisplayStatus(); } services/java/com/android/server/UiModeManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.StatusBarManager; import android.app.UiModeManager; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -497,7 +496,8 @@ class UiModeManagerService extends IUiModeManager.Stub { sendConfigurationLocked(); // If we did not start a dock app, then start dreaming if supported. if (!dockAppStarted && isScreenSaverEnabled() && isScreenSaverActivatedOnDock()) { if (category != null && !dockAppStarted && isScreenSaverEnabled() && isScreenSaverActivatedOnDock()) { Slog.i(TAG, "Activating dream while docked."); try { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( Loading services/java/com/android/server/display/DisplayManagerService.java +15 −28 Original line number Diff line number Diff line Loading @@ -352,11 +352,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void scanWifiDisplays() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -371,19 +366,16 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void connectWifiDisplay(String address) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } final boolean trusted = canCallerConfigureWifiDisplay(); final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { if (mWifiDisplayAdapter != null) { mWifiDisplayAdapter.requestConnectLocked(address); mWifiDisplayAdapter.requestConnectLocked(address, trusted); } } } finally { Loading @@ -393,11 +385,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void disconnectWifiDisplay() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -412,13 +399,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void renameWifiDisplay(String address, String alias) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } if (!canCallerConfigureWifiDisplay()) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + "rename a wifi display."); } final long token = Binder.clearCallingIdentity(); try { Loading @@ -434,13 +421,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void forgetWifiDisplay(String address) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } if (!canCallerConfigureWifiDisplay()) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + "forget a wifi display."); } final long token = Binder.clearCallingIdentity(); try { Loading @@ -456,11 +443,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public WifiDisplayStatus getWifiDisplayStatus() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -475,6 +457,11 @@ public final class DisplayManagerService extends IDisplayManager.Stub { } } private boolean canCallerConfigureWifiDisplay() { return mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) == PackageManager.PERMISSION_GRANTED; } private void registerDefaultDisplayAdapter() { // Register default display adapter. synchronized (mSyncRoot) { Loading services/java/com/android/server/display/WifiDisplayAdapter.java +23 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.hardware.display.WifiDisplayStatus; import android.media.RemoteDisplay; import android.os.Handler; import android.os.IBinder; import android.util.Slog; import android.view.Surface; import java.io.PrintWriter; Loading Loading @@ -121,7 +122,17 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } public void requestConnectLocked(final String address) { public void requestConnectLocked(final String address, final boolean trusted) { if (!trusted) { synchronized (getSyncRoot()) { if (!isRememberedDisplayLocked(address)) { Slog.w(TAG, "Ignoring request by an untrusted client to connect to " + "an unknown wifi display: " + address); return; } } } getHandler().post(new Runnable() { @Override public void run() { Loading @@ -132,6 +143,15 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } private boolean isRememberedDisplayLocked(String address) { for (WifiDisplay display : mRememberedDisplays) { if (display.getDeviceAddress().equals(address)) { return true; } } return false; } public void requestDisconnectLocked() { getHandler().post(new Runnable() { @Override Loading Loading @@ -241,10 +261,8 @@ final class WifiDisplayAdapter extends DisplayAdapter { getWifiDisplayStatusLocked()); } // Send protected broadcast about wifi display status to receivers that // have the required permission. getContext().sendBroadcast(intent, android.Manifest.permission.CONFIGURE_WIFI_DISPLAY); // Send protected broadcast about wifi display status to registered receivers. getContext().sendBroadcast(intent); } }; Loading Loading
core/java/android/hardware/display/DisplayManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,7 @@ public final class DisplayManager { * The status is provided as a {@link WifiDisplayStatus} object in the * {@link #EXTRA_WIFI_DISPLAY_STATUS} extra. * </p><p> * This broadcast is only sent to registered receivers with the * {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} permission and can * only be sent by the system. * This broadcast is only sent to registered receivers and can only be sent by the system. * </p> * @hide */ Loading Loading @@ -163,6 +161,9 @@ public final class DisplayManager { * <p> * Automatically remembers the display after a successful connection, if not * already remembered. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} to connect * to unknown displays. No permissions are required to connect to already known displays. * </p> * * @param deviceAddress The MAC address of the device to which we should connect. Loading @@ -187,6 +188,8 @@ public final class DisplayManager { * The display must already be remembered for this call to succeed. In other words, * we must already have successfully connected to the display at least once and then * not forgotten it. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to rename. Loading @@ -202,6 +205,8 @@ public final class DisplayManager { * Forgets a previously remembered Wifi display. * <p> * Automatically disconnects from the display if currently connected to it. * </p><p> * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to forget. Loading
core/java/android/hardware/display/IDisplayManager.aidl +5 −4 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ interface IDisplayManager { void registerCallback(in IDisplayManagerCallback callback); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. void scanWifiDisplays(); // Requires CONFIGURE_WIFI_DISPLAY permission. // Requires CONFIGURE_WIFI_DISPLAY permission to connect to an unknown device. // No permissions required to connect to a known device. void connectWifiDisplay(String address); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. void disconnectWifiDisplay(); // Requires CONFIGURE_WIFI_DISPLAY permission. Loading @@ -43,6 +44,6 @@ interface IDisplayManager { // Requires CONFIGURE_WIFI_DISPLAY permission. void forgetWifiDisplay(String address); // Requires CONFIGURE_WIFI_DISPLAY permission. // No permissions required. WifiDisplayStatus getWifiDisplayStatus(); }
services/java/com/android/server/UiModeManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.StatusBarManager; import android.app.UiModeManager; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -497,7 +496,8 @@ class UiModeManagerService extends IUiModeManager.Stub { sendConfigurationLocked(); // If we did not start a dock app, then start dreaming if supported. if (!dockAppStarted && isScreenSaverEnabled() && isScreenSaverActivatedOnDock()) { if (category != null && !dockAppStarted && isScreenSaverEnabled() && isScreenSaverActivatedOnDock()) { Slog.i(TAG, "Activating dream while docked."); try { IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( Loading
services/java/com/android/server/display/DisplayManagerService.java +15 −28 Original line number Diff line number Diff line Loading @@ -352,11 +352,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void scanWifiDisplays() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -371,19 +366,16 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void connectWifiDisplay(String address) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } final boolean trusted = canCallerConfigureWifiDisplay(); final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { if (mWifiDisplayAdapter != null) { mWifiDisplayAdapter.requestConnectLocked(address); mWifiDisplayAdapter.requestConnectLocked(address, trusted); } } } finally { Loading @@ -393,11 +385,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void disconnectWifiDisplay() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -412,13 +399,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void renameWifiDisplay(String address, String alias) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } if (!canCallerConfigureWifiDisplay()) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + "rename a wifi display."); } final long token = Binder.clearCallingIdentity(); try { Loading @@ -434,13 +421,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void forgetWifiDisplay(String address) { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } if (address == null) { throw new IllegalArgumentException("address must not be null"); } if (!canCallerConfigureWifiDisplay()) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + "forget a wifi display."); } final long token = Binder.clearCallingIdentity(); try { Loading @@ -456,11 +443,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public WifiDisplayStatus getWifiDisplayStatus() { if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); } final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { Loading @@ -475,6 +457,11 @@ public final class DisplayManagerService extends IDisplayManager.Stub { } } private boolean canCallerConfigureWifiDisplay() { return mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) == PackageManager.PERMISSION_GRANTED; } private void registerDefaultDisplayAdapter() { // Register default display adapter. synchronized (mSyncRoot) { Loading
services/java/com/android/server/display/WifiDisplayAdapter.java +23 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.hardware.display.WifiDisplayStatus; import android.media.RemoteDisplay; import android.os.Handler; import android.os.IBinder; import android.util.Slog; import android.view.Surface; import java.io.PrintWriter; Loading Loading @@ -121,7 +122,17 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } public void requestConnectLocked(final String address) { public void requestConnectLocked(final String address, final boolean trusted) { if (!trusted) { synchronized (getSyncRoot()) { if (!isRememberedDisplayLocked(address)) { Slog.w(TAG, "Ignoring request by an untrusted client to connect to " + "an unknown wifi display: " + address); return; } } } getHandler().post(new Runnable() { @Override public void run() { Loading @@ -132,6 +143,15 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } private boolean isRememberedDisplayLocked(String address) { for (WifiDisplay display : mRememberedDisplays) { if (display.getDeviceAddress().equals(address)) { return true; } } return false; } public void requestDisconnectLocked() { getHandler().post(new Runnable() { @Override Loading Loading @@ -241,10 +261,8 @@ final class WifiDisplayAdapter extends DisplayAdapter { getWifiDisplayStatusLocked()); } // Send protected broadcast about wifi display status to receivers that // have the required permission. getContext().sendBroadcast(intent, android.Manifest.permission.CONFIGURE_WIFI_DISPLAY); // Send protected broadcast about wifi display status to registered receivers. getContext().sendBroadcast(intent); } }; Loading