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

Commit 51daca2e authored by Song Hu's avatar Song Hu
Browse files

Implement dark launch logic for sharesheet aiai model. Route the sharesheet...

Implement dark launch logic for sharesheet aiai model. Route the sharesheet user interaction from PeopleService to Remote Prediction Service, while PeopleService is making inference for sharesheet.
It is guarded by the flag "adb shell device_config put systemui dark_launch_remote_prediction_service_enabled true"

Test: test on local device
Bug: 180933488
Change-Id: I7db52c69224e69ad3125362185e2ffd1a474bb78
parent ebecb333
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -414,6 +414,12 @@ public final class SystemUiDeviceConfigFlags {
     */
    public static final String CHOOSER_TARGET_RANKING_ENABLED = "chooser_target_ranking_enabled";

    /**
     * (boolean) Whether dark launch of remote prediction service is enabled.
     */
    public static final String DARK_LAUNCH_REMOTE_PREDICTION_SERVICE_ENABLED =
            "dark_launch_remote_prediction_service_enabled";

    /**
     * (boolean) Whether to enable pinch resizing for PIP.
     */
+3 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.os.Binder;
import android.os.IBinder;
import android.os.Process;
import android.os.ResultReceiver;
import android.os.ShellCallback;
import android.util.Slog;
@@ -179,7 +180,8 @@ public class AppPredictionManagerService extends
            Context ctx = getContext();
            if (!(ctx.checkCallingPermission(PACKAGE_USAGE_STATS) == PERMISSION_GRANTED
                    || mServiceNameResolver.isTemporary(userId)
                    || mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid()))) {
                    || mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())
                    || Binder.getCallingUid() == Process.SYSTEM_UID)) {

                String msg = "Permission Denial: " + func + " from pid="
                        + Binder.getCallingPid()
+12 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.util.ArrayMap;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.infra.AbstractRemoteService;
import com.android.server.LocalServices;
import com.android.server.infra.AbstractPerUserSystemService;
@@ -55,6 +56,8 @@ public class AppPredictionPerUserService extends
    private static final String TAG = AppPredictionPerUserService.class.getSimpleName();
    private static final String PREDICT_USING_PEOPLE_SERVICE_PREFIX =
            "predict_using_people_service_";
    private static final String REMOTE_APP_PREDICTOR_KEY = "remote_app_predictor";


    @Nullable
    @GuardedBy("mLock")
@@ -112,8 +115,16 @@ public class AppPredictionPerUserService extends
    @GuardedBy("mLock")
    public void onCreatePredictionSessionLocked(@NonNull AppPredictionContext context,
            @NonNull AppPredictionSessionId sessionId, @NonNull IBinder token) {
        final boolean usesPeopleService = DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI,
        boolean usesPeopleService = DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI,
                PREDICT_USING_PEOPLE_SERVICE_PREFIX + context.getUiSurface(), false);
        if (context.getExtras() != null
                && context.getExtras().getBoolean(REMOTE_APP_PREDICTOR_KEY, false)
                && DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.DARK_LAUNCH_REMOTE_PREDICTION_SERVICE_ENABLED, false)
        ) {
            // connect with remote AppPredictionService instead for dark launch
            usesPeopleService = false;
        }
        final boolean serviceExists = resolveService(sessionId, false,
                usesPeopleService, s -> s.onCreatePredictionSession(context, sessionId));
        if (serviceExists && !mSessionInfos.containsKey(sessionId)) {
+4 −2
Original line number Diff line number Diff line
@@ -388,9 +388,11 @@ public class PeopleService extends SystemService {
        private Map<AppPredictionSessionId, SessionInfo> mSessions = new ArrayMap<>();

        @Override
        public void onCreatePredictionSession(AppPredictionContext context,
        public void onCreatePredictionSession(AppPredictionContext appPredictionContext,
                AppPredictionSessionId sessionId) {
            mSessions.put(sessionId, new SessionInfo(context, mDataManager, sessionId.getUserId()));
            mSessions.put(sessionId,
                    new SessionInfo(appPredictionContext, mDataManager, sessionId.getUserId(),
                            getContext()));
        }

        @Override
+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.UserIdInt;
import android.app.prediction.AppPredictionContext;
import android.app.prediction.AppTarget;
import android.app.prediction.IPredictionCallback;
import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -40,9 +41,9 @@ class SessionInfo {
            new RemoteCallbackList<>();

    SessionInfo(AppPredictionContext predictionContext, DataManager dataManager,
            @UserIdInt int callingUserId) {
            @UserIdInt int callingUserId, Context context) {
        mAppTargetPredictor = AppTargetPredictor.create(predictionContext,
                this::updatePredictions, dataManager, callingUserId);
                this::updatePredictions, dataManager, callingUserId, context);
    }

    void addCallback(IPredictionCallback callback) {
Loading