Merge "Activity selections not always persisted by AcitivtyChooserView."
diff --git a/core/java/android/widget/ActivityChooserModel.java b/core/java/android/widget/ActivityChooserModel.java
index d7429b3..4b0a6da 100644
--- a/core/java/android/widget/ActivityChooserModel.java
+++ b/core/java/android/widget/ActivityChooserModel.java
@@ -317,6 +317,7 @@
dataModel = new ActivityChooserModel(context, historyFileName);
sDataModelRegistry.put(historyFileName, dataModel);
}
+ dataModel.readHistoricalData();
return dataModel;
}
}
@@ -505,7 +506,7 @@
* 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 @@
* @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 @@
if (added) {
mHistoricalRecordsChanged = true;
pruneExcessiveHistoricalRecordsLocked();
+ persistHistoricalData();
sortActivities();
}
return added;
diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java
index 5b69aa8..d85f8a4 100644
--- a/core/java/android/widget/ActivityChooserView.java
+++ b/core/java/android/widget/ActivityChooserView.java
@@ -307,7 +307,6 @@
ActivityChooserModel dataModel = mAdapter.getDataModel();
if (dataModel != null) {
dataModel.registerObserver(mModelDataSetOberver);
- dataModel.readHistoricalData();
}
mIsAttachedToWindow = true;
}
@@ -318,7 +317,6 @@
ActivityChooserModel dataModel = mAdapter.getDataModel();
if (dataModel != null) {
dataModel.unregisterObserver(mModelDataSetOberver);
- dataModel.persistHistoricalData();
}
mIsAttachedToWindow = false;
}