summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Narayan Kamath <narayan@google.com> 2019-05-20 07:41:48 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-05-20 07:41:48 +0000
commit7b25470fd95cebd9d316fdd652c455d68e935937 (patch)
treef3e78ad4bb079ad3f85256f4783d3ab349f48a1d
parente827932a9cc759c3f0d4d0d7624185aed08bec29 (diff)
parent9f72a1e3e85e430c9641373ee9b542695684c204 (diff)
Merge "Changes to MediaProjection UX." into qt-dev
-rw-r--r--packages/SystemUI/res/values/strings.xml5
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java71
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/CastControllerImpl.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/Utils.java23
4 files changed, 71 insertions, 33 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index e01e6a84e9d5..c95dbfeac17e 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1100,7 +1100,10 @@
<string name="battery_saver_notification_action_text">Turn off Battery Saver</string>
<!-- Media projection permission dialog warning text. [CHAR LIMIT=NONE] -->
- <string name="media_projection_dialog_text">While recording or casting, <xliff:g id="app_seeking_permission" example="Hangouts">%s</xliff:g> can capture any sensitive information, such as audio that you play and your passwords, payment info, photos, and messages.</string>
+ <string name="media_projection_dialog_text">While recording or casting, <xliff:g id="app_seeking_permission" example="Hangouts">%s</xliff:g> can capture any sensitive information that is displayed on your screen or played from your device, including sensitive information such as audio, passwords, payment info, photos and messages.</string>
+
+ <!-- Media projection permission dialog warning text for system services. [CHAR LIMIT=NONE] -->
+ <string name="media_projection_dialog_service_text">While recording or casting, the service providing this function can capture any sensitive information that is displayed on your screen or played from your device, including sensitive information such as audio, passwords, payment info, photos and messages.</string>
<!-- Media projection permission dialog warning title. [CHAR LIMIT=NONE] -->
<string name="media_projection_dialog_title">Exposing sensitive info during casting/recording </string>
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
index 3a0534d24f59..f78429316e5a 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaProjectionPermissionActivity.java
@@ -44,6 +44,7 @@ import android.view.WindowManager;
import android.widget.TextView;
import com.android.systemui.R;
+import com.android.systemui.util.Utils;
public class MediaProjectionPermissionActivity extends Activity
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener {
@@ -96,44 +97,50 @@ public class MediaProjectionPermissionActivity extends Activity
TextPaint paint = new TextPaint();
paint.setTextSize(42);
- String label = aInfo.loadLabel(packageManager).toString();
-
- // If the label contains new line characters it may push the security
- // message below the fold of the dialog. Labels shouldn't have new line
- // characters anyways, so just truncate the message the first time one
- // is seen.
- final int labelLength = label.length();
- int offset = 0;
- while (offset < labelLength) {
- final int codePoint = label.codePointAt(offset);
- final int type = Character.getType(codePoint);
- if (type == Character.LINE_SEPARATOR
- || type == Character.CONTROL
- || type == Character.PARAGRAPH_SEPARATOR) {
- label = label.substring(0, offset) + ELLIPSIS;
- break;
+ CharSequence dialogText = null;
+ if (Utils.isHeadlessRemoteDisplayProvider(packageManager, mPackageName)) {
+ dialogText = getString(R.string.media_projection_dialog_service_text);
+ } else {
+ String label = aInfo.loadLabel(packageManager).toString();
+
+ // If the label contains new line characters it may push the security
+ // message below the fold of the dialog. Labels shouldn't have new line
+ // characters anyways, so just truncate the message the first time one
+ // is seen.
+ final int labelLength = label.length();
+ int offset = 0;
+ while (offset < labelLength) {
+ final int codePoint = label.codePointAt(offset);
+ final int type = Character.getType(codePoint);
+ if (type == Character.LINE_SEPARATOR
+ || type == Character.CONTROL
+ || type == Character.PARAGRAPH_SEPARATOR) {
+ label = label.substring(0, offset) + ELLIPSIS;
+ break;
+ }
+ offset += Character.charCount(codePoint);
}
- offset += Character.charCount(codePoint);
- }
- if (label.isEmpty()) {
- label = mPackageName;
- }
+ if (label.isEmpty()) {
+ label = mPackageName;
+ }
- String unsanitizedAppName = TextUtils.ellipsize(label,
- paint, MAX_APP_NAME_SIZE_PX, TextUtils.TruncateAt.END).toString();
- String appName = BidiFormatter.getInstance().unicodeWrap(unsanitizedAppName);
+ String unsanitizedAppName = TextUtils.ellipsize(label,
+ paint, MAX_APP_NAME_SIZE_PX, TextUtils.TruncateAt.END).toString();
+ String appName = BidiFormatter.getInstance().unicodeWrap(unsanitizedAppName);
- String actionText = getString(R.string.media_projection_dialog_text, appName);
- SpannableString message = new SpannableString(actionText);
+ String actionText = getString(R.string.media_projection_dialog_text, appName);
+ SpannableString message = new SpannableString(actionText);
- int appNameIndex = actionText.indexOf(appName);
- if (appNameIndex >= 0) {
- message.setSpan(new StyleSpan(Typeface.BOLD),
- appNameIndex, appNameIndex + appName.length(), 0);
+ int appNameIndex = actionText.indexOf(appName);
+ if (appNameIndex >= 0) {
+ message.setSpan(new StyleSpan(Typeface.BOLD),
+ appNameIndex, appNameIndex + appName.length(), 0);
+ }
+ dialogText = message;
}
- String dialogTitle = getString(R.string.media_projection_dialog_title, appName);
+ String dialogTitle = getString(R.string.media_projection_dialog_title);
View dialogTitleView = View.inflate(this, R.layout.media_projection_dialog_title, null);
TextView titleText = (TextView) dialogTitleView.findViewById(R.id.dialog_title);
@@ -141,7 +148,7 @@ public class MediaProjectionPermissionActivity extends Activity
mDialog = new AlertDialog.Builder(this)
.setCustomTitle(dialogTitleView)
- .setMessage(message)
+ .setMessage(dialogText)
.setPositiveButton(R.string.media_projection_action_text, this)
.setNegativeButton(android.R.string.cancel, this)
.setOnCancelListener(this)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastControllerImpl.java
index 505dd169839e..a5bb92d8e6ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CastControllerImpl.java
@@ -35,6 +35,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.annotations.GuardedBy;
import com.android.systemui.R;
+import com.android.systemui.util.Utils;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -234,6 +235,10 @@ public class CastControllerImpl implements CastController {
private String getAppName(String packageName) {
final PackageManager pm = mContext.getPackageManager();
+ if (Utils.isHeadlessRemoteDisplayProvider(pm, packageName)) {
+ return "";
+ }
+
try {
final ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
if (appInfo != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/util/Utils.java b/packages/SystemUI/src/com/android/systemui/util/Utils.java
index 6b4f7edd54fe..1102bb7e690e 100644
--- a/packages/SystemUI/src/com/android/systemui/util/Utils.java
+++ b/packages/SystemUI/src/com/android/systemui/util/Utils.java
@@ -14,6 +14,9 @@
package com.android.systemui.util;
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
import android.view.View;
import com.android.systemui.SysUiServiceProvider;
@@ -87,4 +90,24 @@ public class Utils {
return mDisabled;
}
}
+
+
+ /**
+ * Returns {@code true} iff the package {@code packageName} is a headless remote display
+ * provider, i.e, that the package holds the privileged {@code REMOTE_DISPLAY_PROVIDER}
+ * permission and that it doesn't host a launcher icon.
+ */
+ public static boolean isHeadlessRemoteDisplayProvider(PackageManager pm, String packageName) {
+ if (pm.checkPermission(Manifest.permission.REMOTE_DISPLAY_PROVIDER, packageName)
+ != PackageManager.PERMISSION_GRANTED) {
+ return false;
+ }
+
+ Intent homeIntent = new Intent(Intent.ACTION_MAIN);
+ homeIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+ homeIntent.setPackage(packageName);
+
+ return pm.queryIntentActivities(homeIntent, 0).isEmpty();
+ }
+
}