diff options
author | Sander Alewijnse <salewijnse@google.com> | 2014-06-04 10:11:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-04 10:11:46 +0000 |
commit | 1b8737ee18f5d80adda41eafca6143a046a47a13 (patch) | |
tree | c57d0413c941cc1b96cf4ce0273f4b237e15b338 | |
parent | 8554f62fbccf2b7339d146302836584f1e2b8d72 (diff) | |
parent | 866896df168d1382732c97e49617ab2f2995d376 (diff) | |
download | frameworks_base-1b8737ee18f5d80adda41eafca6143a046a47a13.zip frameworks_base-1b8737ee18f5d80adda41eafca6143a046a47a13.tar.gz frameworks_base-1b8737ee18f5d80adda41eafca6143a046a47a13.tar.bz2 |
Merge "Remove enableSystemApp() and enableSystemAppWithInten()."
4 files changed, 0 insertions, 149 deletions
diff --git a/api/current.txt b/api/current.txt index 8febb71..8a5f1df 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5174,8 +5174,6 @@ package android.app.admin { method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String); method public void clearUserRestriction(android.content.ComponentName, java.lang.String); method public android.os.UserHandle createUser(android.content.ComponentName, java.lang.String); - method public void enableSystemApp(android.content.ComponentName, java.lang.String); - method public int enableSystemApp(android.content.ComponentName, android.content.Intent); method public java.lang.String[] getAccountTypesWithManagementDisabled(); method public java.util.List<android.content.ComponentName> getActiveAdmins(); method public android.os.Bundle getApplicationRestrictions(android.content.ComponentName, java.lang.String); diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index afe2981..24a354f 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -2170,45 +2170,6 @@ public class DevicePolicyManager { } /** - * Called by profile or device owner to re-enable a system app that was disabled by default - * when the managed profile was created. This should only be called from a profile or device - * owner running within a managed profile. - * - * @param admin Which {@link DeviceAdminReceiver} this request is associated with. - * @param packageName The package to be re-enabled in the current profile. - */ - public void enableSystemApp(ComponentName admin, String packageName) { - if (mService != null) { - try { - mService.enableSystemApp(admin, packageName); - } catch (RemoteException e) { - Log.w(TAG, "Failed to install package: " + packageName); - } - } - } - - /** - * Called by profile or device owner to re-enable system apps by intent that were disabled - * by default when the managed profile was created. This should only be called from a profile - * or device owner running within a managed profile. - * - * @param admin Which {@link DeviceAdminReceiver} this request is associated with. - * @param intent An intent matching the app(s) to be installed. All apps that resolve for this - * intent will be re-enabled in the current profile. - * @return int The number of activities that matched the intent and were installed. - */ - public int enableSystemApp(ComponentName admin, Intent intent) { - if (mService != null) { - try { - return mService.enableSystemAppWithIntent(admin, intent); - } catch (RemoteException e) { - Log.w(TAG, "Failed to install packages matching filter: " + intent); - } - } - return 0; - } - - /** * Called by a profile owner to disable account management for a specific type of account. * * <p>The calling device admin must be a profile owner. If it is not, a diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 7f754dc..7d7a312 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -135,9 +135,6 @@ interface IDevicePolicyManager { UserHandle createUser(in ComponentName who, in String name); boolean removeUser(in ComponentName who, in UserHandle userHandle); - void enableSystemApp(in ComponentName admin, in String packageName); - int enableSystemAppWithIntent(in ComponentName admin, in Intent intent); - void setAccountManagementDisabled(in ComponentName who, in String accountType, in boolean disabled); String[] getAccountTypesWithManagementDisabled(); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index a52396e..043fab4 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -3555,111 +3555,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } @Override - public void enableSystemApp(ComponentName who, String packageName) { - synchronized (this) { - if (who == null) { - throw new NullPointerException("ComponentName is null"); - } - getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); - - int userId = UserHandle.getCallingUserId(); - long id = Binder.clearCallingIdentity(); - - try { - UserManager um = UserManager.get(mContext); - if (!um.getUserInfo(userId).isManagedProfile()) { - throw new IllegalStateException( - "Only call this method from a managed profile."); - } - - // TODO: Use UserManager::getProfileParent when available. - UserInfo primaryUser = um.getUserInfo(UserHandle.USER_OWNER); - - if (DBG) { - Slog.v(LOG_TAG, "installing " + packageName + " for " - + userId); - } - - IPackageManager pm = AppGlobals.getPackageManager(); - if (!isSystemApp(pm, packageName, primaryUser.id)) { - throw new IllegalArgumentException("Only system apps can be enabled this way."); - } - - // Install the app. - pm.installExistingPackageAsUser(packageName, userId); - - } catch (RemoteException re) { - // shouldn't happen - Slog.wtf(LOG_TAG, "Failed to install " + packageName, re); - } finally { - restoreCallingIdentity(id); - } - } - } - - @Override - public int enableSystemAppWithIntent(ComponentName who, Intent intent) { - synchronized (this) { - if (who == null) { - throw new NullPointerException("ComponentName is null"); - } - - getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); - - int userId = UserHandle.getCallingUserId(); - long id = Binder.clearCallingIdentity(); - - try { - UserManager um = UserManager.get(mContext); - if (!um.getUserInfo(userId).isManagedProfile()) { - throw new IllegalStateException( - "Only call this method from a managed profile."); - } - - // TODO: Use UserManager::getProfileParent when available. - UserInfo primaryUser = um.getUserInfo(UserHandle.USER_OWNER); - - IPackageManager pm = AppGlobals.getPackageManager(); - List<ResolveInfo> activitiesToEnable = pm.queryIntentActivities(intent, - intent.resolveTypeIfNeeded(mContext.getContentResolver()), - 0, // no flags - primaryUser.id); - - if (DBG) Slog.d(LOG_TAG, "Enabling system activities: " + activitiesToEnable); - int numberOfAppsInstalled = 0; - if (activitiesToEnable != null) { - for (ResolveInfo info : activitiesToEnable) { - if (info.activityInfo != null) { - - if (!isSystemApp(pm, info.activityInfo.packageName, primaryUser.id)) { - throw new IllegalArgumentException( - "Only system apps can be enabled this way."); - } - - - numberOfAppsInstalled++; - pm.installExistingPackageAsUser(info.activityInfo.packageName, userId); - } - } - } - return numberOfAppsInstalled; - } catch (RemoteException e) { - // shouldn't happen - Slog.wtf(LOG_TAG, "Failed to resolve intent for: " + intent); - return 0; - } finally { - restoreCallingIdentity(id); - } - } - } - - private boolean isSystemApp(IPackageManager pm, String packageName, int userId) - throws RemoteException { - ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0, userId); - return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0; - } - - @Override public void setAccountManagementDisabled(ComponentName who, String accountType, boolean disabled) { if (!mHasFeature) { |