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

Commit 25bcd9b9 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge commit 'refs/changes/59/450859/1' of...

Merge commit 'refs/changes/59/450859/1' of https://github.com/LineageOS/android_frameworks_base into 3571-t-september
parents 2ed2906f 06cf3b6f
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();
        }
+5 −0
Original line number Diff line number Diff line
@@ -372,6 +372,11 @@ public final class AssociationRequest implements Parcelable {
        public Builder setDisplayName(@NonNull CharSequence displayName) {
            checkNotUsed();
            mDisplayName = requireNonNull(displayName);
            if (displayName.length() > 1024) {
                throw new IllegalArgumentException("Length of the display name must be at most "
                        + "1024 characters");
            }

            return this;
        }

+37 −4
Original line number Diff line number Diff line
@@ -920,16 +920,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,
@@ -1311,9 +1316,9 @@ public class ChooserActivity extends ResolverActivity implements
                            -1,
                            false);
                    View firstImgView = getFirstVisibleImgPreviewView();
                    // Action bar is user-independent, always start as primary
                    // Action bar is user-independent, always start as the launching user
                    if (firstImgView == null) {
                        safelyStartActivityAsUser(ti, getPersonalProfileUserHandle());
                        safelyStartActivityAsUser(ti, UserHandle.of(UserHandle.myUserId()));
                        finish();
                    } else {
                        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
@@ -4324,4 +4329,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();
            }
        }
    }
}
+8 −36
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ genrule {
  name: "generate_priv_manifest",
  srcs: [
    "shim_priv/AndroidManifest.xml",
        ":CtsShimPrivUpgrade",
    ":CtsShimPrivUpgrade"
  ],
  out: ["AndroidManifest.xml"],
  cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimPrivUpgrade) | cut -d' ' -f1`/ $(location shim_priv/AndroidManifest.xml) > $(out)",
@@ -146,34 +146,6 @@ android_app {
    ],
}

//##########################################################
// Variant: System app upgrade

android_app {
    name: "CtsShimUpgrade",

    sdk_version: "current",
    optimize: {
        enabled: false,
    },
    dex_preopt: {
        enabled: false,
    },

    manifest: "shim/AndroidManifestUpgrade.xml",
    min_sdk_version: "24",
}

genrule {
    name: "generate_shim_manifest",
    srcs: [
        "shim/AndroidManifest.xml",
        ":CtsShimUpgrade",
    ],
    out: ["AndroidManifest.xml"],
    cmd: "sed -e s/__HASH__/`sha512sum -b $(location :CtsShimUpgrade) | cut -d' ' -f1`/ $(location shim/AndroidManifest.xml) > $(out)",
}

//##########################################################
// Variant: System app

@@ -188,7 +160,7 @@ android_app {
        enabled: false,
    },

    manifest: ":generate_shim_manifest",
    manifest: "shim/AndroidManifest.xml",
    apex_available: [
        "//apex_available:platform",
        "com.android.apex.cts.shim.v1",
Loading