Jeff Sharkey 6a97cc3b83 Grant notification Uri permissions as sending app.
For security reasons, the system UID can't make URI permission as
itself; it always needs to do so on behalf of a specific app.  To
handle this, we grant notification Uri permissions as the UID that
sent a given notification.

To give meaningful debug messages to developers, check to see if the
caller has permissions to grant Uri access when they're enqueuing
a notification.  If they're targeting P, throw any security issues
back at the caller; if older SDK, log and ignore that Uri.

Since multiple notifications can grant access to the same content,
we need unique UriPermissionOwner per active notification.  For
example, consider these two notifications:

1. sound=content://sound, image=content://image1
2. sound=content://sound, image=content://image2

When #1 is cancelled, we still need to keep the content://sound
grant active until #2 is also cancelled.  Using unique owners
means that ActivityManagerService tracks reference counting on
our behalf.

Optimizations to avoid allocations in hot code paths.

Test: atest frameworks/base/services/tests/uiservicestests/src/com/android/server/notification
Bug: 9069730
Change-Id: I69601793538adcbf06c4986a2fb1ea2dd9d876eb
2018-04-18 10:00:19 -06:00

45 lines
2.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.frameworks.tests.uiservices">
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
<uses-permission android:name="android.permission.MANAGE_USERS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_VOICE_INTERACTION_SERVICE" />
<uses-permission android:name="android.permission.DEVICE_POWER" />
<uses-permission android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:debuggable="true">
<uses-library android:name="android.test.runner" />
<provider android:name=".DummyProvider"
android:authorities="com.android.services.uitests" />
</application>
<instrumentation
android:name="android.testing.TestableInstrumentation"
android:targetPackage="com.android.frameworks.tests.uiservices"
android:label="Notification Tests" />
</manifest>