Loading iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +19 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteReadOnlyDatabaseException; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; Loading Loading @@ -187,6 +188,7 @@ public abstract class BaseIconCache { } private synchronized void updateIconParamsBg(final int iconDpi, final int iconPixelSize) { try { mIconDpi = iconDpi; mDefaultIcon = null; mUserFlagOpMap.clear(); Loading @@ -194,6 +196,16 @@ public abstract class BaseIconCache { mIconDb.close(); mIconDb = new IconDB(mContext, mDbFileName, iconPixelSize); mCache.clear(); } catch (SQLiteReadOnlyDatabaseException e) { // This is known to happen during repeated backup and restores, if the Launcher is in // restricted mode. When the launcher is loading and the backup restore is being cleared // there can be a conflict where one DB is trying to delete the DB file, and the other // is attempting to write to it. The effect is that launcher crashes, then the backup / // restore process fails, then the user's home screen icons fail to restore. Adding this // try / catch will stop the crash, and LoaderTask will sanitize any residual icon data, // leading to a completed backup / restore and a better experience for our customers. Log.e(TAG, "failed to clear the launcher's icon db or cache.", e); } } @Nullable Loading iconloaderlib/src/com/android/launcher3/util/ComponentKey.java +2 −2 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ public class ComponentKey { @Override public boolean equals(Object o) { ComponentKey other = (ComponentKey) o; return other.componentName.equals(componentName) && other.user.equals(user); return (o instanceof ComponentKey other) && other.componentName.equals(componentName) && other.user.equals(user); } /** Loading monet/tests/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ android_test { "**/*.kt", ], libs: [ "android.test.runner", "android.test.base", "android.test.runner.stubs.system", "android.test.base.stubs.system", ], test_suites: ["device-tests"], } msdllib/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ android_library { android_library { name: "msdl-tests-base", libs: [ "android.test.base", "android.test.base.stubs.system", "androidx.test.core", ], static_libs: [ Loading msdllib/src/com/google/android/msdl/data/repository/MSDLRepository.kt +14 −8 Original line number Diff line number Diff line Loading @@ -15,23 +15,24 @@ */ package com.google.android.msdl.data.repository import androidx.annotation.VisibleForTesting import com.google.android.msdl.data.model.HapticToken import com.google.android.msdl.data.model.SoundToken /** * A repository of data for [ReferenceToken]. * A repository of data for [HapticToken] and [SoundToken]. * * The principle behind this repository is to hold the data for all tokens as a cache in memory. * This is only suitable if the number of tokens and the data stored is manageable. The purpose of * this design choice is to provide fast and easy access to the data when required to be played by * UI interactions. */ interface MSDLRepository { sealed interface MSDLRepository { /** * Get the [MSDLData] that corresponds to the given haptic reference token. This function needs * to be fast since it will be called repeatedly to deliver feedback. If necessary, a caching * strategy should be applied. * Get the [MSDLHapticData] that corresponds to the given haptic reference token. This function * needs to be fast since it will be called repeatedly to deliver feedback. If necessary, a * caching strategy should be applied. * * @param[hapticToken] The [HapticToken] that points to the data. * @return the data that corresponds to the token at the time this function is called. Loading @@ -39,14 +40,19 @@ interface MSDLRepository { fun getHapticData(hapticToken: HapticToken): MSDLHapticData? /** * Get the [MSDLData] that corresponds to the given sound reference token. This function needs * to be fast since it will be called repeatedly to deliver feedback. If necessary, a caching * strategy should be applied. * Get the [MSDLSoundData] that corresponds to the given sound reference token. This function * needs to be fast since it will be called repeatedly to deliver feedback. If necessary, a * caching strategy should be applied. * * @param[soundToken] The [SoundToken] that points to the data. * @return the data that corresponds to the token at the time this function is called. */ fun getAudioData(soundToken: SoundToken): MSDLSoundData? companion object { @VisibleForTesting fun createRepository(): MSDLRepository = MSDLRepositoryImpl() } } /** Representation of data contained in a [MSDLRepository] */ Loading Loading
iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +19 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.res.Resources; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteReadOnlyDatabaseException; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; Loading Loading @@ -187,6 +188,7 @@ public abstract class BaseIconCache { } private synchronized void updateIconParamsBg(final int iconDpi, final int iconPixelSize) { try { mIconDpi = iconDpi; mDefaultIcon = null; mUserFlagOpMap.clear(); Loading @@ -194,6 +196,16 @@ public abstract class BaseIconCache { mIconDb.close(); mIconDb = new IconDB(mContext, mDbFileName, iconPixelSize); mCache.clear(); } catch (SQLiteReadOnlyDatabaseException e) { // This is known to happen during repeated backup and restores, if the Launcher is in // restricted mode. When the launcher is loading and the backup restore is being cleared // there can be a conflict where one DB is trying to delete the DB file, and the other // is attempting to write to it. The effect is that launcher crashes, then the backup / // restore process fails, then the user's home screen icons fail to restore. Adding this // try / catch will stop the crash, and LoaderTask will sanitize any residual icon data, // leading to a completed backup / restore and a better experience for our customers. Log.e(TAG, "failed to clear the launcher's icon db or cache.", e); } } @Nullable Loading
iconloaderlib/src/com/android/launcher3/util/ComponentKey.java +2 −2 Original line number Diff line number Diff line Loading @@ -48,8 +48,8 @@ public class ComponentKey { @Override public boolean equals(Object o) { ComponentKey other = (ComponentKey) o; return other.componentName.equals(componentName) && other.user.equals(user); return (o instanceof ComponentKey other) && other.componentName.equals(componentName) && other.user.equals(user); } /** Loading
monet/tests/Android.bp +2 −2 Original line number Diff line number Diff line Loading @@ -35,8 +35,8 @@ android_test { "**/*.kt", ], libs: [ "android.test.runner", "android.test.base", "android.test.runner.stubs.system", "android.test.base.stubs.system", ], test_suites: ["device-tests"], }
msdllib/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ android_library { android_library { name: "msdl-tests-base", libs: [ "android.test.base", "android.test.base.stubs.system", "androidx.test.core", ], static_libs: [ Loading
msdllib/src/com/google/android/msdl/data/repository/MSDLRepository.kt +14 −8 Original line number Diff line number Diff line Loading @@ -15,23 +15,24 @@ */ package com.google.android.msdl.data.repository import androidx.annotation.VisibleForTesting import com.google.android.msdl.data.model.HapticToken import com.google.android.msdl.data.model.SoundToken /** * A repository of data for [ReferenceToken]. * A repository of data for [HapticToken] and [SoundToken]. * * The principle behind this repository is to hold the data for all tokens as a cache in memory. * This is only suitable if the number of tokens and the data stored is manageable. The purpose of * this design choice is to provide fast and easy access to the data when required to be played by * UI interactions. */ interface MSDLRepository { sealed interface MSDLRepository { /** * Get the [MSDLData] that corresponds to the given haptic reference token. This function needs * to be fast since it will be called repeatedly to deliver feedback. If necessary, a caching * strategy should be applied. * Get the [MSDLHapticData] that corresponds to the given haptic reference token. This function * needs to be fast since it will be called repeatedly to deliver feedback. If necessary, a * caching strategy should be applied. * * @param[hapticToken] The [HapticToken] that points to the data. * @return the data that corresponds to the token at the time this function is called. Loading @@ -39,14 +40,19 @@ interface MSDLRepository { fun getHapticData(hapticToken: HapticToken): MSDLHapticData? /** * Get the [MSDLData] that corresponds to the given sound reference token. This function needs * to be fast since it will be called repeatedly to deliver feedback. If necessary, a caching * strategy should be applied. * Get the [MSDLSoundData] that corresponds to the given sound reference token. This function * needs to be fast since it will be called repeatedly to deliver feedback. If necessary, a * caching strategy should be applied. * * @param[soundToken] The [SoundToken] that points to the data. * @return the data that corresponds to the token at the time this function is called. */ fun getAudioData(soundToken: SoundToken): MSDLSoundData? companion object { @VisibleForTesting fun createRepository(): MSDLRepository = MSDLRepositoryImpl() } } /** Representation of data contained in a [MSDLRepository] */ Loading