diff options
15 files changed, 70 insertions, 15 deletions
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java index b9d3e75b9943..d0791cf93469 100644 --- a/core/java/android/app/WallpaperColors.java +++ b/core/java/android/app/WallpaperColors.java @@ -136,12 +136,12 @@ public final class WallpaperColors implements Parcelable { } final int bitmapArea = bitmap.getWidth() * bitmap.getHeight(); + boolean shouldRecycle = false; if (bitmapArea > MAX_WALLPAPER_EXTRACTION_AREA) { + shouldRecycle = true; Size optimalSize = calculateOptimalSize(bitmap.getWidth(), bitmap.getHeight()); - Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, optimalSize.getWidth(), + bitmap = Bitmap.createScaledBitmap(bitmap, optimalSize.getWidth(), optimalSize.getHeight(), true /* filter */); - bitmap.recycle(); - bitmap = scaledBitmap; } final Palette palette = Palette @@ -181,6 +181,11 @@ public final class WallpaperColors implements Parcelable { } int hints = calculateHints(bitmap); + + if (shouldRecycle) { + bitmap.recycle(); + } + return new WallpaperColors(primary, secondary, tertiary, hints); } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index a37e89ebcad1..c76ca6dbbe49 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -40,7 +40,7 @@ import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFIC import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; import static android.os.Build.VERSION_CODES.O; import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER; -import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; +import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED; import android.annotation.IntRange; import android.annotation.NonNull; @@ -4299,7 +4299,7 @@ public class PackageParser { sa.getString(R.styleable.AndroidManifestActivity_enableVrMode); a.info.rotationAnimation = - sa.getInt(R.styleable.AndroidManifestActivity_rotationAnimation, ROTATION_ANIMATION_ROTATE); + sa.getInt(R.styleable.AndroidManifestActivity_rotationAnimation, ROTATION_ANIMATION_UNSPECIFIED); a.info.colorMode = sa.getInt(R.styleable.AndroidManifestActivity_colorMode, ActivityInfo.COLOR_MODE_DEFAULT); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 050aa4d66c14..8e550dc1cb54 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1751,6 +1751,13 @@ public interface WindowManager extends ViewManager { public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; /** + * Unspecified value for {@link #rotationAnimation} indicating + * a lack of preference. + * @hide + */ + public static final int ROTATION_ANIMATION_UNSPECIFIED = -1; + + /** * Value for {@link #rotationAnimation} which specifies that this * window will visually rotate in or out following a rotation. */ diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp index 9cf6a9d08890..4e6e512b69df 100644 --- a/core/jni/android_view_InputDevice.cpp +++ b/core/jni/android_view_InputDevice.cpp @@ -17,7 +17,7 @@ #include <input/Input.h> #include <android_runtime/AndroidRuntime.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <ScopedLocalRef.h> diff --git a/core/jni/android_view_KeyCharacterMap.cpp b/core/jni/android_view_KeyCharacterMap.cpp index e5519a752c39..586b26ef328f 100644 --- a/core/jni/android_view_KeyCharacterMap.cpp +++ b/core/jni/android_view_KeyCharacterMap.cpp @@ -20,7 +20,7 @@ #include <input/Input.h> #include <binder/Parcel.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include "android_os_Parcel.h" diff --git a/core/jni/include/android_runtime/AndroidRuntime.h b/core/jni/include/android_runtime/AndroidRuntime.h index c2189d4af86d..3ec8b1fe903f 100644 --- a/core/jni/include/android_runtime/AndroidRuntime.h +++ b/core/jni/include/android_runtime/AndroidRuntime.h @@ -26,7 +26,7 @@ #include <utils/Vector.h> #include <utils/threads.h> #include <pthread.h> -#include <nativehelper/jni.h> +#include <jni.h> namespace android { diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index d4cc3fb8ab6e..1f93b34c9186 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -20,7 +20,7 @@ #define LOG_TAG "AudioEffects-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include "media/AudioEffect.h" diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 0645543d4a74..f0cfeef197d8 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -20,7 +20,7 @@ #define LOG_TAG "visualizers-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <utils/threads.h> diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp index 9d0c1f84fada..f6706369f379 100644 --- a/media/jni/soundpool/android_media_SoundPool.cpp +++ b/media/jni/soundpool/android_media_SoundPool.cpp @@ -20,7 +20,7 @@ #define LOG_TAG "SoundPool-JNI" #include <utils/Log.h> -#include <nativehelper/jni.h> +#include <jni.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include "SoundPool.h" diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapper.java b/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapper.java index caa79297539d..6c79a6124ca2 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapper.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapper.java @@ -123,4 +123,9 @@ public interface PackageManagerWrapper { * @return the label as a CharSequence */ CharSequence loadLabel(ApplicationInfo app); + + /** + * Retrieve all activities that can be performed for the given intent. + */ + List<ResolveInfo> queryIntentActivities(Intent intent, int flags); } diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapperImpl.java b/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapperImpl.java index 9b2cd7cb6b28..dcb40b20365e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapperImpl.java +++ b/packages/SettingsLib/src/com/android/settingslib/applications/PackageManagerWrapperImpl.java @@ -113,4 +113,9 @@ public class PackageManagerWrapperImpl implements PackageManagerWrapper { public CharSequence loadLabel(ApplicationInfo app) { return app.loadLabel(mPm); } + + @Override + public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) { + return mPm.queryIntentActivities(intent, flags); + } } diff --git a/services/core/java/com/android/server/pm/BackgroundDexOptService.java b/services/core/java/com/android/server/pm/BackgroundDexOptService.java index 34092ad6607a..0f2864708fdb 100644 --- a/services/core/java/com/android/server/pm/BackgroundDexOptService.java +++ b/services/core/java/com/android/server/pm/BackgroundDexOptService.java @@ -99,6 +99,10 @@ public class BackgroundDexOptService extends JobService { getDowngradeUnusedAppsThresholdInMillis(); public static void schedule(Context context) { + if (isBackgroundDexoptDisabled()) { + return; + } + JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); // Schedule a one-off job which scans installed packages and updates @@ -477,4 +481,9 @@ public class BackgroundDexOptService extends JobService { } return TimeUnit.DAYS.toMillis(Long.parseLong(sysPropValue)); } + + private static boolean isBackgroundDexoptDisabled() { + return SystemProperties.getBoolean("pm.dexopt.disable_bg_dexopt" /* key */, + false /* default */); + } } diff --git a/services/core/java/com/android/server/pm/PermissionsState.java b/services/core/java/com/android/server/pm/PermissionsState.java index 8a427cd329e2..f4d2ad2c6eb0 100644 --- a/services/core/java/com/android/server/pm/PermissionsState.java +++ b/services/core/java/com/android/server/pm/PermissionsState.java @@ -427,7 +427,7 @@ public final class PermissionsState { mPermissionReviewRequired.put(userId, true); } else if ((oldFlags & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) != 0 && (newFlags & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) == 0) { - if (mPermissionReviewRequired != null) { + if (mPermissionReviewRequired != null && !hasPermissionRequiringReview(userId)) { mPermissionReviewRequired.delete(userId); if (mPermissionReviewRequired.size() <= 0) { mPermissionReviewRequired = null; @@ -438,6 +438,18 @@ public final class PermissionsState { return updated; } + private boolean hasPermissionRequiringReview(int userId) { + final int permissionCount = mPermissions.size(); + for (int i = 0; i < permissionCount; i++) { + final PermissionData permission = mPermissions.valueAt(i); + if ((permission.getFlags(userId) + & PackageManager.FLAG_PERMISSION_REVIEW_REQUIRED) != 0) { + return true; + } + } + return false; + } + public boolean updatePermissionFlagsForAllPermissions( int userId, int flagMask, int flagValues) { enforceValidUserId(userId); diff --git a/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java b/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java index 767f0e0993ef..b89ce1cd0f89 100644 --- a/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java +++ b/services/core/java/com/android/server/timezone/RulesManagerServiceHelperImpl.java @@ -18,6 +18,7 @@ package com.android.server.timezone; import android.content.Context; import android.content.pm.PackageManager; +import android.os.AsyncTask; import android.os.Binder; import android.os.ParcelFileDescriptor; @@ -56,10 +57,9 @@ final class RulesManagerServiceHelperImpl implements PermissionHelper, Executor return true; } - // TODO Wake lock required? + // TODO(nfuller): Wake lock required while running in background thread? @Override public void execute(Runnable runnable) { - // TODO Is there a better way? - new Thread(runnable).start(); + AsyncTask.execute(runnable); } } diff --git a/tests/Internal/src/android/app/WallpaperColorsTest.java b/tests/Internal/src/android/app/WallpaperColorsTest.java index 5bbd82bea3de..fb529b936e5c 100644 --- a/tests/Internal/src/android/app/WallpaperColorsTest.java +++ b/tests/Internal/src/android/app/WallpaperColorsTest.java @@ -77,4 +77,16 @@ public class WallpaperColorsTest { Assert.assertFalse("Light surface shouldn't support dark text " + "when it contains dark pixels", supportsDarkText); } + + /** + * WallpaperColors should not recycle bitmaps that it didn't create. + */ + @Test + public void wallpaperRecycleBitmapTest() { + Bitmap image = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888); + WallpaperColors.fromBitmap(image); + Canvas canvas = new Canvas(); + // This would crash: + canvas.drawBitmap(image, 0, 0, new Paint()); + } } |