diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/admin/DeviceAdminInfo.java | 35 | ||||
| -rw-r--r-- | core/java/android/app/admin/DeviceAdminReceiver.java | 25 | ||||
| -rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 7 |
3 files changed, 32 insertions, 35 deletions
diff --git a/core/java/android/app/admin/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java index ed2aaf915ef2..5fbe5b398488 100644 --- a/core/java/android/app/admin/DeviceAdminInfo.java +++ b/core/java/android/app/admin/DeviceAdminInfo.java @@ -16,31 +16,31 @@ package android.app.admin; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlSerializer; - import android.annotation.NonNull; import android.content.ComponentName; import android.content.Context; import android.content.pm.ActivityInfo; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; import android.content.res.Resources; +import android.content.res.Resources.NotFoundException; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; -import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; +import android.os.PersistableBundle; import android.util.AttributeSet; import android.util.Log; import android.util.Printer; import android.util.SparseArray; import android.util.Xml; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlSerializer; + import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -266,6 +266,12 @@ public final class DeviceAdminInfo implements Parcelable { */ int mUsesPolicies; + /** + * Whether this administrator can be a target in an ownership transfer. + * + * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle) + */ + boolean mSupportsTransferOwnership; /** * Constructor. @@ -347,6 +353,12 @@ public final class DeviceAdminInfo implements Parcelable { + getComponent() + ": " + policyName); } } + } else if (tagName.equals("support-transfer-ownership")) { + if (parser.next() != XmlPullParser.END_TAG) { + throw new XmlPullParserException( + "support-transfer-ownership tag must be empty."); + } + mSupportsTransferOwnership = true; } } } catch (NameNotFoundException e) { @@ -360,6 +372,7 @@ public final class DeviceAdminInfo implements Parcelable { DeviceAdminInfo(Parcel source) { mActivityInfo = ActivityInfo.CREATOR.createFromParcel(source); mUsesPolicies = source.readInt(); + mSupportsTransferOwnership = source.readBoolean(); } /** @@ -458,6 +471,13 @@ public final class DeviceAdminInfo implements Parcelable { return sRevKnownPolicies.get(policyIdent).tag; } + /** + * Return true if this administrator can be a target in an ownership transfer. + */ + public boolean supportsTransferOwnership() { + return mSupportsTransferOwnership; + } + /** @hide */ public ArrayList<PolicyInfo> getUsedPolicies() { ArrayList<PolicyInfo> res = new ArrayList<PolicyInfo>(); @@ -502,6 +522,7 @@ public final class DeviceAdminInfo implements Parcelable { public void writeToParcel(Parcel dest, int flags) { mActivityInfo.writeToParcel(dest, flags); dest.writeInt(mUsesPolicies); + dest.writeBoolean(mSupportsTransferOwnership); } /** diff --git a/core/java/android/app/admin/DeviceAdminReceiver.java b/core/java/android/app/admin/DeviceAdminReceiver.java index 8c30fc403713..1c9477d08cb3 100644 --- a/core/java/android/app/admin/DeviceAdminReceiver.java +++ b/core/java/android/app/admin/DeviceAdminReceiver.java @@ -505,31 +505,6 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public static final String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE = "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE"; - /** - * Name under which a device administration component indicates whether it supports transfer of - * ownership. This meta-data is of type <code>boolean</code>. A value of <code>true</code> - * allows this administrator to be used as a target administrator for a transfer. If the value - * is <code>false</code>, ownership cannot be transferred to this administrator. The default - * value is <code>false</code>. - * <p>This metadata is used to avoid ownership transfer migration to an administrator with a - * version which does not yet support it. - * <p>Usage: - * <pre> - * <receiver name="..." android:permission="android.permission.BIND_DEVICE_ADMIN"> - * <meta-data - * android:name="android.app.device_admin" - * android:resource="@xml/..." /> - * <meta-data - * android:name="android.app.support_transfer_ownership" - * android:value="true" /> - * </receiver> - * </pre> - * - * @see DevicePolicyManager#transferOwnership(ComponentName, ComponentName, PersistableBundle) - */ - public static final String SUPPORT_TRANSFER_OWNERSHIP_META_DATA = - "android.app.support_transfer_ownership"; - private DevicePolicyManager mManager; private ComponentName mWho; diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index d42fa996ceff..6511f214f19d 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -9302,9 +9302,10 @@ public class DevicePolicyManager { * after calling this method. * * <p>The incoming target administrator must have the - * {@link DeviceAdminReceiver#SUPPORT_TRANSFER_OWNERSHIP_META_DATA} <code>meta-data</code> tag - * included in its corresponding <code>receiver</code> component with a value of {@code true}. - * Otherwise an {@link IllegalArgumentException} will be thrown. + * <code><support-transfer-ownership /></code> tag inside the + * <code><device-admin></device-admin></code> tags in the xml file referenced by + * {@link DeviceAdminReceiver#DEVICE_ADMIN_META_DATA}. Otherwise an + * {@link IllegalArgumentException} will be thrown. * * @param admin which {@link DeviceAdminReceiver} this request is associated with * @param target which {@link DeviceAdminReceiver} we want the new administrator to be |
