Skip to content

Commit 8dc0410

Browse files
authored
Merge pull request #51 from KVVat/niap-permissions-update-sdk36
Niap permissions update sdk36
2 parents 96dcd75 + 44fed55 commit 8dc0410

File tree

364 files changed

+44372
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+44372
-497
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/security/

niap-cc/Permissions/Companion/app/build.gradle

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
apply plugin: 'com.android.application'
1818
def applicationName = 'Companion'
1919
android {
20-
compileSdk 34
20+
//compileSdkPreview "VanillaIceCream"
21+
//compileSdkPreview "Baklava"
22+
compileSdk 36
2123
signingConfigs {
2224
// TODO :
2325
// Prepare your own companion.jks and put it into
@@ -39,9 +41,11 @@ android {
3941
}
4042
defaultConfig {
4143
applicationId "com.android.certifications.niap.permissions.companion"
42-
minSdkVersion 28
43-
//noinspection EditedTargetSdkVersion,OldTargetApi
44-
targetSdkVersion 34
44+
//targetSdkPreview "Baklava"
45+
targetSdkVersion 36
46+
47+
minSdk 28
48+
//minSdkPreview "28"
4549
versionCode 1
4650
versionName "1.0"
4751
signingConfig signingConfigs.platform
@@ -98,10 +102,10 @@ configurations.implementation {
98102

99103
dependencies {
100104
implementation fileTree(dir: "libs", include: ["*.jar"])
101-
implementation 'androidx.appcompat:appcompat:1.6.1'
102-
implementation 'com.google.android.material:material:1.9.0'
105+
implementation 'androidx.appcompat:appcompat:1.7.0'
106+
implementation 'com.google.android.material:material:1.12.0'
103107
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
104-
implementation 'com.google.android.gms:play-services-location:21.0.1'
108+
implementation 'com.google.android.gms:play-services-location:21.3.0'
105109
testImplementation 'junit:junit:4.13.2'
106110
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
107111
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

niap-cc/Permissions/Companion/app/src/main/AndroidManifest.xml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,35 @@
511511
<service android:name="com.android.certifications.niap.permissions.companion.services.TestBindWearableSensingServiceService"
512512
android:permission="android.permission.BIND_WEARABLE_SENSING_SERVICE"
513513
android:enabled="true" android:exported="true" />
514-
514+
<!-- Services for android V -->
515+
<service android:name=".services.TestBindTvAdServiceService"
516+
android:permission="android.permission.BIND_TV_AD_SERVICE"
517+
android:enabled="true" android:exported="true" />
518+
<service android:name=".services.TestBindDomainSelectionServiceService"
519+
android:permission="android.permission.BIND_DOMAIN_SELECTION_SERVICE"
520+
android:enabled="true" android:exported="true" />
521+
<service android:name=".services.TestBindOnDeviceIntelligenceServiceService"
522+
android:permission="android.permission.BIND_ON_DEVICE_INTELLIGENCE_SERVICE"
523+
android:enabled="true" android:exported="true" />
524+
<service android:name=".services.TestBindOnDeviceSandboxedInferenceServiceService"
525+
android:permission="android.permission.BIND_ON_DEVICE_SANDBOXED_INFERENCE_SERVICE"
526+
android:enabled="true" android:exported="true" />
527+
<!-- for api 36 -->
528+
<service android:name=".services.TestBindPopulationDensityProviderServiceService"
529+
android:permission="android.permission.BIND_POPULATION_DENSITY_PROVIDER_SERVICE"
530+
android:enabled="true" android:exported="true" />
531+
<service android:name=".services.TestBindIntrusionDetectionEventTransportServiceService"
532+
android:permission="android.permission.BIND_INTRUSION_DETECTION_EVENT_TRANSPORT_SERVICE"
533+
android:enabled="true" android:exported="true" />
534+
<service android:name=".services.TestBindRkpServiceService"
535+
android:permission="android.permission.BIND_RKP_SERVICE"
536+
android:enabled="true" android:exported="true" />
537+
<service android:name=".services.TestBindAppFunctionServiceService"
538+
android:permission="android.permission.BIND_APP_FUNCTION_SERVICE"
539+
android:enabled="true" android:exported="true" />
540+
<service android:name=".services.TestBindDependencyInstallerService"
541+
android:permission="android.permission.BIND_DEPENDENCY_INSTALLER"
542+
android:enabled="true" android:exported="true" />
515543

516544
</application>
517545

niap-cc/Permissions/Companion/app/src/main/java/com/android/certifications/niap/permissions/companion/MainActivity.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public boolean deviceConfigSetProperty(String namespace,String name,String value
155155
boolean.class}, namespace, name, value, makeDefault);
156156
return (boolean)r;
157157
} catch (Exception e) {
158-
logdebug("DeviceConfig.setProperty failed.(" + a + "," + b + "," + value + ")",e);
158+
logdebug("DeviceConfig.setProperty failed.(" + namespace + "," + name + "," + value + ")",e);
159159
e.printStackTrace();
160160
return false;
161161
}
@@ -203,7 +203,7 @@ protected void onCreate(Bundle savedInstanceState) {
203203
}
204204

205205
mSetupButton = findViewById(R.id.setupButton);
206-
mCheckBoxButton = findViewById(R.id.flgDPECheckBox);
206+
//mCheckBoxButton = findViewById(R.id.flgDPECheckBox);
207207
mSetupButton.setOnClickListener(new View.OnClickListener() {
208208
@Override
209209
public void onClick(View view) {
@@ -237,24 +237,28 @@ protected Boolean doInBackground(Void... noParams) {
237237
boolean result;
238238
setupLocusTest();
239239
result = setupMediaLocationTest();
240+
//logdebug("result1>"+result);
240241
if (mGmsAvailable) {
241242
// if the location settings are not correct then prompt the user for correction
242243
// before attempting to set up the location tests.
243244
if (!verifyLocationSettings()) {
245+
//logdebug("verifylocation>"+result);
244246
return false;
245247
}
246248
result = result && setupLocationTest();
249+
//logdebug("result2>"+result);
247250
}
248251
/**
249252
* Set flags for enable experimental flags to new device_policy_engine
250253
* as of android 14
251254
*/
252255
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
253256
String value = "false";
254-
if(mCheckBoxButton.isChecked()){
257+
//disabled : because it's infeasible to test with this application
258+
/*if(mCheckBoxButton.isChecked()){
255259
value = "true";
256-
}
257-
260+
}*/
261+
/*
258262
String dvc =
259263
deviceConfigGetProperty("device_policy_manager", "enable_device_policy_engine");
260264
if(dvc == null || !dvc.equals(value)){
@@ -272,6 +276,8 @@ protected Boolean doInBackground(Void... noParams) {
272276
logdebug("force flag enable_permission_based_access set "+value+"=>"
273277
+deviceConfigGetProperty("device_policy_manager",
274278
"enable_permission_based_access"));
279+
280+
*/
275281
}
276282

277283
return result;
@@ -399,7 +405,8 @@ public void onReceive(Context context, Intent intent) {
399405
boolean locationReceived = false;
400406
if(Build.VERSION.SDK_INT<Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
401407
Intent intent = new Intent(ACCESS_LOCATION_ACTION);
402-
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent,
408+
PendingIntent pendingIntent =
409+
PendingIntent.getBroadcast(this, 0, intent,
403410
PendingIntent.FLAG_MUTABLE);
404411
//FLAG_NO_CREATE
405412

@@ -423,11 +430,13 @@ public void onReceive(Context context, Intent intent) {
423430
logerror("Location update not received within timeout window");
424431
}
425432
} else {
433+
426434
//Implementation for android UDC or later (maybe it works on more previous versions)
427435
latch[0] = new CountDownLatch(1);
428436
LocationCallback locationCallback = new LocationCallback() {
429437
@Override
430438
public void onLocationResult(LocationResult locationResult) {
439+
//logdebug("onlocation result");
431440
if (locationResult == null) {
432441
return;
433442
}
@@ -443,11 +452,16 @@ public void onLocationResult(LocationResult locationResult) {
443452

444453
FusedLocationProviderClient locationClient =
445454
LocationServices.getFusedLocationProviderClient(getApplicationContext());
455+
446456
locationClient.requestLocationUpdates(locationRequest,
447457
locationCallback,
448458
Looper.getMainLooper());
449459
try {
460+
//logdebug("start checking");
450461
locationReceived = latch[0].await(10, TimeUnit.SECONDS);
462+
if(!locationReceived){
463+
logerror("Operation timeout, maybe location feature is disabled or no internet connection.");
464+
}
451465
} catch (InterruptedException e) {
452466
logerror("Caught an InterruptedException: "+e.getLocalizedMessage(),e);
453467
}
@@ -591,7 +605,7 @@ private void setupLocusTest() {
591605
@Override
592606
public void onRequestPermissionsResult(int requestCode, String[] permissions,
593607
int[] grantResults) {
594-
//Inspector request below line but in this case we shouldn't call super method.
608+
//Inspector requests below line but in this case we shouldn't call super method.
595609
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
596610
boolean permissionGranted = true;
597611
for (int grantResult : grantResults) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.certifications.niap.permissions.companion.services;
17+
18+
import android.app.Service;
19+
import android.content.Intent;
20+
import android.os.IBinder;
21+
import android.util.Log;
22+
23+
/**
24+
* Exported service used to test the BIND_APP_FUNCTION_SERVICE permission.
25+
*
26+
* This service requires clients are granted the BIND_APP_FUNCTION_SERVICE
27+
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
28+
* and invoke the {@link TestBindAppFunctionServiceServiceImpl#testMethod()} method
29+
* to verify that the platform properly enforces this permission requirement.
30+
*/
31+
public class TestBindAppFunctionServiceService extends Service {
32+
private static final String TAG = "TestBindAppFunctionServiceService";
33+
private TestBindAppFunctionServiceServiceImpl bindService;
34+
35+
@Override
36+
public void onCreate() {
37+
super.onCreate();
38+
bindService = new TestBindAppFunctionServiceServiceImpl();
39+
}
40+
41+
@Override
42+
public IBinder onBind(Intent intent) {
43+
return bindService;
44+
}
45+
46+
static class TestBindAppFunctionServiceServiceImpl extends TestBindService.Stub {
47+
public void testMethod() {
48+
Log.d(TAG, "The caller successfully invoked the test method on service "
49+
+ "TestBindAppFunctionServiceServiceService");
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.certifications.niap.permissions.companion.services;
17+
18+
import android.app.Service;
19+
import android.content.Intent;
20+
import android.os.IBinder;
21+
import android.util.Log;
22+
23+
/**
24+
* Exported service used to test the BIND_DEPENDENCY_INSTALLER permission.
25+
*
26+
* This service requires clients are granted the BIND_DEPENDENCY_INSTALLER
27+
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
28+
* and invoke the {@link TestBindDependencyInstallerServiceImpl#testMethod()} method
29+
* to verify that the platform properly enforces this permission requirement.
30+
*/
31+
public class TestBindDependencyInstallerService extends Service {
32+
private static final String TAG = "TestBindDependencyInstallerService";
33+
private TestBindDependencyInstallerServiceImpl bindService;
34+
35+
@Override
36+
public void onCreate() {
37+
super.onCreate();
38+
bindService = new TestBindDependencyInstallerServiceImpl();
39+
}
40+
41+
@Override
42+
public IBinder onBind(Intent intent) {
43+
return bindService;
44+
}
45+
46+
static class TestBindDependencyInstallerServiceImpl extends TestBindService.Stub {
47+
public void testMethod() {
48+
Log.d(TAG, "The caller successfully invoked the test method on service "
49+
+ "TestBindDependencyInstallerServiceService");
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.certifications.niap.permissions.companion.services;
17+
18+
import android.app.Service;
19+
import android.content.Intent;
20+
import android.os.IBinder;
21+
import android.util.Log;
22+
23+
/**
24+
* Exported service used to test the BIND_DOMAIN_SELECTION_SERVICE permission.
25+
*
26+
* This service requires clients are granted the BIND_DOMAIN_SELECTION_SERVICE
27+
* permission to bind to it. The Permission Test Tool can attempt to bind to this service
28+
* and invoke the {@link TestBindDomainSelectionServiceServiceImpl#testMethod()} method
29+
* to verify that the platform properly enforces this permission requirement.
30+
*/
31+
public class TestBindDomainSelectionServiceService extends Service {
32+
private static final String TAG = "TestBindDomainSelectionServiceService";
33+
private TestBindDomainSelectionServiceServiceImpl bindService;
34+
35+
@Override
36+
public void onCreate() {
37+
super.onCreate();
38+
bindService = new TestBindDomainSelectionServiceServiceImpl();
39+
}
40+
41+
@Override
42+
public IBinder onBind(Intent intent) {
43+
return bindService;
44+
}
45+
46+
static class TestBindDomainSelectionServiceServiceImpl extends TestBindService.Stub {
47+
public void testMethod() {
48+
Log.d(TAG, "The caller successfully invoked the test method on service "
49+
+ "TestBindDomainSelectionServiceServiceService");
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)