Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 904e6cad authored by Chad Brubaker's avatar Chad Brubaker Committed by Android (Google) Code Review
Browse files

Merge "Change ANDROID_ID for Instant Apps" into oc-dev

parents 7844a343 0d277a7b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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();
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -634,4 +634,6 @@ interface IPackageManager {
    ComponentName getInstantAppResolverSettingsComponent();

    ComponentName getInstantAppInstallerComponent();

    String getInstantAppAndroidId(String packageName, int userId);
}
+8 −0
Original line number Diff line number Diff line
@@ -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);
}
+4 −0
Original line number Diff line number Diff line
@@ -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";

+27 −0
Original line number Diff line number Diff line
@@ -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