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

Commit 348c0a78 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents bce1e0db 46f39fc0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -345,6 +345,8 @@ public final class DeviceAdminInfo implements Parcelable {
        } catch (NameNotFoundException e) {
            throw new XmlPullParserException(
                    "Unable to create context for: " + mActivityInfo.packageName);
        } catch (OutOfMemoryError e) {
            throw new XmlPullParserException("Out of memory when parsing", null, e);
        } finally {
            if (parser != null) parser.close();
        }
+35 −2
Original line number Diff line number Diff line
@@ -942,16 +942,21 @@ public class ChooserActivity extends ResolverActivity implements
            List<ResolveInfo> rList,
            boolean filterLastUsed) {
        int selectedProfile = findSelectedProfile();
        List<Intent> crossProfileIntents = sanitizePayloadIntents(mIntents);
        ChooserGridAdapter personalAdapter = createChooserGridAdapter(
                /* context */ this,
                /* payloadIntents */ mIntents,
                /* payloadIntents */ selectedProfile == PROFILE_PERSONAL
                        ? mIntents
                        : crossProfileIntents,
                selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
                rList,
                filterLastUsed,
                /* userHandle */ getPersonalProfileUserHandle());
        ChooserGridAdapter workAdapter = createChooserGridAdapter(
                /* context */ this,
                /* payloadIntents */ mIntents,
                /* payloadIntents */ selectedProfile == PROFILE_WORK
                        ? mIntents
                        : crossProfileIntents,
                selectedProfile == PROFILE_WORK ? initialIntents : null,
                rList,
                filterLastUsed,
@@ -4332,4 +4337,32 @@ public class ChooserActivity extends ResolverActivity implements
                target.getComponentName(),
                target.getIntentExtras());
    }

    /**
     * Returns a copy of provided intents with explicit targeting information is removed from each
     * intent in the list, as well as from its selector {@link Intent#getSelector}. Specifically,
     * the values that would be returned by {@link Intent#getPackage} and
     * {@link Intent#getComponent} are cleared for both the main intent and its selector. This
     * sanitization is performed because explicit intents could otherwise be used to bypass the
     * device's cross-profile sharing policy settings.
     */
    @NonNull
    @VisibleForTesting
    public static List<Intent> sanitizePayloadIntents(@NonNull List<Intent> intents) {
        return intents.stream().map((intent) -> {
            if (intent == null) {
                return null;
            }
            Intent sanitized = new Intent(intent);
            sanitized.setPackage(null);
            sanitized.setComponent(null);
            if (sanitized.getSelector() != null) {
                Intent selector = new Intent(sanitized.getSelector());
                selector.setPackage(null);
                selector.setComponent(null);
                sanitized.setSelector(selector);
            }
            return sanitized;
        }).collect(Collectors.toList());
    }
}
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.app;

import static android.content.Intent.ACTION_SEND;

import static com.google.common.truth.Truth.assertThat;

import android.content.ComponentName;
import android.content.Intent;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ChooserActivityCrossProfileIntentsTest {
    @Test
    public void test_sanitizePayloadIntents() {
        final Intent intentOne = new Intent(ACTION_SEND);
        intentOne.setPackage("org.test.example");
        final Intent intentTwo = new Intent(ACTION_SEND);
        intentTwo.setComponent(ComponentName.unflattenFromString("org.test.example/.TestActivity"));
        final Intent intentThree = new Intent(ACTION_SEND);
        intentThree.setSelector(new Intent(intentOne));
        final Intent intentFour = new Intent(ACTION_SEND);
        intentFour.setSelector(new Intent(intentTwo));
        ArrayList<Intent> intents = new ArrayList<>();
        Collections.addAll(intents, intentOne, intentTwo, intentThree, intentFour);

        List<Intent> sanitizedIntents = ChooserActivity.sanitizePayloadIntents(intents);

        assertThat(sanitizedIntents).hasSize(intents.size());
        for (Intent intent : sanitizedIntents) {
            assertThat(intent.getPackage()).isNull();
            assertThat(intent.getComponent()).isNull();
            Intent selector = intent.getSelector();
            if (selector != null) {
                assertThat(selector.getPackage()).isNull();
                assertThat(selector.getComponent()).isNull();
            }
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -376,7 +376,7 @@ public final class RemotePrintDocument {
        try {
            file = mDocumentInfo.fileProvider.acquireFile(null);
            in = new FileInputStream(file);
            out = contentResolver.openOutputStream(uri);
            out = contentResolver.openOutputStream(uri, "wt");
            final byte[] buffer = new byte[8192];
            while (true) {
                final int readByteCount = in.read(buffer);
+8 −5
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
            if (item == null && active) {
                item = new AppOpItem(code, uid, packageName, mClock.elapsedRealtime());
                if (isOpMicrophone(code)) {
                    item.setDisabled(isAnyRecordingPausedLocked(uid));
                    item.setDisabled(isAllRecordingPausedLocked(uid));
                } else if (isOpCamera(code)) {
                    item.setDisabled(mCameraDisabled);
                }
@@ -472,18 +472,21 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon

    }

    private boolean isAnyRecordingPausedLocked(int uid) {
    // TODO(b/365843152) remove AudioRecordingConfiguration listening
    private boolean isAllRecordingPausedLocked(int uid) {
        if (mMicMuted) {
            return true;
        }
        List<AudioRecordingConfiguration> configs = mRecordingsByUid.get(uid);
        if (configs == null) return false;
        // If we are aware of AudioRecordConfigs, suppress the indicator if all of them are known
        // to be silenced.
        int configsNum = configs.size();
        for (int i = 0; i < configsNum; i++) {
            AudioRecordingConfiguration config = configs.get(i);
            if (config.isClientSilenced()) return true;
            if (!config.isClientSilenced()) return false;
        }
        return false;
        return true;
    }

    private void updateSensorDisabledStatus() {
@@ -494,7 +497,7 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon

                boolean paused = false;
                if (isOpMicrophone(item.getCode())) {
                    paused = isAnyRecordingPausedLocked(item.getUid());
                    paused = isAllRecordingPausedLocked(item.getUid());
                } else if (isOpCamera(item.getCode())) {
                    paused = mCameraDisabled;
                }
Loading