Loading core/java/android/app/ApplicationPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2630,4 +2630,13 @@ public class ApplicationPackageManager extends PackageManager { throw e.rethrowAsRuntimeException(); } } @Override public String getInstantAppAndroidId(String packageName, UserHandle user) { try { return mPM.getInstantAppAndroidId(packageName, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } } core/java/android/content/pm/IPackageManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -634,4 +634,6 @@ interface IPackageManager { ComponentName getInstantAppResolverSettingsComponent(); ComponentName getInstantAppInstallerComponent(); String getInstantAppAndroidId(String packageName, int userId); } core/java/android/content/pm/PackageManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -6305,4 +6305,12 @@ public abstract class PackageManager { */ @SystemApi public abstract ComponentName getInstantAppInstallerComponent(); /** * Return the Android Id for a given Instant App. * * @see {@link android.provider.Settings.Secure#ANDROID_ID} * @hide */ public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user); } core/java/android/provider/Settings.java +4 −0 Original line number Diff line number Diff line Loading @@ -5082,6 +5082,10 @@ public final class Settings { * (available on certain devices running Android 4.2 or higher), each user appears as a * completely separate device, so the {@code ANDROID_ID} value is unique to each * user.</p> * * <p class="note"><strong>Note:</strong> If the caller is an Instant App the id is scoped * to the Instant App, it is generated when the Instant App is first installed and reset if * the user clears the Instant App. */ public static final String ANDROID_ID = "android_id"; Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +27 −0 Original line number Diff line number Diff line Loading @@ -1109,6 +1109,33 @@ public class SettingsProvider extends ContentProvider { // Retrieve the ssaid from the table if present. final Setting ssaid = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SSAID, owningUserId, name); // If the app is an Instant App use its stored SSAID instead of our own. final String instantSsaid; final long token = Binder.clearCallingIdentity(); try { instantSsaid = mPackageManager.getInstantAppAndroidId(callingPkg.packageName, owningUserId); } catch (RemoteException e) { Slog.e(LOG_TAG, "Failed to get Instant App Android ID", e); return null; } finally { Binder.restoreCallingIdentity(token); } if (instantSsaid != null) { // Use the stored value if it is still valid. if (ssaid != null && instantSsaid.equals(ssaid.getValue())) { return ssaid; } // The value has changed, update the stored value. final SettingsState ssaidSettings = mSettingsRegistry.getSettingsLocked( SETTINGS_TYPE_SSAID, owningUserId); final boolean success = ssaidSettings.insertSettingLocked(name, instantSsaid, null, true, callingPkg.packageName); if (!success) { throw new IllegalStateException("Failed to update instant app android id"); } return mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SSAID, owningUserId, name); } // Lazy initialize ssaid if not yet present in ssaid table. if (ssaid == null || ssaid.isNull() || ssaid.getValue() == null) { Loading Loading
core/java/android/app/ApplicationPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -2630,4 +2630,13 @@ public class ApplicationPackageManager extends PackageManager { throw e.rethrowAsRuntimeException(); } } @Override public String getInstantAppAndroidId(String packageName, UserHandle user) { try { return mPM.getInstantAppAndroidId(packageName, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } }
core/java/android/content/pm/IPackageManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -634,4 +634,6 @@ interface IPackageManager { ComponentName getInstantAppResolverSettingsComponent(); ComponentName getInstantAppInstallerComponent(); String getInstantAppAndroidId(String packageName, int userId); }
core/java/android/content/pm/PackageManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -6305,4 +6305,12 @@ public abstract class PackageManager { */ @SystemApi public abstract ComponentName getInstantAppInstallerComponent(); /** * Return the Android Id for a given Instant App. * * @see {@link android.provider.Settings.Secure#ANDROID_ID} * @hide */ public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user); }
core/java/android/provider/Settings.java +4 −0 Original line number Diff line number Diff line Loading @@ -5082,6 +5082,10 @@ public final class Settings { * (available on certain devices running Android 4.2 or higher), each user appears as a * completely separate device, so the {@code ANDROID_ID} value is unique to each * user.</p> * * <p class="note"><strong>Note:</strong> If the caller is an Instant App the id is scoped * to the Instant App, it is generated when the Instant App is first installed and reset if * the user clears the Instant App. */ public static final String ANDROID_ID = "android_id"; Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +27 −0 Original line number Diff line number Diff line Loading @@ -1109,6 +1109,33 @@ public class SettingsProvider extends ContentProvider { // Retrieve the ssaid from the table if present. final Setting ssaid = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SSAID, owningUserId, name); // If the app is an Instant App use its stored SSAID instead of our own. final String instantSsaid; final long token = Binder.clearCallingIdentity(); try { instantSsaid = mPackageManager.getInstantAppAndroidId(callingPkg.packageName, owningUserId); } catch (RemoteException e) { Slog.e(LOG_TAG, "Failed to get Instant App Android ID", e); return null; } finally { Binder.restoreCallingIdentity(token); } if (instantSsaid != null) { // Use the stored value if it is still valid. if (ssaid != null && instantSsaid.equals(ssaid.getValue())) { return ssaid; } // The value has changed, update the stored value. final SettingsState ssaidSettings = mSettingsRegistry.getSettingsLocked( SETTINGS_TYPE_SSAID, owningUserId); final boolean success = ssaidSettings.insertSettingLocked(name, instantSsaid, null, true, callingPkg.packageName); if (!success) { throw new IllegalStateException("Failed to update instant app android id"); } return mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SSAID, owningUserId, name); } // Lazy initialize ssaid if not yet present in ssaid table. if (ssaid == null || ssaid.isNull() || ssaid.getValue() == null) { Loading