Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aabf7411 authored by Danny Baumann's avatar Danny Baumann Committed by Steve Kondik
Browse files

Only access CMHW from main thread.

Some CMHW classes might expect that they're created in the main thread,
e.g. if they want to use Handlers.

Change-Id: I319709a423547368b3c4f047c2efbfab4c191953
parent 6bfff164
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -729,6 +729,19 @@ public class DisplaySettings extends SettingsPreferenceFragment implements

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
                private boolean mHasTapToWake;
                private boolean mHasSunlightEnhancement, mHasColorEnhancement;
                private boolean mHasDisplayGamma, mHasDisplayColor;

                @Override
                public void prepare() {
                    mHasTapToWake = isTapToWakeSupported();
                    mHasSunlightEnhancement = isSunlightEnhancementSupported();
                    mHasColorEnhancement = isColorEnhancementSupported();
                    mHasDisplayGamma = DisplayGamma.isSupported();
                    mHasDisplayColor = DisplayColor.isSupported();
                }

                @Override
                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
                        boolean enabled) {
@@ -761,22 +774,22 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
                            com.android.internal.R.bool.config_proximityCheckOnWake)) {
                        result.add(KEY_PROXIMITY_WAKE);
                    }
                    if (!isTapToWakeSupported()) {
                    if (!mHasTapToWake) {
                        result.add(KEY_TAP_TO_WAKE);
                    }
                    if (!isSunlightEnhancementSupported()) {
                    if (!mHasSunlightEnhancement) {
                        result.add(KEY_SUNLIGHT_ENHANCEMENT);
                    }
                    if (!isColorEnhancementSupported()) {
                    if (!mHasColorEnhancement) {
                        result.add(KEY_COLOR_ENHANCEMENT);
                    }
                    if (!isPostProcessingSupported(context)) {
                        result.add(KEY_SCREEN_COLOR_SETTINGS);
                    }
                    if (!DisplayColor.isSupported()) {
                    if (!mHasDisplayColor) {
                        result.add(KEY_DISPLAY_COLOR);
                    }
                    if (!DisplayGamma.isSupported()) {
                    if (!mHasDisplayGamma) {
                        result.add(KEY_DISPLAY_GAMMA);
                    }
                    if (!isAutomaticBrightnessAvailable(context.getResources())) {
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
    public BaseSearchIndexProvider() {
    }

    @Override
    public void prepare() {
    }

    @Override
    public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled) {
        return null;
+12 −0
Original line number Diff line number Diff line
@@ -522,6 +522,18 @@ public class Index {
        synchronized (mDataToProcess) {
            final UpdateIndexTask task = new UpdateIndexTask();
            UpdateData copy = mDataToProcess.copy();
            for (SearchIndexableData data : copy.dataToUpdate) {
                if (data instanceof SearchIndexableResource) {
                    SearchIndexableResource sir = (SearchIndexableResource) data;
                    final Class<?> clazz = sir.className != null
                            ? getIndexableClass(sir.className) : null;
                    final Indexable.SearchIndexProvider provider = clazz != null
                            ? getSearchIndexProvider(clazz) : null;
                    if (provider != null) {
                        provider.prepare();
                    }
                }
            }
            task.execute(copy);
            mDataToProcess.clear();
        }
+5 −0
Original line number Diff line number Diff line
@@ -65,5 +65,10 @@ public interface Indexable {
         * @return a list of {@link SearchIndexableRaw} references. Can be null.
         */
        List<String> getNonIndexableKeys(Context context);

        /**
         * Prepare for indexing. Guaranteed to be called from the main thread.
         */
        void prepare();
    }
}