am 0a361b10: Merge "Workaround for issue where the notifyDatasetChanged call chain is broken when Launcher is killed. (Bug 5703782)" into ics-mr1
* commit '0a361b10a665a3d158c846722290f26ce62276e1': Workaround for issue where the notifyDatasetChanged call chain is broken when Launcher is killed. (Bug 5703782)
This commit is contained in:
@@ -145,6 +145,9 @@ public abstract class RemoteViewsService extends Service {
|
|||||||
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(t, ex);
|
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(t, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public synchronized void onDataSetChangedAsync() {
|
||||||
|
onDataSetChanged();
|
||||||
|
}
|
||||||
public synchronized int getCount() {
|
public synchronized int getCount() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.widget.RemoteViews;
|
|||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
interface IRemoteViewsFactory {
|
interface IRemoteViewsFactory {
|
||||||
void onDataSetChanged();
|
void onDataSetChanged();
|
||||||
|
oneway void onDataSetChangedAsync();
|
||||||
oneway void onDestroy(in Intent intent);
|
oneway void onDestroy(in Intent intent);
|
||||||
int getCount();
|
int getCount();
|
||||||
RemoteViews getViewAt(int position);
|
RemoteViews getViewAt(int position);
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.Intent.FilterComparison;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.Intent.FilterComparison;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -39,6 +39,8 @@ import android.content.res.XmlResourceParser;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
@@ -74,6 +76,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
class AppWidgetService extends IAppWidgetService.Stub
|
class AppWidgetService extends IAppWidgetService.Stub
|
||||||
{
|
{
|
||||||
@@ -805,6 +808,45 @@ class AppWidgetService extends IAppWidgetService.Stub
|
|||||||
id.host.callbacks = null;
|
id.host.callbacks = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the host is unavailable, then we call the associated
|
||||||
|
// RemoteViewsFactory.onDataSetChanged() directly
|
||||||
|
if (id.host.callbacks == null) {
|
||||||
|
Set<FilterComparison> keys = mRemoteViewsServicesAppWidgets.keySet();
|
||||||
|
for (FilterComparison key : keys) {
|
||||||
|
if (mRemoteViewsServicesAppWidgets.get(key).contains(id.appWidgetId)) {
|
||||||
|
Intent intent = key.getIntent();
|
||||||
|
|
||||||
|
final ServiceConnection conn = new ServiceConnection() {
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
|
IRemoteViewsFactory cb =
|
||||||
|
IRemoteViewsFactory.Stub.asInterface(service);
|
||||||
|
try {
|
||||||
|
cb.onDataSetChangedAsync();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
mContext.unbindService(this);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(android.content.ComponentName name) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Bind to the service and call onDataSetChanged()
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user