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

Commit 84f11774 authored by Sihua Ma's avatar Sihua Ma Committed by Android (Google) Code Review
Browse files

Merge "Wrap service connection in try-catch block" into main

parents 06a8068e 6d3d2904
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -1684,10 +1684,14 @@ public class AppWidgetManager {
            private IBinder mIBinder;

            ConnectionTask(@NonNull FilterComparison filter) {
                try {
                    mContext.bindService(filter.getIntent(),
                            Context.BindServiceFlags.of(Context.BIND_AUTO_CREATE),
                            mHandler::post,
                            this);
                } catch (Exception e) {
                    Log.e(TAG, "Error connecting to service in connection cache", e);
                }
            }

            @Override
@@ -1737,7 +1741,11 @@ public class AppWidgetManager {
                    handleNext();
                    return;
                }
                try {
                    mContext.unbindService(this);
                } catch (Exception e) {
                    Log.e(TAG, "Error unbinding the cached connection", e);
                }
                mActiveConnections.values().remove(this);
            }
        }