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

Commit ec67ed4c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8742912 from 3c3c0312 to tm-qpr1-release

Change-Id: Ida0f0c701ca466cb169e06d4b1921e4a46ffc32c
parents 9750237b 3c3c0312
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.devicestate;


import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
import static android.view.Display.DEFAULT_DISPLAY;


import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.IntRange;
@@ -48,9 +49,16 @@ public final class DeviceState {
     */
     */
    public static final int FLAG_CANCEL_OVERRIDE_REQUESTS = 1 << 0;
    public static final int FLAG_CANCEL_OVERRIDE_REQUESTS = 1 << 0;


    /**
     * Flag that indicates this device state is inaccessible for applications to be placed in. This
     * could be a device-state where the {@link DEFAULT_DISPLAY} is not enabled.
     */
    public static final int FLAG_APP_INACCESSIBLE = 1 << 1;

    /** @hide */
    /** @hide */
    @IntDef(prefix = {"FLAG_"}, flag = true, value = {
    @IntDef(prefix = {"FLAG_"}, flag = true, value = {
            FLAG_CANCEL_OVERRIDE_REQUESTS,
            FLAG_CANCEL_OVERRIDE_REQUESTS,
            FLAG_APP_INACCESSIBLE
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface DeviceStateFlags {}
    public @interface DeviceStateFlags {}
@@ -97,7 +105,8 @@ public final class DeviceState {


    @Override
    @Override
    public String toString() {
    public String toString() {
        return "DeviceState{" + "identifier=" + mIdentifier + ", name='" + mName + '\'' + '}';
        return "DeviceState{" + "identifier=" + mIdentifier + ", name='" + mName + '\''
                + ", app_accessible=" + !hasFlag(FLAG_APP_INACCESSIBLE) + "}";
    }
    }


    @Override
    @Override
+15 −2
Original line number Original line Diff line number Diff line
@@ -2686,7 +2686,7 @@ public class ComputerEngine implements Computer {
        if (Process.isSdkSandboxUid(callingUid)) {
        if (Process.isSdkSandboxUid(callingUid)) {
            int clientAppUid = Process.getAppUidForSdkSandboxUid(callingUid);
            int clientAppUid = Process.getAppUidForSdkSandboxUid(callingUid);
            // SDK sandbox should be able to see it's client app
            // SDK sandbox should be able to see it's client app
            if (clientAppUid == UserHandle.getUid(userId, ps.getAppId())) {
            if (ps != null && clientAppUid == UserHandle.getUid(userId, ps.getAppId())) {
                return false;
                return false;
            }
            }
        }
        }
@@ -2698,7 +2698,7 @@ public class ComputerEngine implements Computer {
        final boolean callerIsInstantApp = instantAppPkgName != null;
        final boolean callerIsInstantApp = instantAppPkgName != null;
        if (ps == null) {
        if (ps == null) {
            // pretend the application exists, but, needs to be filtered
            // pretend the application exists, but, needs to be filtered
            return callerIsInstantApp;
            return callerIsInstantApp || Process.isSdkSandboxUid(callingUid);
        }
        }
        // if the target and caller are the same application, don't filter
        // if the target and caller are the same application, don't filter
        if (isCallerSameApp(ps.getPackageName(), callingUid)) {
        if (isCallerSameApp(ps.getPackageName(), callingUid)) {
@@ -3089,6 +3089,19 @@ public class ComputerEngine implements Computer {
    }
    }


    public boolean filterAppAccess(int uid, int callingUid) {
    public boolean filterAppAccess(int uid, int callingUid) {
        if (Process.isSdkSandboxUid(uid)) {
            // Sdk sandbox instance should be able to see itself.
            if (callingUid == uid) {
                return false;
            }
            final int clientAppUid = Process.getAppUidForSdkSandboxUid(uid);
            // Client app of this sdk sandbox process should be able to see it.
            if (clientAppUid == uid) {
                return false;
            }
            // Nobody else should be able to see the sdk sandbox process.
            return true;
        }
        final int userId = UserHandle.getUserId(uid);
        final int userId = UserHandle.getUserId(uid);
        final int appId = UserHandle.getAppId(uid);
        final int appId = UserHandle.getAppId(uid);
        final Object setting = mSettings.getSettingBase(appId);
        final Object setting = mSettings.getSettingBase(appId);
+4 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,7 @@ public final class DeviceStateProviderImpl implements DeviceStateProvider,
    private static final String DATA_CONFIG_FILE_PATH = "system/devicestate/";
    private static final String DATA_CONFIG_FILE_PATH = "system/devicestate/";
    private static final String CONFIG_FILE_NAME = "device_state_configuration.xml";
    private static final String CONFIG_FILE_NAME = "device_state_configuration.xml";
    private static final String FLAG_CANCEL_OVERRIDE_REQUESTS = "FLAG_CANCEL_OVERRIDE_REQUESTS";
    private static final String FLAG_CANCEL_OVERRIDE_REQUESTS = "FLAG_CANCEL_OVERRIDE_REQUESTS";
    private static final String FLAG_APP_INACCESSIBLE = "FLAG_APP_INACCESSIBLE";


    /** Interface that allows reading the device state configuration. */
    /** Interface that allows reading the device state configuration. */
    interface ReadableConfig {
    interface ReadableConfig {
@@ -145,6 +146,9 @@ public final class DeviceStateProviderImpl implements DeviceStateProvider,
                                case FLAG_CANCEL_OVERRIDE_REQUESTS:
                                case FLAG_CANCEL_OVERRIDE_REQUESTS:
                                    flags |= DeviceState.FLAG_CANCEL_OVERRIDE_REQUESTS;
                                    flags |= DeviceState.FLAG_CANCEL_OVERRIDE_REQUESTS;
                                    break;
                                    break;
                                case FLAG_APP_INACCESSIBLE:
                                    flags |= DeviceState.FLAG_APP_INACCESSIBLE;
                                    break;
                                default:
                                default:
                                    Slog.w(TAG, "Parsed unknown flag with name: "
                                    Slog.w(TAG, "Parsed unknown flag with name: "
                                            + configFlagString);
                                            + configFlagString);