com.android.server.SystemConfig Java Examples

The following examples show how to use com.android.server.SystemConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PermissionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether a package is whitelisted for a particular privapp permission.
 *
 * <p>Does NOT check whether the package is a privapp, just whether it's whitelisted.
 *
 * <p>This handles parent/child apps.
 */
private boolean hasPrivappWhitelistEntry(String perm, PackageParser.Package pkg) {
    ArraySet<String> wlPermissions = null;
    if (pkg.isVendor()) {
        wlPermissions =
                SystemConfig.getInstance().getVendorPrivAppPermissions(pkg.packageName);
    } else if (pkg.isProduct()) {
        wlPermissions =
                SystemConfig.getInstance().getProductPrivAppPermissions(pkg.packageName);
    } else {
        wlPermissions = SystemConfig.getInstance().getPrivAppPermissions(pkg.packageName);
    }
    // Let's check if this package is whitelisted...
    boolean whitelisted = wlPermissions != null && wlPermissions.contains(perm);
    // If it's not, we'll also tail-recurse to the parent.
    return whitelisted ||
            pkg.parentPackage != null && hasPrivappWhitelistEntry(perm, pkg.parentPackage);
}
 
Example #2
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private int runGetPrivappPermissions() {
    final String pkg = getNextArg();
    if (pkg == null) {
        getErrPrintWriter().println("Error: no package specified.");
        return 1;
    }

    ArraySet<String> privAppPermissions = null;
    if (isVendorApp(pkg)) {
        privAppPermissions = SystemConfig.getInstance().getVendorPrivAppPermissions(pkg);
    } else if (isProductApp(pkg)) {
        privAppPermissions = SystemConfig.getInstance().getProductPrivAppPermissions(pkg);
    } else {
        privAppPermissions = SystemConfig.getInstance().getPrivAppPermissions(pkg);
    }

    getOutPrintWriter().println(privAppPermissions == null
            ? "{}" : privAppPermissions.toString());
    return 0;
}
 
Example #3
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private int runGetPrivappDenyPermissions() {
    final String pkg = getNextArg();
    if (pkg == null) {
        getErrPrintWriter().println("Error: no package specified.");
        return 1;
    }

    ArraySet<String> privAppPermissions = null;
    if (isVendorApp(pkg)) {
        privAppPermissions = SystemConfig.getInstance().getVendorPrivAppDenyPermissions(pkg);
    } else if (isProductApp(pkg)) {
        privAppPermissions = SystemConfig.getInstance().getProductPrivAppDenyPermissions(pkg);
    } else {
        privAppPermissions = SystemConfig.getInstance().getPrivAppDenyPermissions(pkg);
    }

    getOutPrintWriter().println(privAppPermissions == null
            ? "{}" : privAppPermissions.toString());
    return 0;
}
 
Example #4
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private int runGetOemPermissions() {
    final String pkg = getNextArg();
    if (pkg == null) {
        getErrPrintWriter().println("Error: no package specified.");
        return 1;
    }
    final Map<String, Boolean> oemPermissions = SystemConfig.getInstance()
            .getOemPermissions(pkg);
    if (oemPermissions == null || oemPermissions.isEmpty()) {
        getOutPrintWriter().println("{}");
    } else {
        oemPermissions.forEach((permission, granted) ->
                getOutPrintWriter().println(permission + " granted:" + granted)
        );
    }
    return 0;
}
 
Example #5
Source File: PermissionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static boolean canGrantOemPermission(PackageSetting ps, String permission) {
    if (!ps.isOem()) {
        return false;
    }
    // all oem permissions must explicitly be granted or denied
    final Boolean granted =
            SystemConfig.getInstance().getOemPermissions(ps.name).get(permission);
    if (granted == null) {
        throw new IllegalStateException("OEM permission" + permission + " requested by package "
                + ps.name + " must be explicitly declared granted or not");
    }
    return Boolean.TRUE == granted;
}
 
