diff options
author | Amith Yamasani <yamasani@google.com> | 2011-04-19 10:41:20 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-19 10:41:20 -0700 |
commit | 25641ca1ac5b09727f86fe01389877332a00455d (patch) | |
tree | e18f66c852164f4fbc6fbdf3d7c689b9b2ac3d83 /core/java | |
parent | 08d1f937236230756bffde241ad6b335da368cf9 (diff) | |
parent | 0b285499db739ba50f2f839d633e763c70e67f96 (diff) | |
download | frameworks_base-25641ca1ac5b09727f86fe01389877332a00455d.zip frameworks_base-25641ca1ac5b09727f86fe01389877332a00455d.tar.gz frameworks_base-25641ca1ac5b09727f86fe01389877332a00455d.tar.bz2 |
Merge "Plumbing in PackageManager and installd for multi-user support."
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/ApplicationPackageManager.java | 13 | ||||
-rw-r--r-- | core/java/android/content/pm/IPackageManager.aidl | 4 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 46 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 1 | ||||
-rw-r--r-- | core/java/android/content/pm/UserInfo.aidl | 20 | ||||
-rw-r--r-- | core/java/android/content/pm/UserInfo.java | 3 |
6 files changed, 78 insertions, 9 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index ef8ba8e..85918cf 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -1113,7 +1113,11 @@ final class ApplicationPackageManager extends PackageManager { */ @Override public UserInfo createUser(String name, int flags) { - // TODO + try { + return mPM.createUser(name, flags); + } catch (RemoteException e) { + // Should never happen! + } return null; } @@ -1136,8 +1140,11 @@ final class ApplicationPackageManager extends PackageManager { */ @Override public boolean removeUser(int id) { - // TODO: - return false; + try { + return mPM.removeUser(id); + } catch (RemoteException e) { + return false; + } } /** diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl index fbf8f92..11cd446 100644 --- a/core/java/android/content/pm/IPackageManager.aidl +++ b/core/java/android/content/pm/IPackageManager.aidl @@ -35,6 +35,7 @@ import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.pm.UserInfo; import android.net.Uri; import android.content.IntentSender; @@ -329,4 +330,7 @@ interface IPackageManager { boolean setInstallLocation(int loc); int getInstallLocation(); + + UserInfo createUser(in String name, int flags); + boolean removeUser(int userId); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 99c4c7f..ff817c1 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -662,10 +662,15 @@ public abstract class PackageManager { public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; /** - * Feature for {@link #getSystemAvailableFeatures} and - * {@link #hasSystemFeature}: The device's audio pipeline is low-latency, - * more suitable for audio applications sensitive to delays or lag in - * sound input or output. + * Range of IDs allocated for a user. + * @hide + */ + public static final int PER_USER_RANGE = 100000; + + /** + * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's + * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or + * lag in sound input or output. */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; @@ -2387,4 +2392,37 @@ public abstract class PackageManager { * @hide */ public abstract void updateUserFlags(int id, int flags); + + /** + * Checks to see if the user id is the same for the two uids, i.e., they belong to the same + * user. + * @hide + */ + public static boolean isSameUser(int uid1, int uid2) { + return getUserId(uid1) == getUserId(uid2); + } + + /** + * Returns the user id for a given uid. + * @hide + */ + public static int getUserId(int uid) { + return uid / PER_USER_RANGE; + } + + /** + * Returns the uid that is composed from the userId and the appId. + * @hide + */ + public static int getUid(int userId, int appId) { + return userId * PER_USER_RANGE + (appId % PER_USER_RANGE); + } + + /** + * Returns the app id (or base uid) for a given uid, stripping out the user id from it. + * @hide + */ + public static int getAppId(int uid) { + return uid % PER_USER_RANGE; + } } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 54a8842..564f4f4 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -24,6 +24,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; +import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.PatternMatcher; diff --git a/core/java/android/content/pm/UserInfo.aidl b/core/java/android/content/pm/UserInfo.aidl new file mode 100644 index 0000000..2e7cb8f --- /dev/null +++ b/core/java/android/content/pm/UserInfo.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2011, 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.content.pm; + +parcelable UserInfo; diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java index 3704d3a..ba5331c 100644 --- a/core/java/android/content/pm/UserInfo.java +++ b/core/java/android/content/pm/UserInfo.java @@ -74,8 +74,7 @@ public class UserInfo implements Parcelable { @Override public String toString() { - return "UserInfo{" - + id + ":" + name + ":" + Integer.toHexString(flags) + "}"; + return "UserInfo{" + id + ":" + name + ":" + Integer.toHexString(flags) + "}"; } public int describeContents() { |