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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user