Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7745,6 +7745,8 @@ package android.content.pm { public class LauncherApps { method public synchronized void addOnAppsChangedListener(android.content.pm.LauncherApps.OnAppsChangedListener); method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle); method public boolean isActivityEnabledForProfile(android.content.ComponentName, android.os.UserHandle); method public boolean isPackageEnabledForProfile(java.lang.String, android.os.UserHandle); method public synchronized void removeOnAppsChangedListener(android.content.pm.LauncherApps.OnAppsChangedListener); method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle); method public void startActivityForProfile(android.content.ComponentName, android.graphics.Rect, android.os.Bundle, android.os.UserHandle); core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); } core/java/android/content/pm/LauncherApps.java +33 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading services/core/java/com/android/server/pm/LauncherAppsService.java +32 −0 Original line number Diff line number Diff line Loading @@ -16,14 +16,18 @@ package com.android.server.pm; import android.app.AppGlobals; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.ILauncherApps; import android.content.pm.IOnAppsChangedListener; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.graphics.Rect; Loading Loading @@ -169,6 +173,34 @@ public class LauncherAppsService extends ILauncherApps.Stub { } } @Override public boolean isPackageEnabled(String packageName, UserHandle user) throws RemoteException { ensureInUserProfiles(user, "Cannot check package for unrelated profile " + user); long ident = Binder.clearCallingIdentity(); try { IPackageManager pm = AppGlobals.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, 0, user.getIdentifier()); return info != null && info.applicationInfo.enabled; } finally { Binder.restoreCallingIdentity(ident); } } @Override public boolean isActivityEnabled(ComponentName component, UserHandle user) throws RemoteException { ensureInUserProfiles(user, "Cannot check component for unrelated profile " + user); long ident = Binder.clearCallingIdentity(); try { IPackageManager pm = AppGlobals.getPackageManager(); ActivityInfo info = pm.getActivityInfo(component, 0, user.getIdentifier()); return info != null && info.isEnabled(); } finally { Binder.restoreCallingIdentity(ident); } } @Override public void startActivityAsUser(ComponentName component, Rect sourceBounds, Bundle opts, UserHandle user) throws RemoteException { Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -7745,6 +7745,8 @@ package android.content.pm { public class LauncherApps { method public synchronized void addOnAppsChangedListener(android.content.pm.LauncherApps.OnAppsChangedListener); method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(java.lang.String, android.os.UserHandle); method public boolean isActivityEnabledForProfile(android.content.ComponentName, android.os.UserHandle); method public boolean isPackageEnabledForProfile(java.lang.String, android.os.UserHandle); method public synchronized void removeOnAppsChangedListener(android.content.pm.LauncherApps.OnAppsChangedListener); method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle); method public void startActivityForProfile(android.content.ComponentName, android.graphics.Rect, android.os.Bundle, android.os.UserHandle);
core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); }
core/java/android/content/pm/LauncherApps.java +33 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +32 −0 Original line number Diff line number Diff line Loading @@ -16,14 +16,18 @@ package com.android.server.pm; import android.app.AppGlobals; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.ILauncherApps; import android.content.pm.IOnAppsChangedListener; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.graphics.Rect; Loading Loading @@ -169,6 +173,34 @@ public class LauncherAppsService extends ILauncherApps.Stub { } } @Override public boolean isPackageEnabled(String packageName, UserHandle user) throws RemoteException { ensureInUserProfiles(user, "Cannot check package for unrelated profile " + user); long ident = Binder.clearCallingIdentity(); try { IPackageManager pm = AppGlobals.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, 0, user.getIdentifier()); return info != null && info.applicationInfo.enabled; } finally { Binder.restoreCallingIdentity(ident); } } @Override public boolean isActivityEnabled(ComponentName component, UserHandle user) throws RemoteException { ensureInUserProfiles(user, "Cannot check component for unrelated profile " + user); long ident = Binder.clearCallingIdentity(); try { IPackageManager pm = AppGlobals.getPackageManager(); ActivityInfo info = pm.getActivityInfo(component, 0, user.getIdentifier()); return info != null && info.isEnabled(); } finally { Binder.restoreCallingIdentity(ident); } } @Override public void startActivityAsUser(ComponentName component, Rect sourceBounds, Bundle opts, UserHandle user) throws RemoteException { Loading