Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
*.iml
.DS_Store
.agent/
8 changes: 8 additions & 0 deletions niap-cc/Permissions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
xpermission/
xpermission.zip
xpermssion/
xpermssion.zip
.agent/
.idea/
.idea/*
.DS_Store
68 changes: 68 additions & 0 deletions niap-cc/Permissions/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Agent Context - Permission Test Tool Update

This file provides context for AI agents working on this project.

## Project Goal
Update the Permission Test Tooling for Android 17 / Android 26Q2 (SDK 37).

## Workspace Information
- **Root Directory**: `~/AndroidStudioProjects/security-certification-resources/niap-cc/Permissions`
- **Active Branch**: `niap-permission-update-sdk37` (Ensure all work is done here)
- **Android 17 / 26Q2 Source Directory**: `~/android-26Q2`
- **Preliminary Investigation Data**: Look in `xpermission`.

## Component Summary
- `PermissionTester`: The legacy tester body. **Do not update.**
- `Tester`: Appears in directory listing, likely related to `PermissionTester`.
- `Companion`: Provides service stubs for calling services via Transaction ID and handles configuration. Needs review/update for Android 17 / 26Q2.
- `TransactIds`: Tool to extract Transaction IDs from actual devices. Needs review/update for Android 17 / 26Q2.

## Guidance for Agents
- This project is part of a security certification resource update.
- Focus on updating `Companion` and `TransactIds` or creating a new tester mechanism as needed for Android 17 / 26Q2.
- Reference the research in `xpermission` to understand the changes in Android 17 / 26Q2 permissions.
- **Reference [TESTAUTONOMOUS.md](file:///~/AndroidStudioProjects/security-certification-resources/niap-cc/Permissions/TESTAUTONOMOUS.md) for automation procedures, including how to scope test execution via `SharedPreferences` manipulation.** and mcp tools ot communcating test devices.

### ❗ Essential Rules for Agents
- **Timer Rule**: When you say "wait" or similar, you **MUST** set a timer (using `schedule` tool) to ensure you don't forget to check back.
- **Logcat Rule**: When searching logcat or getting logs with MCP tools, you **MUST** prioritize filtering by process name or PID (e.g., `com.android.certification.niap.permission.dpctester`) to avoid noise and context pollution. Scoping tests and logs must be done from the beginning.

### 🛠️ Prerequisites for Testing on Real Devices
- **Companion App**: Must be installed and running for normal operation of some tests.
- **SELinux**: Must be disabled before running tests. Use `adb shell setenforce 0`.
- **Hidden API**: Must be enabled before running tests. Use `adb shell settings put global hidden_api_policy 1` (or appropriate command for the target OS).
- **Scope Execution**: Always scope test execution to specific modules via `SharedPreferences` to save time and avoid crashes.

## Module Installation and Verification

When installing the test modules, the `-g` option is **ALWAYS required** to grant all runtime permissions automatically. Also, the `-t` option is needed as it behaves as a test app. You can use the shell command in PermissionTester/script` to build and install the test modules.

Example command:
```bash
adb install -t -g Tester-normal-debug.apk
```

### Target Variants
Basically, we only check the following three variants:
- **platform**: Signed by platform key, contains all permissions.
- **noperm**: No permissions in manifest.
- **normal**: Contains all permissions, signed by ordinary key.

We have prepared scripts in `PermissionTester/script/` to build and install these variants:
- `install-normal.sh`
- `install-noperm.sh`
- `install-platform.sh`
- `uninstall.sh`

Use these scripts for verification.

## Permissions Checklist Legend

The `permissions_checklist.csv` file uses the following status codes:
- `-`: Not implementable
- `0`: Not implemented
- `1`: Placeholder ready
- `2`: Tentative implementation
- `3`: Implemented
- `4`: Verified
- `5`: Completed
6 changes: 3 additions & 3 deletions niap-cc/Permissions/Companion/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ apply plugin: 'com.android.application'
def applicationName = 'Companion'
android {
//compileSdkPreview "VanillaIceCream"
//compileSdkPreview "Baklava"
compileSdk 36
//compileSdkPreview "CinnamonBun"
compileSdk 37
signingConfigs {
// TODO :
// Prepare your own companion.jks and put it into
Expand All @@ -42,7 +42,7 @@ android {
defaultConfig {
applicationId "com.android.certifications.niap.permissions.companion"
//targetSdkPreview "Baklava"
targetSdkVersion 36
targetSdkVersion 37

minSdk 28
//minSdkPreview "28"
Expand Down
51 changes: 51 additions & 0 deletions niap-cc/Permissions/Companion/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,57 @@
android:permission="android.permission.BIND_DEPENDENCY_INSTALLER"
android:enabled="true" android:exported="true" />

<!-- for api 37 -->
<service android:name=".services.TestBindInsightSurfaceVisualizerServiceService"
android:permission="android.permission.BIND_INSIGHT_SURFACE_VISUALIZER_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindContextComponentServiceService"
android:permission="android.permission.BIND_CONTEXT_COMPONENT_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindAppSearchIsolatedStorageServiceService"
android:permission="android.permission.BIND_APP_SEARCH_ISOLATED_STORAGE_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindTrustTokenServiceService"
android:permission="android.permission.BIND_TRUST_TOKEN_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindInsightRendererServiceService"
android:permission="android.permission.BIND_INSIGHT_RENDERER_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindDeveloperVerificationAgentService"
android:permission="android.permission.BIND_DEVELOPER_VERIFICATION_AGENT"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindMotionCuesServiceService"
android:permission="android.permission.BIND_MOTION_CUES_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindSettingsContentSafetyServiceService"
android:permission="android.permission.BIND_SETTINGS_CONTENT_SAFETY_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindAllowlistProviderServiceService"
android:permission="android.permission.BIND_ALLOWLIST_PROVIDER_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindSupervisionAppServiceService"
android:permission="android.permission.BIND_SUPERVISION_APP_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindContentSafetyServiceService"
android:permission="android.permission.BIND_CONTENT_SAFETY_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindToTapToShareServiceService"
android:permission="android.permission.BIND_TO_TAP_TO_SHARE_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindSandboxedContentSafetyServiceService"
android:permission="android.permission.BIND_SANDBOXED_CONTENT_SAFETY_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindAlternativeMessageTransportServiceService"
android:permission="android.permission.BIND_ALTERNATIVE_MESSAGE_TRANSPORT_SERVICE"
android:enabled="true" android:exported="true" />
<service android:name=".services.TestBindContentRestrictionServiceService"
android:permission="android.permission.BIND_CONTENT_RESTRICTION_SERVICE"
android:enabled="true" android:exported="true" />

<service android:name=".services.TestBindDataMigrationForPrivatecomputeService"
android:permission="android.permission.BIND_DATA_MIGRATION_FOR_PRIVATECOMPUTE"
android:enabled="true" android:exported="true" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2026 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.certifications.niap.permissions.companion.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

/**
* Exported service used to test the BIND_ALLOWLIST_PROVIDER_SERVICE permission.
*
* This service requires clients are granted the BIND_ALLOWLIST_PROVIDER_SERVICE
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
* and invoke the {@link TestBindAllowlistProviderServiceServiceImpl#testMethod()} method
* to verify that the platform properly enforces this permission requirement.
*/
public class TestBindAllowlistProviderServiceService extends Service {
private static final String TAG = "TestBindAllowlistProviderServiceService";
private TestBindAllowlistProviderServiceServiceImpl bindService;

@Override
public void onCreate() {
super.onCreate();
bindService = new TestBindAllowlistProviderServiceServiceImpl();
}

@Override
public IBinder onBind(Intent intent) {
return bindService;
}

static class TestBindAllowlistProviderServiceServiceImpl extends TestBindService.Stub {
public void testMethod() {
Log.d(TAG, "The caller successfully invoked the test method on service "
+ "TestBindAllowlistProviderServiceServiceService");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2026 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.certifications.niap.permissions.companion.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

/**
* Exported service used to test the BIND_ALTERNATIVE_MESSAGE_TRANSPORT_SERVICE permission.
*
* This service requires clients are granted the BIND_ALTERNATIVE_MESSAGE_TRANSPORT_SERVICE
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
* and invoke the {@link TestBindAlternativeMessageTransportServiceServiceImpl#testMethod()} method
* to verify that the platform properly enforces this permission requirement.
*/
public class TestBindAlternativeMessageTransportServiceService extends Service {
private static final String TAG = "TestBindAlternativeMessageTransportServiceService";
private TestBindAlternativeMessageTransportServiceServiceImpl bindService;

@Override
public void onCreate() {
super.onCreate();
bindService = new TestBindAlternativeMessageTransportServiceServiceImpl();
}

@Override
public IBinder onBind(Intent intent) {
return bindService;
}

static class TestBindAlternativeMessageTransportServiceServiceImpl extends TestBindService.Stub {
public void testMethod() {
Log.d(TAG, "The caller successfully invoked the test method on service "
+ "TestBindAlternativeMessageTransportServiceServiceService");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2025 The Android Open Source Project
* Copyright 2026 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2026 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.certifications.niap.permissions.companion.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

/**
* Exported service used to test the BIND_APP_SEARCH_ISOLATED_STORAGE_SERVICE permission.
*
* This service requires clients are granted the BIND_APP_SEARCH_ISOLATED_STORAGE_SERVICE
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
* and invoke the {@link TestBindAppSearchIsolatedStorageServiceServiceImpl#testMethod()} method
* to verify that the platform properly enforces this permission requirement.
*/
public class TestBindAppSearchIsolatedStorageServiceService extends Service {
private static final String TAG = "TestBindAppSearchIsolatedStorageServiceService";
private TestBindAppSearchIsolatedStorageServiceServiceImpl bindService;

@Override
public void onCreate() {
super.onCreate();
bindService = new TestBindAppSearchIsolatedStorageServiceServiceImpl();
}

@Override
public IBinder onBind(Intent intent) {
return bindService;
}

static class TestBindAppSearchIsolatedStorageServiceServiceImpl extends TestBindService.Stub {
public void testMethod() {
Log.d(TAG, "The caller successfully invoked the test method on service "
+ "TestBindAppSearchIsolatedStorageServiceServiceService");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2026 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.certifications.niap.permissions.companion.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

/**
* Exported service used to test the BIND_CONTENT_RESTRICTION_SERVICE permission.
*
* This service requires clients are granted the BIND_CONTENT_RESTRICTION_SERVICE
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
* and invoke the {@link TestBindContentRestrictionServiceServiceImpl#testMethod()} method
* to verify that the platform properly enforces this permission requirement.
*/
public class TestBindContentRestrictionServiceService extends Service {
private static final String TAG = "TestBindContentRestrictionServiceService";
private TestBindContentRestrictionServiceServiceImpl bindService;

@Override
public void onCreate() {
super.onCreate();
bindService = new TestBindContentRestrictionServiceServiceImpl();
}

@Override
public IBinder onBind(Intent intent) {
return bindService;
}

static class TestBindContentRestrictionServiceServiceImpl extends TestBindService.Stub {
public void testMethod() {
Log.d(TAG, "The caller successfully invoked the test method on service "
+ "TestBindContentRestrictionServiceServiceService");
}
}
}
Loading
Loading