Search in sources :

Example 1 with SliceManager

use of android.app.slice.SliceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsSliceProvider method grantWhitelistedPackagePermissions.

@VisibleForTesting
static void grantWhitelistedPackagePermissions(Context context, List<Uri> descendants) {
    if (descendants == null) {
        Log.d(TAG, "No descendants to grant permission with, skipping.");
    }
    final String[] whitelistPackages = context.getResources().getStringArray(R.array.slice_whitelist_package_names);
    if (whitelistPackages == null || whitelistPackages.length == 0) {
        Log.d(TAG, "No packages to whitelist, skipping.");
        return;
    } else {
        Log.d(TAG, String.format("Whitelisting %d uris to %d pkgs.", descendants.size(), whitelistPackages.length));
    }
    final SliceManager sliceManager = context.getSystemService(SliceManager.class);
    for (Uri descendant : descendants) {
        for (String toPackage : whitelistPackages) {
            sliceManager.grantSlicePermission(toPackage, descendant);
        }
    }
}
Also used : SliceManager(android.app.slice.SliceManager) Uri(android.net.Uri) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 2 with SliceManager

use of android.app.slice.SliceManager in project android_packages_apps_Settings by omnirom.

the class SettingsSliceProvider method grantAllowlistedPackagePermissions.

@VisibleForTesting
static void grantAllowlistedPackagePermissions(Context context, List<Uri> descendants) {
    if (descendants == null) {
        Log.d(TAG, "No descendants to grant permission with, skipping.");
    }
    final String[] allowlistPackages = context.getResources().getStringArray(R.array.slice_allowlist_package_names);
    if (allowlistPackages == null || allowlistPackages.length == 0) {
        Log.d(TAG, "No packages to allowlist, skipping.");
        return;
    } else {
        Log.d(TAG, String.format("Allowlisting %d uris to %d pkgs.", descendants.size(), allowlistPackages.length));
    }
    final SliceManager sliceManager = context.getSystemService(SliceManager.class);
    for (Uri descendant : descendants) {
        for (String toPackage : allowlistPackages) {
            sliceManager.grantSlicePermission(toPackage, descendant);
        }
    }
}
Also used : SliceManager(android.app.slice.SliceManager) Uri(android.net.Uri) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 3 with SliceManager

use of android.app.slice.SliceManager in project robolectric by robolectric.

the class ShadowSliceManagerTest method setUp.

@Before
public void setUp() {
    PackageManager packageManager = RuntimeEnvironment.getApplication().getPackageManager();
    ShadowApplicationPackageManager shadowPackageManager = (ShadowApplicationPackageManager) shadowOf(packageManager);
    shadowPackageManager.setPackagesForUid(PACKAGE_1_UID, PACKAGE_NAME_1);
    shadowPackageManager.setPackagesForUid(PACKAGE_2_UID, PACKAGE_NAME_2);
    sliceUri1 = Uri.parse("content://a/b");
    sliceUri2 = Uri.parse("content://c/d");
    sliceManager = ApplicationProvider.getApplicationContext().getSystemService(SliceManager.class);
}
Also used : PackageManager(android.content.pm.PackageManager) SliceManager(android.app.slice.SliceManager) Before(org.junit.Before)

Aggregations

SliceManager (android.app.slice.SliceManager)3 Uri (android.net.Uri)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 PackageManager (android.content.pm.PackageManager)1 Before (org.junit.Before)1