summaryrefslogtreecommitdiffstats
path: root/core/java/android/app
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/app')
-rw-r--r--core/java/android/app/ContextImpl.java28
-rw-r--r--core/java/android/app/Notification.java22
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java86
-rw-r--r--core/java/android/app/admin/DevicePolicyManagerInternal.java38
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl3
5 files changed, 151 insertions, 26 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 5f606a6..4cf8cb4 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -18,10 +18,12 @@ package android.app;
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageStatsManager;
+import android.appwidget.AppWidgetManager;
import android.os.Build;
import android.service.persistentdata.IPersistentDataBlockService;
import android.service.persistentdata.PersistentDataBlockManager;
+import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.policy.PolicyManager;
import com.android.internal.util.Preconditions;
@@ -148,7 +150,6 @@ import android.app.trust.TrustManager;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IAppOpsService;
-import com.android.internal.appwidget.IAppWidgetService.Stub;
import com.android.internal.os.IDropBoxManagerService;
import com.android.internal.telecomm.ITelecommService;
@@ -771,6 +772,12 @@ class ContextImpl extends Context {
return new MediaProjectionManager(ctx);
}
});
+
+ registerService(APPWIDGET_SERVICE, new ServiceFetcher() {
+ public Object createService(ContextImpl ctx) {
+ IBinder b = ServiceManager.getService(APPWIDGET_SERVICE);
+ return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
+ }});
}
static ContextImpl getImpl(Context context) {
@@ -2100,6 +2107,25 @@ class ContextImpl extends Context {
}
@Override
+ public Context createApplicationContext(ApplicationInfo application, int flags)
+ throws NameNotFoundException {
+ LoadedApk pi = mMainThread.getPackageInfo(application, mResources.getCompatibilityInfo(),
+ flags | CONTEXT_REGISTER_PACKAGE);
+ if (pi != null) {
+ final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
+ ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
+ new UserHandle(UserHandle.getUserId(application.uid)), restricted,
+ mDisplay, mOverrideConfiguration);
+ if (c.mResources != null) {
+ return c;
+ }
+ }
+
+ throw new PackageManager.NameNotFoundException(
+ "Application package " + application.packageName + " not found");
+ }
+
+ @Override
public Context createPackageContext(String packageName, int flags)
throws NameNotFoundException {
return createPackageContextAsUser(packageName, flags,
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 21525bc..797a0a0 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1707,28 +1707,6 @@ public class Notification implements Parcelable
}
}
- /** {@hide} */
- public void setUser(UserHandle user) {
- if (user.getIdentifier() == UserHandle.USER_ALL) {
- user = UserHandle.OWNER;
- }
- if (tickerView != null) {
- tickerView.setUser(user);
- }
- if (contentView != null) {
- contentView.setUser(user);
- }
- if (bigContentView != null) {
- bigContentView.setUser(user);
- }
- if (headsUpContentView != null) {
- headsUpContentView.setUser(user);
- }
- if (publicVersion != null) {
- publicVersion.setUser(user);
- }
- }
-
/**
* @hide
*/
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);
}