Loading services/core/java/com/android/server/clipboard/ClipboardService.java +20 −8 Original line number Diff line number Diff line Loading @@ -368,6 +368,19 @@ public class ClipboardService extends SystemService { return related; } /** Check if the user has the given restriction set. Default to true if error occured during * calling UserManager, so it fails safe. */ private boolean hasRestriction(String restriction, int userId) { try { return mUm.hasUserRestriction(restriction, userId); } catch (RemoteException e) { Slog.e(TAG, "Remote Exception calling UserManager.getUserRestrictions: ", e); // Fails safe return true; } } void setPrimaryClipInternal(@Nullable ClipData clip, int callingUid) { // Push clipboard to host, if any if (mHostClipboardMonitor != null) { Loading @@ -391,13 +404,8 @@ public class ClipboardService extends SystemService { if (related != null) { int size = related.size(); if (size > 1) { // Related profiles list include the current profile. boolean canCopy = false; try { canCopy = !mUm.getUserRestrictions(userId).getBoolean( UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE); } catch (RemoteException e) { Slog.e(TAG, "Remote Exception calling UserManager: " + e); } final boolean canCopy = !hasRestriction( UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE, userId); // Copy clip data to related users if allowed. If disallowed, then remove // primary clip in related users to prevent pasting stale content. if (!canCopy) { Loading @@ -416,12 +424,16 @@ public class ClipboardService extends SystemService { for (int i = 0; i < size; i++) { int id = related.get(i).id; if (id != userId) { final boolean canCopyIntoProfile = !hasRestriction( UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE, id); if (canCopyIntoProfile) { setPrimaryClipInternal(getClipboard(id), clip, callingUid); } } } } } } void setPrimaryClipInternal(PerUserClipboard clipboard, @Nullable ClipData clip, int callingUid) { Loading Loading
services/core/java/com/android/server/clipboard/ClipboardService.java +20 −8 Original line number Diff line number Diff line Loading @@ -368,6 +368,19 @@ public class ClipboardService extends SystemService { return related; } /** Check if the user has the given restriction set. Default to true if error occured during * calling UserManager, so it fails safe. */ private boolean hasRestriction(String restriction, int userId) { try { return mUm.hasUserRestriction(restriction, userId); } catch (RemoteException e) { Slog.e(TAG, "Remote Exception calling UserManager.getUserRestrictions: ", e); // Fails safe return true; } } void setPrimaryClipInternal(@Nullable ClipData clip, int callingUid) { // Push clipboard to host, if any if (mHostClipboardMonitor != null) { Loading @@ -391,13 +404,8 @@ public class ClipboardService extends SystemService { if (related != null) { int size = related.size(); if (size > 1) { // Related profiles list include the current profile. boolean canCopy = false; try { canCopy = !mUm.getUserRestrictions(userId).getBoolean( UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE); } catch (RemoteException e) { Slog.e(TAG, "Remote Exception calling UserManager: " + e); } final boolean canCopy = !hasRestriction( UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE, userId); // Copy clip data to related users if allowed. If disallowed, then remove // primary clip in related users to prevent pasting stale content. if (!canCopy) { Loading @@ -416,12 +424,16 @@ public class ClipboardService extends SystemService { for (int i = 0; i < size; i++) { int id = related.get(i).id; if (id != userId) { final boolean canCopyIntoProfile = !hasRestriction( UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE, id); if (canCopyIntoProfile) { setPrimaryClipInternal(getClipboard(id), clip, callingUid); } } } } } } void setPrimaryClipInternal(PerUserClipboard clipboard, @Nullable ClipData clip, int callingUid) { Loading