Loading core/java/android/app/role/IRoleManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,6 @@ interface IRoleManager { boolean removeRoleHolderFromController(in String roleName, in String packageName); List<String> getHeldRolesFromController(in String packageName); String getDefaultSmsPackage(int userId); } core/java/android/app/role/RoleManager.java +17 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app.role; import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; Loading Loading @@ -592,7 +593,6 @@ public final class RoleManager { } } /** * Returns the list of all roles that the given package is currently holding * Loading @@ -613,6 +613,22 @@ public final class RoleManager { } } /** * Allows getting the role holder for {@link #ROLE_SMS} without * {@link Manifest.permission#OBSERVE_ROLE_HOLDERS}, as required by * {@link android.provider.Telephony.Sms#getDefaultSmsPackage(Context)} * * @hide */ @Nullable public String getDefaultSmsPackage(@UserIdInt int userId) { try { return mService.getDefaultSmsPackage(userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private static class RoleManagerCallbackDelegate extends IRoleManagerCallback.Stub { @NonNull Loading core/java/android/content/pm/PackageUserState.java +19 −4 Original line number Diff line number Diff line Loading @@ -29,8 +29,11 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import android.annotation.UnsupportedAppUsage; import android.os.BaseBundle; import android.os.Debug; import android.os.PersistableBundle; import android.util.ArraySet; import android.util.DebugUtils; import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; Loading @@ -43,6 +46,9 @@ import java.util.Objects; * @hide */ public class PackageUserState { private static final boolean DEBUG = false; private static final String LOG_TAG = "PackageUserState"; public long ceDataInode; public boolean installed; public boolean stopped; Loading Loading @@ -132,12 +138,12 @@ public class PackageUserState { final boolean isSystemApp = componentInfo.applicationInfo.isSystemApp(); final boolean matchUninstalled = (flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0; if (!isAvailable(flags) && !(isSystemApp && matchUninstalled)) return false; if (!isEnabled(componentInfo, flags)) return false; && !(isSystemApp && matchUninstalled)) return reportIfDebug(false, flags); if (!isEnabled(componentInfo, flags)) return reportIfDebug(false, flags); if ((flags & MATCH_SYSTEM_ONLY) != 0) { if (!isSystemApp) { return false; return reportIfDebug(false, flags); } } Loading @@ -145,7 +151,16 @@ public class PackageUserState { && !componentInfo.directBootAware; final boolean matchesAware = ((flags & MATCH_DIRECT_BOOT_AWARE) != 0) && componentInfo.directBootAware; return matchesUnaware || matchesAware; return reportIfDebug(matchesUnaware || matchesAware, flags); } private boolean reportIfDebug(boolean result, int flags) { if (DEBUG && !result) { Slog.i(LOG_TAG, "No match!; flags: " + DebugUtils.flagsToString(PackageManager.class, "MATCH_", flags) + " " + Debug.getCaller()); } return result; } /** Loading core/java/android/util/DebugUtils.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.util; import android.annotation.UnsupportedAppUsage; import android.os.Build; import java.io.PrintWriter; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -250,7 +251,7 @@ public class DebugUtils { if (value == 0 && flagsWasZero) { return constNameWithoutPrefix(prefix, field); } if ((flags & value) != 0) { if ((flags & value) == value) { flags &= ~value; res.append(constNameWithoutPrefix(prefix, field)).append('|'); } Loading core/java/com/android/internal/util/CollectionUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -330,4 +330,18 @@ public class CollectionUtils { public static @NonNull <T> List<T> defeatNullable(@Nullable List<T> val) { return (val != null) ? val : Collections.emptyList(); } /** * @return the first element if not empty/null, null otherwise */ public static @Nullable <T> T firstOrNull(@Nullable List<T> cur) { return isEmpty(cur) ? null : cur.get(0); } /** * @return list of single given element if it's not null, empty list otherwise */ public static @NonNull <T> List<T> singletonOrEmpty(@Nullable T item) { return item == null ? Collections.emptyList() : Collections.singletonList(item); } } Loading
core/java/android/app/role/IRoleManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,6 @@ interface IRoleManager { boolean removeRoleHolderFromController(in String roleName, in String packageName); List<String> getHeldRolesFromController(in String packageName); String getDefaultSmsPackage(int userId); }
core/java/android/app/role/RoleManager.java +17 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.app.role; import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.SystemService; Loading Loading @@ -592,7 +593,6 @@ public final class RoleManager { } } /** * Returns the list of all roles that the given package is currently holding * Loading @@ -613,6 +613,22 @@ public final class RoleManager { } } /** * Allows getting the role holder for {@link #ROLE_SMS} without * {@link Manifest.permission#OBSERVE_ROLE_HOLDERS}, as required by * {@link android.provider.Telephony.Sms#getDefaultSmsPackage(Context)} * * @hide */ @Nullable public String getDefaultSmsPackage(@UserIdInt int userId) { try { return mService.getDefaultSmsPackage(userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private static class RoleManagerCallbackDelegate extends IRoleManagerCallback.Stub { @NonNull Loading
core/java/android/content/pm/PackageUserState.java +19 −4 Original line number Diff line number Diff line Loading @@ -29,8 +29,11 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import android.annotation.UnsupportedAppUsage; import android.os.BaseBundle; import android.os.Debug; import android.os.PersistableBundle; import android.util.ArraySet; import android.util.DebugUtils; import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; Loading @@ -43,6 +46,9 @@ import java.util.Objects; * @hide */ public class PackageUserState { private static final boolean DEBUG = false; private static final String LOG_TAG = "PackageUserState"; public long ceDataInode; public boolean installed; public boolean stopped; Loading Loading @@ -132,12 +138,12 @@ public class PackageUserState { final boolean isSystemApp = componentInfo.applicationInfo.isSystemApp(); final boolean matchUninstalled = (flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0; if (!isAvailable(flags) && !(isSystemApp && matchUninstalled)) return false; if (!isEnabled(componentInfo, flags)) return false; && !(isSystemApp && matchUninstalled)) return reportIfDebug(false, flags); if (!isEnabled(componentInfo, flags)) return reportIfDebug(false, flags); if ((flags & MATCH_SYSTEM_ONLY) != 0) { if (!isSystemApp) { return false; return reportIfDebug(false, flags); } } Loading @@ -145,7 +151,16 @@ public class PackageUserState { && !componentInfo.directBootAware; final boolean matchesAware = ((flags & MATCH_DIRECT_BOOT_AWARE) != 0) && componentInfo.directBootAware; return matchesUnaware || matchesAware; return reportIfDebug(matchesUnaware || matchesAware, flags); } private boolean reportIfDebug(boolean result, int flags) { if (DEBUG && !result) { Slog.i(LOG_TAG, "No match!; flags: " + DebugUtils.flagsToString(PackageManager.class, "MATCH_", flags) + " " + Debug.getCaller()); } return result; } /** Loading
core/java/android/util/DebugUtils.java +2 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.util; import android.annotation.UnsupportedAppUsage; import android.os.Build; import java.io.PrintWriter; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -250,7 +251,7 @@ public class DebugUtils { if (value == 0 && flagsWasZero) { return constNameWithoutPrefix(prefix, field); } if ((flags & value) != 0) { if ((flags & value) == value) { flags &= ~value; res.append(constNameWithoutPrefix(prefix, field)).append('|'); } Loading
core/java/com/android/internal/util/CollectionUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -330,4 +330,18 @@ public class CollectionUtils { public static @NonNull <T> List<T> defeatNullable(@Nullable List<T> val) { return (val != null) ? val : Collections.emptyList(); } /** * @return the first element if not empty/null, null otherwise */ public static @Nullable <T> T firstOrNull(@Nullable List<T> cur) { return isEmpty(cur) ? null : cur.get(0); } /** * @return list of single given element if it's not null, empty list otherwise */ public static @NonNull <T> List<T> singletonOrEmpty(@Nullable T item) { return item == null ? Collections.emptyList() : Collections.singletonList(item); } }