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

Commit 4a1bad00 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Prevent activity config override for system processes." into rvc-dev am: c47c4c0e

Change-Id: I3bffcec0aac2616db55f4bec8083b0915b79c428
parents 4436af05 c47c4c0e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -356,6 +356,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    ActivityManagerInternal mAmInternal;
    UriGrantsManagerInternal mUgmInternal;
    private PackageManagerInternal mPmInternal;
    /** The cached sys ui service component name from package manager. */
    private ComponentName mSysUiServiceComponent;
    private PermissionPolicyInternal mPermissionPolicyInternal;
    @VisibleForTesting
    final ActivityTaskManagerInternal mInternal;
@@ -5869,6 +5871,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        return mPmInternal;
    }

    ComponentName getSysUiServiceComponentLocked() {
        if (mSysUiServiceComponent == null) {
            final PackageManagerInternal pm = getPackageManagerInternalLocked();
            mSysUiServiceComponent = pm.getSystemUiServiceComponent();
        }
        return mSysUiServiceComponent;
    }

    PermissionPolicyInternal getPermissionPolicyInternal() {
        if (mPermissionPolicyInternal == null) {
            mPermissionPolicyInternal = LocalServices.getService(PermissionPolicyInternal.class);
+14 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.ArraySet;
@@ -200,6 +201,9 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
    /** Whether our process is currently running a {@link IRemoteAnimationRunner} */
    private boolean mRunningRemoteAnimation;

    /** Whether this process is owned by the System UI package. */
    final boolean mIsSysUiPackage;

    public WindowProcessController(@NonNull ActivityTaskManagerService atm, ApplicationInfo info,
            String name, int uid, int userId, Object owner, WindowProcessListener listener) {
        mInfo = info;
@@ -210,6 +214,10 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        mListener = listener;
        mAtm = atm;
        mDisplayId = INVALID_DISPLAY;

        mIsSysUiPackage = info.packageName.equals(
                mAtm.getSysUiServiceComponentLocked().getPackageName());

        onConfigurationChanged(atm.getGlobalConfiguration());
    }

@@ -1077,6 +1085,12 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
     * always track the configuration of the non-finishing activity last added to the process.
     */
    private void updateActivityConfigurationListener() {
        if (mIsSysUiPackage || mUid == Process.SYSTEM_UID) {
            // This is a system owned process and should not use an activity config.
            // TODO(b/151161907): Remove after support for display-independent (raw) SysUi configs.
            return;
        }

        for (int i = mActivities.size() - 1; i >= 0; i--) {
            final ActivityRecord activityRecord = mActivities.get(i);
            if (!activityRecord.finishing && !activityRecord.containsListener(this)) {
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.system.OsConstants;
import android.text.TextUtils;
import android.util.Pair;

import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.appop.AppOpsService;
import com.android.server.wm.ActivityTaskManagerService;
@@ -125,6 +126,8 @@ public class ApplicationExitInfoTest {
        mAms.mActivityTaskManager.initialize(null, null, mContext.getMainLooper());
        mAms.mAtmInternal = spy(mAms.mActivityTaskManager.getAtmInternal());
        mAms.mPackageManagerInt = mPackageManagerInt;
        doReturn(new ComponentName("", "")).when(mPackageManagerInt).getSystemUiServiceComponent();
        LocalServices.addService(PackageManagerInternal.class, mPackageManagerInt);
    }

    @After
+10 −0
Original line number Diff line number Diff line
@@ -75,8 +75,10 @@ import static org.mockito.Mockito.spy;

import android.app.IApplicationThread;
import android.app.IServiceConnection;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManagerInternal;
import android.content.pm.ServiceInfo;
import android.os.Build;
import android.os.IBinder;
@@ -87,6 +89,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.SparseArray;

import com.android.server.LocalServices;
import com.android.server.wm.ActivityServiceConnectionsHolder;
import com.android.server.wm.ActivityTaskManagerService;
import com.android.server.wm.WindowProcessController;
@@ -127,6 +130,7 @@ public class MockingOomAdjusterTests {
    private static final String MOCKAPP5_PROCESSNAME = "test #5";
    private static final String MOCKAPP5_PACKAGENAME = "com.android.test.test5";
    private static Context sContext;
    private static PackageManagerInternal sPackageManagerInternal;
    private static ActivityManagerService sService;

    @BeforeClass
@@ -134,9 +138,15 @@ public class MockingOomAdjusterTests {
        sContext = getInstrumentation().getTargetContext();
        System.setProperty("dexmaker.share_classloader", "true");

        sPackageManagerInternal = mock(PackageManagerInternal.class);
        doReturn(new ComponentName("", "")).when(sPackageManagerInternal)
                .getSystemUiServiceComponent();
        LocalServices.addService(PackageManagerInternal.class, sPackageManagerInternal);

        sService = mock(ActivityManagerService.class);
        sService.mActivityTaskManager = new ActivityTaskManagerService(sContext);
        sService.mActivityTaskManager.initialize(null, null, sContext.getMainLooper());
        sService.mPackageManagerInt = sPackageManagerInternal;
        sService.mAtmInternal = spy(sService.mActivityTaskManager.getAtmInternal());

        sService.mConstants = new ActivityManagerConstants(sContext, sService,
+5 −2
Original line number Diff line number Diff line
@@ -203,10 +203,11 @@ public class ActivityStarterTests extends ActivityTestsBase {
        final IApplicationThread caller = mock(IApplicationThread.class);
        final WindowProcessListener listener = mock(WindowProcessListener.class);

        final ApplicationInfo ai = new ApplicationInfo();
        ai.packageName = "com.android.test.package";
        final WindowProcessController wpc =
                containsConditions(preconditions, PRECONDITION_NO_CALLER_APP)
                ? null : new WindowProcessController(
                        service, mock(ApplicationInfo.class), null, 0, -1, null, listener);
                ? null : new WindowProcessController(service, ai, null, 0, -1, null, listener);
        doReturn(wpc).when(service).getProcessController(anyObject());

        final Intent intent = new Intent();
@@ -345,6 +346,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
        doReturn(false).when(mMockPackageManager).isInstantAppInstallerComponent(any());
        doReturn(null).when(mMockPackageManager).resolveIntent(any(), any(), anyInt(), anyInt(),
                anyInt(), anyBoolean(), anyInt());
        doReturn(new ComponentName("", "")).when(mMockPackageManager).getSystemUiServiceComponent();

        // Never review permissions
        doReturn(false).when(mMockPackageManager).isPermissionsReviewRequired(any(), anyInt());
@@ -656,6 +658,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
        final WindowProcessListener listener = mock(WindowProcessListener.class);
        final ApplicationInfo ai = new ApplicationInfo();
        ai.uid = callingUid;
        ai.packageName = "com.android.test.package";
        final WindowProcessController callerApp =
                new WindowProcessController(mService, ai, null, callingUid, -1, null, listener);
        callerApp.setHasForegroundActivities(hasForegroundActivities);
Loading