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

Commit 44f71104 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add rebindService API to update binding flags." into main

parents cf8347ad 3f6d9e89
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11200,6 +11200,7 @@ package android.content {
    method public abstract android.database.sqlite.SQLiteDatabase openOrCreateDatabase(String, int, android.database.sqlite.SQLiteDatabase.CursorFactory);
    method public abstract android.database.sqlite.SQLiteDatabase openOrCreateDatabase(String, int, android.database.sqlite.SQLiteDatabase.CursorFactory, @Nullable android.database.DatabaseErrorHandler);
    method @Deprecated public abstract android.graphics.drawable.Drawable peekWallpaper();
    method @FlaggedApi("android.content.flags.enable_update_service_bindings") public void rebindService(@NonNull android.content.ServiceConnection, @NonNull android.content.Context.BindServiceFlags);
    method public void registerComponentCallbacks(android.content.ComponentCallbacks);
    method public void registerDeviceIdChangeListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.IntConsumer);
    method @Nullable public abstract android.content.Intent registerReceiver(@Nullable android.content.BroadcastReceiver, android.content.IntentFilter);
+1 −1
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ public abstract class ActivityManagerInternal {
    public static final int OOM_ADJ_REASON_SERVICE_BINDER_CALL = 25;

    /**
     * Oom Adj Reason: Batched updated request.
     * Oom Adj Reason: Batched service binding update request
     */
    public static final int OOM_ADJ_REASON_BATCH_UPDATE_REQUEST = 26;

+26 −0
Original line number Diff line number Diff line
@@ -2372,6 +2372,32 @@ class ContextImpl extends Context {
        }
    }

    @Override
    public void rebindService(ServiceConnection conn, @NonNull BindServiceFlags flags) {
        if (conn == null) {
            throw new IllegalArgumentException("ServiceConnection is null");
        }
        if (mPackageInfo == null) {
            throw new RuntimeException("Not supported in system context");
        }
        final IServiceConnection sd = mPackageInfo.lookupServiceDispatcher(
                        conn, getOuterContext());
        if (sd == null) {
            throw new IllegalArgumentException("ServiceConnection not currently bound: " + conn);
        }
        final BindUpdateInfo update = new BindUpdateInfo();
        update.connection = sd.asBinder();
        update.unbind = false;
        update.flags = flags.getValue();
        final ArrayList<BindUpdateInfo> updates = new ArrayList<>(1);
        updates.add(update);
        try {
            ActivityManager.getService().updateServiceBindings(updates);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public boolean startInstrumentation(ComponentName className,
            String profileFile, Bundle arguments) {
+18 −0
Original line number Diff line number Diff line
@@ -4467,6 +4467,24 @@ public abstract class Context {
     */
    public abstract void unbindService(@NonNull ServiceConnection conn);

    /**
     * Rebind an application service with updated bind service flags
     *
     * @param conn The connection interface previously supplied to
     *             bindService().  This parameter must not be null.
     * @param flags Updated flags for the binding as per {@link #bindService}.
     *              Only flags returned from {@link #getUpdateableFlags} may
     *              be added or removed.
     *
     * @see #bindService
     * @see #updateServiceBindings
     */
    @FlaggedApi(FLAG_ENABLE_UPDATE_SERVICE_BINDINGS)
    public void rebindService(@NonNull ServiceConnection conn,
            @NonNull BindServiceFlags flags) {
        throw new RuntimeException("Not implemented. Must override in a subclass.");
    }

    /**
     * Start executing an {@link android.app.Instrumentation} class.  The given
     * Instrumentation component will be run by killing its target application
+7 −0
Original line number Diff line number Diff line
@@ -973,6 +973,13 @@ public class ContextWrapper extends Context {
        mBase.unbindService(conn);
    }


    @Override
    public void rebindService(@NonNull ServiceConnection conn,
            @NonNull BindServiceFlags flags) {
        mBase.rebindService(conn, flags);
    }

    @Override
    public boolean startInstrumentation(ComponentName className,
            @Nullable String profileFile, @Nullable Bundle arguments) {