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

Commit c45a9903 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Allow wallpapers and IMEs to get location if needed

Wallpapers and Input Methods are bound by the system
and are only brought up to BFGS, which is insufficient
for getting foreground location. Add the required
flag to the bindService call to allow the bound process
to reach FGSL when visible.

Same for VoiceInteractionServices

Bug: 117494189
Test: Manually enable a wallpaper that needs location and
     verify it gets location.
      atest CtsAppTestCases:ActivityManagerProcessStateTest

Change-Id: I6767e1f480e5b3d6e33864dabd9cb167df4846f5
parent 6e14a032
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,8 +78,8 @@ public final class ProcessState {
        STATE_PERSISTENT,               // ActivityManager.PROCESS_STATE_PERSISTENT_UI
        STATE_TOP,                      // ActivityManager.PROCESS_STATE_TOP
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE_LOCATION
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_BOUND_TOP
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE
        STATE_IMPORTANT_FOREGROUND,     // ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND
        STATE_IMPORTANT_BACKGROUND,     // ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND
+5 −4
Original line number Diff line number Diff line
@@ -1262,15 +1262,16 @@ public final class OomAdjuster {
                                // processes).  These should not bring the current process
                                // into the top state, since they are not on top.  Instead
                                // give them the best bound state after that.
                                final int bestState = cr.hasFlag(Context.BIND_INCLUDE_CAPABILITIES)
                                        ? PROCESS_STATE_FOREGROUND_SERVICE_LOCATION
                                        : PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
                                if ((cr.flags & Context.BIND_FOREGROUND_SERVICE) != 0) {
                                    clientProcState =
                                            PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
                                    clientProcState = bestState;
                                } else if (mService.mWakefulness
                                        == PowerManagerInternal.WAKEFULNESS_AWAKE
                                        && (cr.flags & Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE)
                                                != 0) {
                                    clientProcState =
                                            PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
                                    clientProcState = bestState;
                                } else {
                                    clientProcState =
                                            PROCESS_STATE_IMPORTANT_FOREGROUND;
+1 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            Context.BIND_AUTO_CREATE
            | Context.BIND_TREAT_LIKE_ACTIVITY
            | Context.BIND_FOREGROUND_SERVICE
            | Context.BIND_INCLUDE_CAPABILITIES
            | Context.BIND_SHOWING_UI
            | Context.BIND_SCHEDULE_LIKE_TOP_APP;

+2 −1
Original line number Diff line number Diff line
@@ -2629,7 +2629,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    0, null, new UserHandle(serviceUserId)));
            if (!mContext.bindServiceAsUser(intent, newConn,
                    Context.BIND_AUTO_CREATE | Context.BIND_SHOWING_UI
                            | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
                            | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE
                            | Context.BIND_INCLUDE_CAPABILITIES,
                    new UserHandle(serviceUserId))) {
                String msg = "Unable to bind service: "
                        + componentName;
+3 −4
Original line number Diff line number Diff line
@@ -25,9 +25,6 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;

import com.android.internal.app.IVoiceActionCheckCallback;
import com.android.server.wm.ActivityTaskManagerInternal;
import android.app.IActivityManager;
import android.app.IActivityTaskManager;
import android.content.BroadcastReceiver;
@@ -51,15 +48,16 @@ import android.util.PrintWriterPrinter;
import android.util.Slog;
import android.view.IWindowManager;

import com.android.internal.app.IVoiceActionCheckCallback;
import com.android.internal.app.IVoiceInteractionSessionShowCallback;
import com.android.internal.app.IVoiceInteractor;
import com.android.server.LocalServices;
import com.android.server.wm.ActivityTaskManagerInternal;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConnection.Callback {
    final static String TAG = "VoiceInteractionServiceManager";
@@ -358,6 +356,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        intent.setComponent(mComponent);
        mBound = mContext.bindServiceAsUser(intent, mConnection,
                Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
                | Context.BIND_INCLUDE_CAPABILITIES
                | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS, new UserHandle(mUser));
        if (!mBound) {
            Slog.w(TAG, "Failed binding to voice interaction service " + mComponent);