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

Commit d0286de7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Catch potential SecurityExceptions while binding"

parents bad83b12 a54902ca
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -206,16 +206,21 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
                Log.d(TAG, "[" + mTag + "] binding to " + mBoundServiceInfo);
            }

            mRebinder = null;

            Intent bindIntent = new Intent(mBoundServiceInfo.getAction()).setComponent(
                    mBoundServiceInfo.getComponentName());
            try {
                if (!mContext.bindServiceAsUser(bindIntent, this,
                        BIND_AUTO_CREATE | BIND_NOT_FOREGROUND | BIND_NOT_VISIBLE,
                        mHandler, UserHandle.of(mBoundServiceInfo.getUserId()))) {
                    Log.e(TAG, "[" + mTag + "] unexpected bind failure - retrying later");
                    mRebinder = this::bind;
                    mHandler.postDelayed(mRebinder, RETRY_DELAY_MS);
            } else {
                mRebinder = null;
                }
            } catch (SecurityException e) {
                // if anything goes wrong it shouldn't crash the system server
                Log.e(TAG, "[" + mTag + "] " + mBoundServiceInfo + " bind failed", e);
            }
        }