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

Commit 5eb40a85 authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "Addressing issues associated RemoteViewsAdapter's service crashes / disconnects"

parents fc3948a8 fb60386b
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -5184,6 +5184,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    public void onRemoteAdapterConnected() {
        if (mRemoteAdapter != mAdapter) {
            setAdapter(mRemoteAdapter);
        } else if (mRemoteAdapter != null) {
            mRemoteAdapter.superNotifyDataSetChanged();
        }
    }

@@ -5191,10 +5193,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     * Called back when the adapter disconnects from the RemoteViewsService.
     */
    public void onRemoteAdapterDisconnected() {
        if (mRemoteAdapter == mAdapter) {
            mRemoteAdapter = null;
            setAdapter(null);
        }
        // If the remote adapter disconnects, we keep it around
        // since the currently displayed items are still cached.
        // Further, we want the service to eventually reconnect
        // when necessary, as triggered by this view requesting
        // items from the Adapter.
    }

    /**
+7 −4
Original line number Diff line number Diff line
@@ -964,6 +964,8 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
    public void onRemoteAdapterConnected() {
        if (mRemoteViewsAdapter != mAdapter) {
            setAdapter(mRemoteViewsAdapter);
        } else if (mRemoteViewsAdapter != null) {
            mRemoteViewsAdapter.superNotifyDataSetChanged();
        }
    }

@@ -971,10 +973,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
     * Called back when the adapter disconnects from the RemoteViewsService.
     */
    public void onRemoteAdapterDisconnected() {
        if (mRemoteViewsAdapter != mAdapter) {
            mRemoteViewsAdapter = null;
            setAdapter(mRemoteViewsAdapter);
        }
        // If the remote adapter disconnects, we keep it around
        // since the currently displayed items are still cached.
        // Further, we want the service to eventually reconnect
        // when necessary, as triggered by this view requesting
        // items from the Adapter.
    }

    public void advance() {
+1 −2
Original line number Diff line number Diff line
@@ -1535,7 +1535,6 @@ public class ListView extends AbsListView {
            // reset the focus restoration
            View focusLayoutRestoreDirectChild = null;


            // Don't put header or footer views into the Recycler. Those are
            // already cached in mHeaderViews;
            if (dataChanged) {
+3 −8
Original line number Diff line number Diff line
@@ -148,11 +148,6 @@ public class RemoteViewsAdapter extends BaseAdapter {
            adapter.mMainQueue.removeMessages(0);
            adapter.mWorkerQueue.removeMessages(0);

            // Clear the cache (the meta data will be re-requested on service re-connection)
            synchronized (adapter.mCache) {
                adapter.mCache.reset();
            }

            final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
            if (callback != null) {
                callback.onRemoteAdapterDisconnected();
@@ -880,7 +875,7 @@ public class RemoteViewsAdapter extends BaseAdapter {
        // a chance to update itself and return new meta data associated with the new data.
    }

    private void superNotifyDataSetChanged() {
    void superNotifyDataSetChanged() {
        super.notifyDataSetChanged();
    }