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

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

Merge "Fix uris coming into SliceManager.getPinnedSpecs"

parents a8d90577 4f645cc2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ public class SliceManagerService extends ISliceManager.Stub {
    public SliceSpec[] getPinnedSpecs(Uri uri, String pkg) throws RemoteException {
        verifyCaller(pkg);
        enforceAccess(pkg, uri);
        uri = maybeAddUserId(uri, Binder.getCallingUserHandle().getIdentifier());
        return getPinnedSlice(uri).getSpecs();
    }

+18 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import static android.content.ContentProvider.maybeAddUserId;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
@@ -59,7 +60,7 @@ import org.junit.runner.RunWith;
public class SliceManagerServiceTest extends UiServiceTestCase {

    private static final String AUTH = "com.android.services.uitests";
    private static final Uri TEST_URI = maybeAddUserId(Uri.parse("content://" + AUTH + "/path"), 0);
    private static final Uri TEST_URI = Uri.parse("content://" + AUTH + "/path");

    private static final SliceSpec[] EMPTY_SPECS = new SliceSpec[]{
    };
@@ -93,7 +94,7 @@ public class SliceManagerServiceTest extends UiServiceTestCase {

        mService.pinSlice("pkg", TEST_URI, EMPTY_SPECS, mToken);
        mService.pinSlice("pkg", TEST_URI, EMPTY_SPECS, mToken);
        verify(mService, times(1)).createPinnedSlice(eq(TEST_URI), anyString());
        verify(mService, times(1)).createPinnedSlice(eq(maybeAddUserId(TEST_URI, 0)), anyString());
    }

    @Test
@@ -126,4 +127,19 @@ public class SliceManagerServiceTest extends UiServiceTestCase {
        verify(mContextSpy).checkPermission(eq("perm2"), eq(Process.myPid()), eq(Process.myUid()));
    }

    @Test(expected = IllegalStateException.class)
    public void testNoPinThrow() throws Exception {
        mService.getPinnedSpecs(TEST_URI, "pkg");
    }

    @Test
    public void testGetPinnedSpecs() throws Exception {
        SliceSpec[] specs = new SliceSpec[] {
            new SliceSpec("Something", 1) };
        mService.pinSlice("pkg", TEST_URI, specs, mToken);

        when(mCreatedSliceState.getSpecs()).thenReturn(specs);
        assertEquals(specs, mService.getPinnedSpecs(TEST_URI, "pkg"));
    }

}