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

Commit 0adef18c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Ensuring valid packageName when granting slice permission" into tm-dev...

Merge "Ensuring valid packageName when granting slice permission" into tm-dev am: bf2d6e02 am: 03d8cdd3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/34125024



Change-Id: Ie5ed1de95548f1f9d795cbd14dc855071ad47a8a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 83cef86e 03d8cdd3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@ package com.android.server.slice;

import android.content.ContentProvider;
import android.content.Context;
import android.content.pm.parsing.FrameworkParsingPackageUtils;
import android.net.Uri;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -410,6 +412,7 @@ public class SlicePermissionManager implements DirtyTracker {
        public PkgUser(String pkg, int userId) {
            mPkg = pkg;
            mUserId = userId;
            enforceValidPackage();
        }

        public PkgUser(String pkgUserStr) throws IllegalArgumentException {
@@ -420,6 +423,17 @@ public class SlicePermissionManager implements DirtyTracker {
            } catch (Exception e) {
                throw new IllegalArgumentException(e);
            }
            enforceValidPackage();
        }

        private void enforceValidPackage() {
            String error = FrameworkParsingPackageUtils.validateName(
                    mPkg,
                    false /* requireSeparator */,
                    true /* requireFilename */);
            if (!TextUtils.isEmpty(error)) {
                throw new IllegalArgumentException((error));
            }
        }

        public String getPkg() {