Merge "Merge "Ensure that we use the current user context when adding nav mode listeners" into qt-dev am: d76c0d751a am: 2d7c954668" into qt-r1-dev-plus-aosp
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index 31a6b81..d83cd96 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -82,7 +82,7 @@
*/
public class ExifInterface {
private static final String TAG = "ExifInterface";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
// The Exif tag names. See Tiff 6.0 Section 3 and Section 8.
/** Type is String. */
@@ -1605,12 +1605,15 @@
|| exifTag.primaryFormat == IFD_FORMAT_STRING) {
dataFormat = exifTag.primaryFormat;
} else {
- Log.w(TAG, "Given tag (" + tag + ") value didn't match with one of expected "
- + "formats: " + IFD_FORMAT_NAMES[exifTag.primaryFormat]
- + (exifTag.secondaryFormat == -1 ? "" : ", "
- + IFD_FORMAT_NAMES[exifTag.secondaryFormat]) + " (guess: "
- + IFD_FORMAT_NAMES[guess.first] + (guess.second == -1 ? "" : ", "
- + IFD_FORMAT_NAMES[guess.second]) + ")");
+ if (DEBUG) {
+ Log.d(TAG, "Given tag (" + tag
+ + ") value didn't match with one of expected "
+ + "formats: " + IFD_FORMAT_NAMES[exifTag.primaryFormat]
+ + (exifTag.secondaryFormat == -1 ? "" : ", "
+ + IFD_FORMAT_NAMES[exifTag.secondaryFormat]) + " (guess: "
+ + IFD_FORMAT_NAMES[guess.first] + (guess.second == -1 ? "" : ", "
+ + IFD_FORMAT_NAMES[guess.second]) + ")");
+ }
continue;
}
switch (dataFormat) {
@@ -1688,7 +1691,9 @@
break;
}
default:
- Log.w(TAG, "Data format isn't one of expected formats: " + dataFormat);
+ if (DEBUG) {
+ Log.d(TAG, "Data format isn't one of expected formats: " + dataFormat);
+ }
continue;
}
}
@@ -1790,7 +1795,7 @@
// ExifInterface.
mIsSupportedFile = false;
if (DEBUG) {
- Log.w(TAG, "Invalid image: ExifInterface got an unsupported image format file"
+ Log.d(TAG, "Invalid image: ExifInterface got an unsupported image format file"
+ "(ExifInterface supports JPEG and some RAW image formats only) "
+ "or a corrupted JPEG file to ExifInterface.", e);
}
@@ -3183,14 +3188,20 @@
long byteCount = 0;
boolean valid = false;
if (tag == null) {
- Log.w(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber);
+ if (DEBUG) {
+ Log.d(TAG, "Skip the tag entry since tag number is not defined: " + tagNumber);
+ }
} else if (dataFormat <= 0 || dataFormat >= IFD_FORMAT_BYTES_PER_FORMAT.length) {
- Log.w(TAG, "Skip the tag entry since data format is invalid: " + dataFormat);
+ if (DEBUG) {
+ Log.d(TAG, "Skip the tag entry since data format is invalid: " + dataFormat);
+ }
} else {
byteCount = (long) numberOfComponents * IFD_FORMAT_BYTES_PER_FORMAT[dataFormat];
if (byteCount < 0 || byteCount > Integer.MAX_VALUE) {
- Log.w(TAG, "Skip the tag entry since the number of components is invalid: "
- + numberOfComponents);
+ if (DEBUG) {
+ Log.d(TAG, "Skip the tag entry since the number of components is invalid: "
+ + numberOfComponents);
+ }
} else {
valid = true;
}
@@ -3239,7 +3250,9 @@
dataInputStream.seek(offset);
} else {
// Skip if invalid data offset.
- Log.w(TAG, "Skip the tag entry since data offset is invalid: " + offset);
+ if (DEBUG) {
+ Log.d(TAG, "Skip the tag entry since data offset is invalid: " + offset);
+ }
dataInputStream.seek(nextEntryOffset);
continue;
}
@@ -3289,11 +3302,15 @@
dataInputStream.seek(offset);
readImageFileDirectory(dataInputStream, nextIfdType);
} else {
- Log.w(TAG, "Skip jump into the IFD since it has already been read: "
- + "IfdType " + nextIfdType + " (at " + offset + ")");
+ if (DEBUG) {
+ Log.d(TAG, "Skip jump into the IFD since it has already been read: "
+ + "IfdType " + nextIfdType + " (at " + offset + ")");
+ }
}
} else {
- Log.w(TAG, "Skip jump into the IFD since its offset is invalid: " + offset);
+ if (DEBUG) {
+ Log.d(TAG, "Skip jump into the IFD since its offset is invalid: " + offset);
+ }
}
dataInputStream.seek(nextEntryOffset);
@@ -3348,12 +3365,16 @@
readImageFileDirectory(dataInputStream, IFD_TYPE_PREVIEW);
}
} else {
- Log.w(TAG, "Stop reading file since re-reading an IFD may cause an "
- + "infinite loop: " + nextIfdOffset);
+ if (DEBUG) {
+ Log.d(TAG, "Stop reading file since re-reading an IFD may cause an "
+ + "infinite loop: " + nextIfdOffset);
+ }
}
} else {
- Log.w(TAG, "Stop reading file since a wrong offset may cause an infinite loop: "
- + nextIfdOffset);
+ if (DEBUG) {
+ Log.d(TAG, "Stop reading file since a wrong offset may cause an infinite loop: "
+ + nextIfdOffset);
+ }
}
}
}
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index e01e6a8..c95dbfe 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 3a0534d2..f784293 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.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 @@
TextPaint paint = new TextPaint();
paint.setTextSize(42);
- String label = aInfo.loadLabel(packageManager).toString();
+ 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;
+ // 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;
+ }
+
+ 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);
+
+ int appNameIndex = actionText.indexOf(appName);
+ if (appNameIndex >= 0) {
+ message.setSpan(new StyleSpan(Typeface.BOLD),
+ appNameIndex, appNameIndex + appName.length(), 0);
+ }
+ dialogText = message;
}
- 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 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);
- }
-
- 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 @@
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 505dd16..a5bb92d 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 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 @@
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 6b4f7ed..1102bb7 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 @@
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();
+ }
+
}
diff --git a/services/core/java/com/android/server/display/color/ColorDisplayService.java b/services/core/java/com/android/server/display/color/ColorDisplayService.java
index ad81ca2..b2420b5 100644
--- a/services/core/java/com/android/server/display/color/ColorDisplayService.java
+++ b/services/core/java/com/android/server/display/color/ColorDisplayService.java
@@ -23,6 +23,8 @@
import static android.hardware.display.ColorDisplayManager.COLOR_MODE_BOOSTED;
import static android.hardware.display.ColorDisplayManager.COLOR_MODE_NATURAL;
import static android.hardware.display.ColorDisplayManager.COLOR_MODE_SATURATED;
+import static android.hardware.display.ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MAX;
+import static android.hardware.display.ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MIN;
import static com.android.server.display.color.DisplayTransformManager.LEVEL_COLOR_MATRIX_NIGHT_DISPLAY;
@@ -822,6 +824,9 @@
return COLOR_MODE_SATURATED;
} else if (displayColorSetting == 2) {
return COLOR_MODE_AUTOMATIC;
+ } else if (displayColorSetting >= VENDOR_COLOR_MODE_RANGE_MIN
+ && displayColorSetting <= VENDOR_COLOR_MODE_RANGE_MAX) {
+ return displayColorSetting;
} else {
return -1;
}