From 0ac1fc9d233b8671f371a71e2a6374b47ef069a9 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 27 Mar 2013 18:56:08 -0700 Subject: [PATCH] Restricted account visibility When accounts are shared to a restricted/limited user, apps can opt-in to viewing accounts of a certain type. Other shared accounts are not visible to the app. App would specify the account type in the manifest tag with the attribute restrictedAccountType="foo.bar", where "foo.bar" is the account type as defined by the authenticator. Change-Id: I7586da04d6d6d32aae15adc6b1366f325bb07384 --- api/current.txt | 1 + core/java/android/content/pm/PackageInfo.java | 5 ++++ .../android/content/pm/PackageParser.java | 10 +++++++ core/res/res/values/attrs_manifest.xml | 5 ++++ core/res/res/values/public.xml | 1 + .../accounts/AccountManagerService.java | 30 ++++++++++++++----- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/api/current.txt b/api/current.txt index d1a904af030b5..9a90c9f6d245a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -858,6 +858,7 @@ package android { field public static final int resource = 16842789; // 0x1010025 field public static final int restoreAnyVersion = 16843450; // 0x10102ba field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d + field public static final int restrictedAccountType = 16843733; // 0x10103d5 field public static final int right = 16843183; // 0x10101af field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093 field public static final int ringtoneType = 16843257; // 0x10101f9 diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java index 77ca7f68e75e5..33a67572c5670 100644 --- a/core/java/android/content/pm/PackageInfo.java +++ b/core/java/android/content/pm/PackageInfo.java @@ -221,6 +221,9 @@ public class PackageInfo implements Parcelable { /** @hide */ public boolean requiredForAllUsers; + /** @hide */ + public String restrictedAccountType; + public PackageInfo() { } @@ -262,6 +265,7 @@ public class PackageInfo implements Parcelable { dest.writeTypedArray(reqFeatures, parcelableFlags); dest.writeInt(installLocation); dest.writeInt(requiredForAllUsers ? 1 : 0); + dest.writeString(restrictedAccountType); } public static final Parcelable.Creator CREATOR @@ -301,5 +305,6 @@ public class PackageInfo implements Parcelable { reqFeatures = source.createTypedArray(FeatureInfo.CREATOR); installLocation = source.readInt(); requiredForAllUsers = source.readInt() != 0; + restrictedAccountType = source.readString(); } } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 149b8e5d2a958..8893538d629a2 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -290,6 +290,7 @@ public class PackageParser { pi.applicationInfo = generateApplicationInfo(p, flags, state, userId); pi.installLocation = p.installLocation; pi.requiredForAllUsers = p.mRequiredForAllUsers; + pi.restrictedAccountType = p.mRestrictedAccountType; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags&PackageManager.GET_GIDS) != 0) { @@ -1766,6 +1767,11 @@ public class PackageParser { false)) { owner.mRequiredForAllUsers = true; } + String accountType = sa.getString(com.android.internal.R.styleable + .AndroidManifestApplication_restrictedAccountType); + if (accountType != null && accountType.length() > 0) { + owner.mRestrictedAccountType = accountType; + } } if (sa.getBoolean( @@ -3193,6 +3199,7 @@ public class PackageParser { } public final static class Package { + public String packageName; // For now we only support one application per package. @@ -3280,6 +3287,9 @@ public class PackageParser { /* An app that's required for all users and cannot be uninstalled for a user */ public boolean mRequiredForAllUsers; + /* The restricted account authenticator type that is used by this application */ + public String mRestrictedAccountType; + /** * Digest suitable for comparing whether this package's manifest is the * same as another. diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 6f59817bf671b..7b70e21226ce8 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -889,6 +889,11 @@ + +