diff options
author | Winson Chung <winsonc@google.com> | 2011-02-21 13:57:45 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-02-25 14:06:47 -0800 |
commit | 84bbb020217adcdfe0694c44ccab57e208ffde16 (patch) | |
tree | 35b5e3e319a134a82ed526742ce3e8ac8d91a329 /core/java | |
parent | e4ce73763de01a6d3e0281ad90f6eca08d455f10 (diff) | |
download | frameworks_base-84bbb020217adcdfe0694c44ccab57e208ffde16.zip frameworks_base-84bbb020217adcdfe0694c44ccab57e208ffde16.tar.gz frameworks_base-84bbb020217adcdfe0694c44ccab57e208ffde16.tar.bz2 |
Fixing issue where RemoteViewsService.onDestroy() was never being called.
Change-Id: I15ad04eee18bc3e09d4846c7f2f2d2d8d168e518
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/RemoteViewsAdapter.java | 3 | ||||
-rw-r--r-- | core/java/android/widget/RemoteViewsService.java | 24 | ||||
-rw-r--r-- | core/java/com/android/internal/widget/IRemoteViewsFactory.aidl | 2 |
3 files changed, 19 insertions, 10 deletions
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java index 13a911b..2d2165b 100644 --- a/core/java/android/widget/RemoteViewsAdapter.java +++ b/core/java/android/widget/RemoteViewsAdapter.java @@ -20,7 +20,6 @@ import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; -import java.util.Map; import android.appwidget.AppWidgetManager; import android.content.Context; @@ -33,8 +32,8 @@ import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.View.MeasureSpec; +import android.view.ViewGroup; import com.android.internal.widget.IRemoteViewsAdapterConnection; import com.android.internal.widget.IRemoteViewsFactory; diff --git a/core/java/android/widget/RemoteViewsService.java b/core/java/android/widget/RemoteViewsService.java index fb2c416..e0b08d4 100644 --- a/core/java/android/widget/RemoteViewsService.java +++ b/core/java/android/widget/RemoteViewsService.java @@ -21,8 +21,6 @@ import java.util.HashMap; import android.app.Service; import android.content.Intent; import android.os.IBinder; -import android.util.Log; -import android.util.Pair; import com.android.internal.widget.IRemoteViewsFactory; @@ -40,9 +38,9 @@ public abstract class RemoteViewsService extends Service { // reclaimed), the references to the factories that are created need to be stored and used when // the service is restarted (in response to user input for example). When the process is // destroyed, so is this static cache of RemoteViewsFactories. - private static final HashMap<Intent.FilterComparison, RemoteViewsFactory> mRemoteViewFactories = + private static final HashMap<Intent.FilterComparison, RemoteViewsFactory> sRemoteViewFactories = new HashMap<Intent.FilterComparison, RemoteViewsFactory>(); - private final Object mLock = new Object(); + private static final Object sLock = new Object(); /** * An interface for an adapter between a remote collection view (ListView, GridView, etc) and @@ -162,6 +160,16 @@ public abstract class RemoteViewsService extends Service { public synchronized boolean hasStableIds() { return mFactory.hasStableIds(); } + public void onDestroy(Intent intent) { + synchronized (sLock) { + Intent.FilterComparison fc = new Intent.FilterComparison(intent); + if (RemoteViewsService.sRemoteViewFactories.containsKey(fc)) { + RemoteViewsFactory factory = RemoteViewsService.sRemoteViewFactories.get(fc); + factory.onDestroy(); + RemoteViewsService.sRemoteViewFactories.remove(fc); + } + } + } private RemoteViewsFactory mFactory; private boolean mIsCreated; @@ -169,17 +177,17 @@ public abstract class RemoteViewsService extends Service { @Override public IBinder onBind(Intent intent) { - synchronized (mLock) { + synchronized (sLock) { Intent.FilterComparison fc = new Intent.FilterComparison(intent); RemoteViewsFactory factory = null; boolean isCreated = false; - if (!mRemoteViewFactories.containsKey(fc)) { + if (!sRemoteViewFactories.containsKey(fc)) { factory = onGetViewFactory(intent); - mRemoteViewFactories.put(fc, factory); + sRemoteViewFactories.put(fc, factory); factory.onCreate(); isCreated = false; } else { - factory = mRemoteViewFactories.get(fc); + factory = sRemoteViewFactories.get(fc); isCreated = true; } return new RemoteViewsFactoryAdapter(factory, isCreated); diff --git a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl index 60eca00..5857acb 100644 --- a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl +++ b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl @@ -16,11 +16,13 @@ package com.android.internal.widget; +import android.content.Intent; import android.widget.RemoteViews; /** {@hide} */ interface IRemoteViewsFactory { void onDataSetChanged(); + void onDestroy(in Intent intent); int getCount(); RemoteViews getViewAt(int position); RemoteViews getLoadingView(); |