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

Commit 8dbace2d authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Activity selections not always persisted by AcitivtyChooserView.

1. ActivityChooserModel was delegating the rsponsibility for reading
   and persisting data to its clients i.e. ActivityChooserView and
   the latter was persisting on detach from window. However, it is
   not guaranteed that this callback will be received leading to
   lack of presistence sometimes. Now the model is responsible for
   loading and persisting thus voiding the posisbility a misbehaved
   client to cause data loss.

bug:5061638

Change-Id: Ia2b7bb659f7b9abe8869c94b3eaa726ddd4e4fad
parent b5d4f971
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ public class ActivityChooserModel extends DataSetObservable {
                dataModel = new ActivityChooserModel(context, historyFileName);
                sDataModelRegistry.put(historyFileName, dataModel);
            }
            dataModel.readHistoricalData();
            return dataModel;
        }
    }
@@ -505,7 +506,7 @@ public class ActivityChooserModel extends DataSetObservable {
     *       data is read until this method is invoked.
     * <p>
     */
    public void readHistoricalData() {
    private void readHistoricalData() {
        synchronized (mInstanceLock) {
            if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) {
                return;
@@ -527,7 +528,7 @@ public class ActivityChooserModel extends DataSetObservable {
     * @throws IllegalStateException If this method is called before a call to
     *         {@link #readHistoricalData()}.
     */
    public void persistHistoricalData() {
    private void persistHistoricalData() {
        synchronized (mInstanceLock) {
            if (!mReadShareHistoryCalled) {
                throw new IllegalStateException("No preceding call to #readHistoricalData");
@@ -629,6 +630,7 @@ public class ActivityChooserModel extends DataSetObservable {
            if (added) {
                mHistoricalRecordsChanged = true;
                pruneExcessiveHistoricalRecordsLocked();
                persistHistoricalData();
                sortActivities();
            }
            return added;
+0 −2
Original line number Diff line number Diff line
@@ -307,7 +307,6 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
        ActivityChooserModel dataModel = mAdapter.getDataModel();
        if (dataModel != null) {
            dataModel.registerObserver(mModelDataSetOberver);
            dataModel.readHistoricalData();
        }
        mIsAttachedToWindow = true;
    }
@@ -318,7 +317,6 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
        ActivityChooserModel dataModel = mAdapter.getDataModel();
        if (dataModel != null) {
            dataModel.unregisterObserver(mModelDataSetOberver);
            dataModel.persistHistoricalData();
        }
        mIsAttachedToWindow = false;
    }