diff options
author | Svetoslav <svetoslavganov@google.com> | 2014-07-16 15:12:03 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-08-05 20:57:20 +0000 |
commit | 976e8bd2017d0263216c62111454438cc0f130e3 (patch) | |
tree | 5cf592fb85841f9e41d3bf6b43422641c3609ab2 /core/java/android/app/admin | |
parent | c79eabcd3c6306bb2ec75f9584b79e661f265127 (diff) | |
download | frameworks_base-976e8bd2017d0263216c62111454438cc0f130e3.zip frameworks_base-976e8bd2017d0263216c62111454438cc0f130e3.tar.gz frameworks_base-976e8bd2017d0263216c62111454438cc0f130e3.tar.bz2 |
Allow adding widgets from user profiles.
The goal of this change is to enable support for appwidget from
user profiles to the user main profile. A user profile is a user
which is associated as a child of the main user profile. For example,
a user may have a personal (parent) and corporate (child) profile.
The device policy should be able to control whether adding a widget
from a child profile and given packages is allowed. This change
assumes that all packages from managed profiles are white listed.
Another change will add the device policy changes.
Change-Id: I267260b55d74c48b112a29979a9f59eef7a8194e
Diffstat (limited to 'core/java/android/app/admin')
3 files changed, 124 insertions, 3 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index e28f00c..ca6b1e8 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -20,6 +20,7 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.app.Activity; +import android.app.admin.IDevicePolicyManager; import android.content.AbstractRestrictionsProvider; import android.content.ComponentName; import android.content.Context; @@ -28,8 +29,6 @@ import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.RestrictionsManager; -import android.media.AudioService; import android.net.ProxyInfo; import android.os.Bundle; import android.os.Handler; @@ -40,7 +39,6 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import android.service.trust.TrustAgentService; import android.util.Log; import com.android.org.conscrypt.TrustedCertificateStore; @@ -55,6 +53,7 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -3079,4 +3078,85 @@ public class DevicePolicyManager { } return false; } + + /** + * Called by the profile owner to enable widget providers from a given package + * to be available in the parent profile. As a result the user will be able to + * add widgets from the white-listed package running under the profile to a widget + * host which runs under the device owner, for example the home screen. Note that + * a package may have zero or more provider components, where each component + * provides a different widget type. + * <p> + * <strong>Note:</strong> By default no widget provider package is white-listed. + * </p> + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param packageName The package from which widget providers are white-listed. + * @return Whether the package was added. + * + * @see #removeCrossProfileWidgetProvider(android.content.ComponentName, String) + * @see #getCrossProfileWidgetProviders(android.content.ComponentName) + */ + public boolean addCrossProfileWidgetProvider(ComponentName admin, String packageName) { + if (mService != null) { + try { + return mService.addCrossProfileWidgetProvider(admin, packageName); + } catch (RemoteException re) { + Log.w(TAG, "Error calling addCrossProfileWidgetProvider", re); + } + } + return false; + } + + /** + * Called by the profile owner to disable widget providers from a given package + * to be available in the parent profile. For this method to take effect the + * package should have been added via {@link #addCrossProfileWidgetProvider( + * android.content.ComponentName, String)}. + * <p> + * <strong>Note:</strong> By default no widget provider package is white-listed. + * </p> + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param packageName The package from which widget providers are no longer + * white-listed. + * @return Whether the package was removed. + * + * @see #addCrossProfileWidgetProvider(android.content.ComponentName, String) + * @see #getCrossProfileWidgetProviders(android.content.ComponentName) + */ + public boolean removeCrossProfileWidgetProvider(ComponentName admin, String packageName) { + if (mService != null) { + try { + return mService.removeCrossProfileWidgetProvider(admin, packageName); + } catch (RemoteException re) { + Log.w(TAG, "Error calling removeCrossProfileWidgetProvider", re); + } + } + return false; + } + + /** + * Called by the profile owner to query providers from which packages are + * available in the parent profile. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @return The white-listed package list. + * + * @see #addCrossProfileWidgetProvider(android.content.ComponentName, String) + * @see #removeCrossProfileWidgetProvider(android.content.ComponentName, String) + */ + public List<String> getCrossProfileWidgetProviders(ComponentName admin) { + if (mService != null) { + try { + List<String> providers = mService.getCrossProfileWidgetProviders(admin); + if (providers != null) { + return providers; + } + } catch (RemoteException re) { + Log.w(TAG, "Error calling getCrossProfileWidgetProviders", re); + } + } + return Collections.emptyList(); + } } diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java new file mode 100644 index 0000000..edd8199 --- /dev/null +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 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 android.app.admin; + +import java.util.List; + +/** + * Device policy manager local system service interface. + * + * @hide Only for use within the system server. + */ +public abstract class DevicePolicyManagerInternal { + + /** + * Gets the packages whose widget providers are white-listed to be + * available in the parent user. + * + * @param profileId The profile id. + * @return The list of packages if such or empty list if there are + * no white-listed packages or the profile id is not a managed + * profile. + */ + public abstract List<String> getCrossProfileWidgetProviders(int profileId); +} diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 6ce737a..8954c0d 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -175,4 +175,7 @@ interface IDevicePolicyManager { void setTrustAgentFeaturesEnabled(in ComponentName admin, in ComponentName agent, in List<String> features, int userId); List<String> getTrustAgentFeaturesEnabled(in ComponentName admin, in ComponentName agent, int userId); + boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName); + boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName); + List<String> getCrossProfileWidgetProviders(in ComponentName admin); } |