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

Commit bf2d6e02 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 5ca1fa70 3dfe8f61
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() {