Extend LauncherApps service to expose enabled state.

Provide methods for checking if a package or activity
is enabled for a given profile.

Change-Id: If9cb15dc9398a709e60e7b689b664c24c49fcc16
This commit is contained in:
Kenny Guy
2014-04-29 14:24:18 +01:00
parent b039603867
commit 53fa4ec7f4
4 changed files with 69 additions and 0 deletions

View File

@@ -35,4 +35,6 @@ interface ILauncherApps {
ResolveInfo resolveActivity(in Intent intent, in UserHandle user);
void startActivityAsUser(in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
boolean isPackageEnabled(String packageName, in UserHandle user);
boolean isActivityEnabled(in ComponentName component, in UserHandle user);
}

View File

@@ -186,6 +186,39 @@ public class LauncherApps {
}
}
/**
* Checks if the package is installed and enabled for a profile.
*
* @param packageName The package to check.
* @param user The UserHandle of the profile.
*
* @return true if the package exists and is enabled.
*/
public boolean isPackageEnabledForProfile(String packageName, UserHandle user) {
try {
return mService.isPackageEnabled(packageName, user);
} catch (RemoteException re) {
return false;
}
}
/**
* Checks if the activity exists and it enabled for a profile.
*
* @param component The activity to check.
* @param user The UserHandle of the profile.
*
* @return true if the activity exists and is enabled.
*/
public boolean isActivityEnabledForProfile(ComponentName component, UserHandle user) {
try {
return mService.isActivityEnabled(component, user);
} catch (RemoteException re) {
return false;
}
}
/**
* Adds a listener for changes to packages in current and managed profiles.
*