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

Commit 8773bbe8 authored by Vadim Caen's avatar Vadim Caen Committed by Android (Google) Code Review
Browse files

Merge "API to override the splashscreen theme" into sc-dev

parents bc32bd8c 78171642
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -56795,6 +56795,7 @@ package android.window {
  public interface SplashScreen {
    method public void clearOnExitAnimationListener();
    method public void setOnExitAnimationListener(@NonNull android.window.SplashScreen.OnExitAnimationListener);
    method public void setSplashScreenTheme(@StyleRes int);
  }
  public static interface SplashScreen.OnExitAnimationListener {
+4 −0
Original line number Diff line number Diff line
@@ -796,6 +796,10 @@ interface IPackageManager {

    void setMimeGroup(String packageName, String group, in List<String> mimeTypes);

    String getSplashScreenTheme(String packageName, int userId);

    void setSplashScreenTheme(String packageName, String themeName, int userId);

    List<String> getMimeGroup(String packageName, String group);

    boolean isAutoRevokeWhitelisted(String packageName);
+9 −1
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public class PackageUserState {
    public int installReason;
    public @PackageManager.UninstallReason int uninstallReason;
    public String harmfulAppWarning;
    public String splashScreenTheme;

    public ArraySet<String> disabledComponents;
    public ArraySet<String> enabledComponents;
@@ -130,6 +131,7 @@ public class PackageUserState {
        if (o.componentLabelIconOverrideMap != null) {
            this.componentLabelIconOverrideMap = new ArrayMap<>(o.componentLabelIconOverrideMap);
        }
        splashScreenTheme = o.splashScreenTheme;
    }

    @Nullable
@@ -242,6 +244,7 @@ public class PackageUserState {
        return componentLabelIconOverrideMap.get(componentName);
    }


    /**
     * Test if this package is installed.
     */
@@ -482,6 +485,10 @@ public class PackageUserState {
                && !harmfulAppWarning.equals(oldState.harmfulAppWarning))) {
            return false;
        }

        if (!Objects.equals(splashScreenTheme, oldState.splashScreenTheme)) {
            return false;
        }
        return true;
    }

@@ -505,6 +512,7 @@ public class PackageUserState {
        hashCode = 31 * hashCode + Objects.hashCode(disabledComponents);
        hashCode = 31 * hashCode + Objects.hashCode(enabledComponents);
        hashCode = 31 * hashCode + Objects.hashCode(harmfulAppWarning);
        hashCode = 31 * hashCode + Objects.hashCode(splashScreenTheme);
        return hashCode;
    }

+41 −0
Original line number Diff line number Diff line
@@ -17,12 +17,17 @@
package android.window;

import android.annotation.NonNull;
import android.annotation.StyleRes;
import android.annotation.SuppressLint;
import android.annotation.UiThread;
import android.app.Activity;
import android.app.ActivityThread;
import android.app.AppGlobals;
import android.content.Context;
import android.content.res.Resources;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.util.Singleton;
import android.util.Slog;

@@ -60,6 +65,17 @@ public interface SplashScreen {
     */
    void clearOnExitAnimationListener();


    /**
     * Overrides the theme used for the {@link SplashScreen}s of this application.
     * <p>
     * By default, the {@link SplashScreen} uses the theme set in the manifest. This method
     * overrides and persists the theme used for the {@link SplashScreen} of this application.
     * <p>
     * To reset to the default theme, set this the themeId to {@link Resources#ID_NULL}.
     */
    void setSplashScreenTheme(@StyleRes int themeId);

    /**
     * Listens for the splash screen exit event.
     */
@@ -84,6 +100,8 @@ public interface SplashScreen {
     * @hide
     */
    class SplashScreenImpl implements SplashScreen {
        private static final String TAG = "SplashScreenImpl";

        private OnExitAnimationListener mExitAnimationListener;
        private final IBinder mActivityToken;
        private final SplashScreenManagerGlobal mGlobal;
@@ -119,6 +137,29 @@ public interface SplashScreen {
                mGlobal.removeImpl(this);
            }
        }

        public void setSplashScreenTheme(@StyleRes int themeId) {
            if (mActivityToken == null) {
                Log.w(TAG, "Couldn't persist the starting theme. This instance is not an Activity");
                return;
            }

            Activity activity = ActivityThread.currentActivityThread().getActivity(
                    mActivityToken);
            if (activity == null) {
                return;
            }
            String themeName = themeId != Resources.ID_NULL
                    ? activity.getResources().getResourceName(themeId) : null;

            try {
                AppGlobals.getPackageManager().setSplashScreenTheme(
                        activity.getComponentName().getPackageName(),
                        themeName, activity.getUserId());
            } catch (RemoteException e) {
                Log.w(TAG, "Couldn't persist the starting theme", e);
            }
        }
    }

    /**
+19 −1
Original line number Diff line number Diff line
@@ -21627,7 +21627,8 @@ public class PackageManagerService extends IPackageManager.Stub
                    null /*disabledComponents*/,
                    PackageManager.INSTALL_REASON_UNKNOWN,
                    PackageManager.UNINSTALL_REASON_UNKNOWN,
                    null /*harmfulAppWarning*/);
                    null /*harmfulAppWarning*/,
                    null /*splashScreenTheme*/);
        }
        mSettings.writeKernelMappingLPr(ps);
    }
@@ -27701,6 +27702,23 @@ public class PackageManagerService extends IPackageManager.Stub
        return mSettings.getPackageLPr(packageName).getMimeGroup(mimeGroup);
    }
    @Override
    public void setSplashScreenTheme(@NonNull String packageName, @Nullable String themeId,
            int userId) {
        int callingUid = Binder.getCallingUid();
        PackageSetting packageSetting = getPackageSettingForUser(packageName, callingUid, userId);
        if (packageSetting != null) {
            packageSetting.setSplashScreenTheme(userId, themeId);
        }
    }
    @Override
    public String getSplashScreenTheme(@NonNull String packageName, int userId) {
        int callingUid = Binder.getCallingUid();
        PackageSetting packageSetting = getPackageSettingForUser(packageName, callingUid, userId);
        return packageSetting != null ? packageSetting.getSplashScreenTheme(userId) : null;
    }
    /**
     * Temporary method that wraps mSettings.writeLPr() and calls mPermissionManager's
     * writeLegacyPermissionsTEMP() beforehand.
Loading