am 9f48e316: am e2ed349c: Merge "Removing context ref from AppWidgetHost. (Bug 18769791)" into lmp-mr1-dev

* commit '9f48e3160f2768d3322670cbbcc606c9eef76bad':
  Removing context ref from AppWidgetHost. (Bug 18769791)
This commit is contained in:
Winson Chung
2014-12-18 00:26:16 +00:00
committed by Android Git Automerger

View File

@@ -57,7 +57,7 @@ public class AppWidgetHost {
static IAppWidgetService sService; static IAppWidgetService sService;
private DisplayMetrics mDisplayMetrics; private DisplayMetrics mDisplayMetrics;
Context mContext; private String mContextOpPackageName;
Handler mHandler; Handler mHandler;
int mHostId; int mHostId;
Callbacks mCallbacks = new Callbacks(); Callbacks mCallbacks = new Callbacks();
@@ -128,7 +128,7 @@ public class AppWidgetHost {
* @hide * @hide
*/ */
public AppWidgetHost(Context context, int hostId, OnClickHandler handler, Looper looper) { public AppWidgetHost(Context context, int hostId, OnClickHandler handler, Looper looper) {
mContext = context; mContextOpPackageName = context.getOpPackageName();
mHostId = hostId; mHostId = hostId;
mOnClickHandler = handler; mOnClickHandler = handler;
mHandler = new UpdateHandler(looper); mHandler = new UpdateHandler(looper);
@@ -154,7 +154,7 @@ public class AppWidgetHost {
int[] updatedIds; int[] updatedIds;
ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>();
try { try {
updatedIds = sService.startListening(mCallbacks, mContext.getOpPackageName(), mHostId, updatedIds = sService.startListening(mCallbacks, mContextOpPackageName, mHostId,
updatedViews); updatedViews);
} }
catch (RemoteException e) { catch (RemoteException e) {
@@ -173,7 +173,7 @@ public class AppWidgetHost {
*/ */
public void stopListening() { public void stopListening() {
try { try {
sService.stopListening(mContext.getOpPackageName(), mHostId); sService.stopListening(mContextOpPackageName, mHostId);
} }
catch (RemoteException e) { catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
@@ -191,7 +191,7 @@ public class AppWidgetHost {
*/ */
public int allocateAppWidgetId() { public int allocateAppWidgetId() {
try { try {
return sService.allocateAppWidgetId(mContext.getOpPackageName(), mHostId); return sService.allocateAppWidgetId(mContextOpPackageName, mHostId);
} }
catch (RemoteException e) { catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
@@ -221,7 +221,7 @@ public class AppWidgetHost {
int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) { int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) {
try { try {
IntentSender intentSender = sService.createAppWidgetConfigIntentSender( IntentSender intentSender = sService.createAppWidgetConfigIntentSender(
mContext.getOpPackageName(), appWidgetId, intentFlags); mContextOpPackageName, appWidgetId, intentFlags);
if (intentSender != null) { if (intentSender != null) {
activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0, activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0,
options); options);
@@ -245,7 +245,7 @@ public class AppWidgetHost {
if (sService == null) { if (sService == null) {
bindService(); bindService();
} }
return sService.getAppWidgetIdsForHost(mContext.getOpPackageName(), mHostId); return sService.getAppWidgetIdsForHost(mContextOpPackageName, mHostId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
} }
@@ -262,7 +262,7 @@ public class AppWidgetHost {
synchronized (mViews) { synchronized (mViews) {
mViews.remove(appWidgetId); mViews.remove(appWidgetId);
try { try {
sService.deleteAppWidgetId(mContext.getOpPackageName(), appWidgetId); sService.deleteAppWidgetId(mContextOpPackageName, appWidgetId);
} }
catch (RemoteException e) { catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
@@ -280,7 +280,7 @@ public class AppWidgetHost {
*/ */
public void deleteHost() { public void deleteHost() {
try { try {
sService.deleteHost(mContext.getOpPackageName(), mHostId); sService.deleteHost(mContextOpPackageName, mHostId);
} }
catch (RemoteException e) { catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
@@ -310,7 +310,7 @@ public class AppWidgetHost {
*/ */
public final AppWidgetHostView createView(Context context, int appWidgetId, public final AppWidgetHostView createView(Context context, int appWidgetId,
AppWidgetProviderInfo appWidget) { AppWidgetProviderInfo appWidget) {
AppWidgetHostView view = onCreateView(mContext, appWidgetId, appWidget); AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget);
view.setOnClickHandler(mOnClickHandler); view.setOnClickHandler(mOnClickHandler);
view.setAppWidget(appWidgetId, appWidget); view.setAppWidget(appWidgetId, appWidget);
synchronized (mViews) { synchronized (mViews) {
@@ -318,7 +318,7 @@ public class AppWidgetHost {
} }
RemoteViews views; RemoteViews views;
try { try {
views = sService.getAppWidgetViews(mContext.getOpPackageName(), appWidgetId); views = sService.getAppWidgetViews(mContextOpPackageName, appWidgetId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException("system server dead?", e); throw new RuntimeException("system server dead?", e);
} }