Merge "[MediaProjection] Clarify createVirtualDisplay exception javadoc" into udc-dev
diff --git a/core/java/android/app/smartspace/SmartspaceAction.java b/core/java/android/app/smartspace/SmartspaceAction.java
index f17b044..4475fc5 100644
--- a/core/java/android/app/smartspace/SmartspaceAction.java
+++ b/core/java/android/app/smartspace/SmartspaceAction.java
@@ -348,6 +348,10 @@
*/
@NonNull
public SmartspaceAction build() {
+ if (mIcon != null) {
+ mIcon.convertToAshmem();
+ }
+
return new SmartspaceAction(mId, mIcon, mTitle, mSubtitle, mContentDescription,
mPendingIntent, mIntent, mUserHandle, mExtras);
}
diff --git a/core/java/android/app/smartspace/uitemplatedata/Icon.java b/core/java/android/app/smartspace/uitemplatedata/Icon.java
index 6bdc926..b9d90bf 100644
--- a/core/java/android/app/smartspace/uitemplatedata/Icon.java
+++ b/core/java/android/app/smartspace/uitemplatedata/Icon.java
@@ -171,6 +171,7 @@
*/
@NonNull
public Icon build() {
+ mIcon.convertToAshmem();
return new Icon(mIcon, mContentDescription, mShouldTint);
}
}
diff --git a/services/core/java/com/android/server/wm/LetterboxConfigurationPersister.java b/services/core/java/com/android/server/wm/LetterboxConfigurationPersister.java
index 3b10deb..7563397 100644
--- a/services/core/java/com/android/server/wm/LetterboxConfigurationPersister.java
+++ b/services/core/java/com/android/server/wm/LetterboxConfigurationPersister.java
@@ -16,6 +16,8 @@
package com.android.server.wm;
+import static android.os.StrictMode.setThreadPolicy;
+
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -23,6 +25,8 @@
import android.annotation.Nullable;
import android.content.Context;
import android.os.Environment;
+import android.os.StrictMode;
+import android.os.StrictMode.ThreadPolicy;
import android.util.AtomicFile;
import android.util.Slog;
@@ -125,7 +129,7 @@
final File prefFiles = new File(configFolder, LETTERBOX_CONFIGURATION_FILENAME);
mConfigurationFile = new AtomicFile(prefFiles);
mPersisterQueue = persisterQueue;
- readCurrentConfiguration();
+ runWithDiskReadsThreadPolicy(this::readCurrentConfiguration);
}
/**
@@ -275,6 +279,20 @@
}
}
+ // The LetterboxConfigurationDeviceConfig needs to access the
+ // file with the current reachability position once when the
+ // device boots. Because DisplayThread uses allowIo=false
+ // accessing a file triggers a DiskReadViolation.
+ // Here we use StrictMode to allow the current thread to read
+ // the AtomicFile once in the current thread restoring the
+ // original ThreadPolicy after that.
+ private void runWithDiskReadsThreadPolicy(Runnable runnable) {
+ final ThreadPolicy currentPolicy = StrictMode.getThreadPolicy();
+ setThreadPolicy(new ThreadPolicy.Builder().permitDiskReads().build());
+ runnable.run();
+ setThreadPolicy(currentPolicy);
+ }
+
private static class UpdateValuesCommand implements
PersisterQueue.WriteQueueItem<UpdateValuesCommand> {