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

Commit d658b493 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Implement dark launch logic for sharesheet aiai model." into sc-dev am: b4c0d646

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13930760

Change-Id: I91e17129007c5c4e8598693e9182662922ef82f9
parents fb2dfc63 b4c0d646
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