Example #6
Source File: ApplicationInfo.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private boolean isPackageWhitelistedForHiddenApis() {
    return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
}
 
Example #7
Source File: ApplicationInfo.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private boolean isPackageWhitelistedForHiddenApis() {
    return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
}
 
Example #8
Source File: PermissionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
PermissionManagerService(Context context,
        @Nullable DefaultPermissionGrantedCallback defaultGrantCallback,
        @NonNull Object externalLock) {
    mContext = context;
    mLock = externalLock;
    mPackageManagerInt = LocalServices.getService(PackageManagerInternal.class);
    mUserManagerInt = LocalServices.getService(UserManagerInternal.class);
    mSettings = new PermissionSettings(context, mLock);

    mHandlerThread = new ServiceThread(TAG,
            Process.THREAD_PRIORITY_BACKGROUND, true /*allowIo*/);
    mHandlerThread.start();
    mHandler = new Handler(mHandlerThread.getLooper());
    Watchdog.getInstance().addThread(mHandler);

    mDefaultPermissionGrantPolicy = new DefaultPermissionGrantPolicy(
            context, mHandlerThread.getLooper(), defaultGrantCallback, this);
    SystemConfig systemConfig = SystemConfig.getInstance();
    mSystemPermissions = systemConfig.getSystemPermissions();
    mGlobalGids = systemConfig.getGlobalGids();

    // propagate permission configuration
    final ArrayMap<String, SystemConfig.PermissionEntry> permConfig =
            SystemConfig.getInstance().getPermissions();
    synchronized (mLock) {
        for (int i=0; i<permConfig.size(); i++) {
            final SystemConfig.PermissionEntry perm = permConfig.valueAt(i);
            BasePermission bp = mSettings.getPermissionLocked(perm.name);
            if (bp == null) {
                bp = new BasePermission(perm.name, "android", BasePermission.TYPE_BUILTIN);
                mSettings.putPermissionLocked(perm.name, bp);
            }
            if (perm.gids != null) {
                bp.setGids(perm.gids, perm.perUser);
            }
        }
    }

    LocalServices.addService(
            PermissionManagerInternal.class, new PermissionManagerInternalImpl());
}
 
Example #9
Source File: VrManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void onBootPhase(int phase) {
    if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
        LocalServices.getService(ActivityManagerInternal.class)
                .registerScreenObserver(this);

        mNotificationManager = INotificationManager.Stub.asInterface(
                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
        synchronized (mLock) {
            Looper looper = Looper.getMainLooper();
            Handler handler = new Handler(looper);
            ArrayList<EnabledComponentChangeListener> listeners = new ArrayList<>();
            listeners.add(this);
            mComponentObserver = EnabledComponentsObserver.build(mContext, handler,
                    Settings.Secure.ENABLED_VR_LISTENERS, looper,
                    android.Manifest.permission.BIND_VR_LISTENER_SERVICE,
                    VrListenerService.SERVICE_INTERFACE, mLock, listeners);

            mComponentObserver.rebuildAll();
        }

        //TODO: something more robust than picking the first one
        ArraySet<ComponentName> defaultVrComponents =
                SystemConfig.getInstance().getDefaultVrComponents();
        if (defaultVrComponents.size() > 0) {
            mDefaultVrService = defaultVrComponents.valueAt(0);
        } else {
            Slog.i(TAG, "No default vr listener service found.");
        }

        DisplayManager dm =
                (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
        mVr2dDisplay = new Vr2dDisplay(
                dm,
                LocalServices.getService(ActivityManagerInternal.class),
                LocalServices.getService(WindowManagerInternal.class),
                mVrManager);
        mVr2dDisplay.init(getContext(), mBootsToVr);

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
        getContext().registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) {
                        VrManagerService.this.setUserUnlocked();
                    }
                }
            }, intentFilter);
    }
}
 
Example #10
Source File: ApplicationInfo.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private boolean isPackageWhitelistedForHiddenApis() {
    return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
}