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

Commit 23a51303 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Wallpaper clean up as a result of getting rid of USE_SURFACE_VIEW_FOR_PREVIEW flag

Bug: 159755324
Test: manual
Change-Id: I47e283b90fb8711cc18fb746af42e9c9c62af444
parent 385ce933
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.customization.model.grid;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Pair;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -66,7 +65,7 @@ public class GridOptionsManager implements CustomizationManager<GridOption> {
        return mProvider.renderPreview(gridName, bundle);
    }

    private static class FetchTask extends AsyncTask<Void, Void, Pair<List<GridOption>, String>> {
    private static class FetchTask extends AsyncTask<Void, Void, List<GridOption>> {
        private final LauncherGridOptionsProvider mProvider;
        @Nullable private final OptionsFetchedListener<GridOption> mCallback;
        private final boolean mReload;
@@ -79,16 +78,15 @@ public class GridOptionsManager implements CustomizationManager<GridOption> {
        }

        @Override
        protected Pair<List<GridOption>, String> doInBackground(Void[] params) {
        protected List<GridOption> doInBackground(Void[] params) {
            return mProvider.fetch(mReload);
        }

        @Override
        protected void onPostExecute(Pair<List<GridOption>, String> gridOptionsResult) {
        protected void onPostExecute(List<GridOption> gridOptions) {
            if (mCallback != null) {
                if (gridOptionsResult != null && gridOptionsResult.first != null
                        && !gridOptionsResult.first.isEmpty()) {
                    mCallback.onOptionsLoaded(gridOptionsResult.first);
                if (gridOptions != null && !gridOptions.isEmpty()) {
                    mCallback.onOptionsLoaded(gridOptions);
                } else {
                    mCallback.onError(null);
                }
+3 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Pair;
import android.view.SurfaceView;

import androidx.annotation.Nullable;
@@ -59,7 +58,6 @@ public class LauncherGridOptionsProvider {
    private final Context mContext;
    private final PreviewUtils mPreviewUtils;
    private List<GridOption> mOptions;
    private String mVersion;

    public LauncherGridOptionsProvider(Context context, String authorityMetadataKey) {
        mPreviewUtils = new PreviewUtils(context, authorityMetadataKey);
@@ -76,19 +74,18 @@ public class LauncherGridOptionsProvider {
     */
    @WorkerThread
    @Nullable
    Pair<List<GridOption>, String> fetch(boolean reload) {
    List<GridOption> fetch(boolean reload) {
        if (!areGridsAvailable()) {
            return null;
        }
        if (mOptions != null && !reload) {
            return Pair.create(mOptions, mVersion);
            return mOptions;
        }
        ContentResolver resolver = mContext.getContentResolver();
        String iconPath = mContext.getResources().getString(Resources.getSystem().getIdentifier(
                ResourceConstants.CONFIG_ICON_MASK, "string", ResourceConstants.ANDROID_PACKAGE));
        try (Cursor c = resolver.query(mPreviewUtils.getUri(LIST_OPTIONS), null, null, null,
                null)) {
            mVersion = c.getExtras().getString(METADATA_KEY_PREVIEW_VERSION);
            mOptions = new ArrayList<>();
            while(c.moveToNext()) {
                String name = c.getString(c.getColumnIndex(COL_NAME));
@@ -105,9 +102,8 @@ public class LauncherGridOptionsProvider {
            Glide.get(mContext).clearDiskCache();
        } catch (Exception e) {
            mOptions = null;
            mVersion = null;
        }
        return Pair.create(mOptions, mVersion);
        return mOptions;
    }

    /**