diff options
author | d34d <clark@cyngn.com> | 2015-03-03 10:36:43 -0800 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2015-10-27 10:41:12 -0700 |
commit | 9e2a69886db785729f9c7925e6c06b8ad283d49e (patch) | |
tree | 66867f0cf87ab73878b4b7da1996245d9e45ad86 | |
parent | a17db2b5c7fb407fa40de99f8f89bb8fda1584fd (diff) | |
download | frameworks_base-9e2a69886db785729f9c7925e6c06b8ad283d49e.zip frameworks_base-9e2a69886db785729f9c7925e6c06b8ad283d49e.tar.gz frameworks_base-9e2a69886db785729f9c7925e6c06b8ad283d49e.tar.bz2 |
Themes: Add RequestType to ThemeChangeRequest [1/3]
Change-Id: I2c65ca8eebb3347873cbb133fc29d5ade75b258b
3 files changed, 33 insertions, 8 deletions
diff --git a/core/java/android/content/res/ThemeChangeRequest.java b/core/java/android/content/res/ThemeChangeRequest.java index 2c1f6ff..6c55cd2 100644 --- a/core/java/android/content/res/ThemeChangeRequest.java +++ b/core/java/android/content/res/ThemeChangeRequest.java @@ -29,6 +29,7 @@ import static android.provider.ThemesContract.ThemesColumns.*; public final class ThemeChangeRequest implements Parcelable { private final Map<String, String> mThemeComponents = new HashMap<String, String>(); private final Map<String, String> mPerAppOverlays = new HashMap<String, String>(); + private RequestType mRequestType; public String getOverlayThemePackageName() { return getThemePackageNameForComponent(MODIFIES_OVERLAYS); @@ -90,17 +91,23 @@ public final class ThemeChangeRequest implements Parcelable { return mThemeComponents.size() + mPerAppOverlays.size(); } + public RequestType getReqeustType() { + return mRequestType; + } + private String getThemePackageNameForComponent(String componentName) { return mThemeComponents.get(componentName); } - private ThemeChangeRequest(Map<String, String> components, Map<String, String> perAppThemes) { + private ThemeChangeRequest(Map<String, String> components, Map<String, String> perAppThemes, + RequestType requestType) { if (components != null) { mThemeComponents.putAll(components); } if (perAppThemes != null) { mPerAppOverlays.putAll(perAppThemes); } + mRequestType = requestType; } private ThemeChangeRequest(Parcel source) { @@ -113,6 +120,7 @@ public final class ThemeChangeRequest implements Parcelable { for (int i = 0 ; i < numComponents; i++) { mPerAppOverlays.put(source.readString(), source.readString()); } + mRequestType = RequestType.values()[source.readInt()]; } @Override @@ -132,6 +140,7 @@ public final class ThemeChangeRequest implements Parcelable { dest.writeString(appPkgName); dest.writeString(mPerAppOverlays.get(appPkgName)); } + dest.writeInt(mRequestType.ordinal()); } public static final Parcelable.Creator<ThemeChangeRequest> CREATOR = @@ -147,9 +156,18 @@ public final class ThemeChangeRequest implements Parcelable { } }; + public enum RequestType { + USER_REQUEST, + USER_REQUEST_MIXNMATCH, + THEME_UPDATED, + THEME_REMOVED, + THEME_RESET; + } + public static class Builder { Map<String, String> mThemeComponents = new HashMap<String, String>(); Map<String, String> mPerAppOverlays = new HashMap<String, String>(); + RequestType mRequestType = RequestType.USER_REQUEST; public Builder() {} @@ -218,8 +236,13 @@ public final class ThemeChangeRequest implements Parcelable { return this; } + public Builder setRequestType(RequestType requestType) { + mRequestType = requestType != null ? requestType : RequestType.USER_REQUEST; + return this; + } + public ThemeChangeRequest build() { - return new ThemeChangeRequest(mThemeComponents, mPerAppOverlays); + return new ThemeChangeRequest(mThemeComponents, mPerAppOverlays, mRequestType); } } } diff --git a/services/core/java/com/android/server/ThemeService.java b/services/core/java/com/android/server/ThemeService.java index faf8502..86b5bfd 100644 --- a/services/core/java/com/android/server/ThemeService.java +++ b/services/core/java/com/android/server/ThemeService.java @@ -777,7 +777,11 @@ public class ThemeService extends IThemeService.Stub { } } - builder.setThemeChangeTimestamp(System.currentTimeMillis()); + // When a theme is being updated the new config equal the old config so in this case we + // want to update the timestamp so they are no longer equal. + if (request.getReqeustType() == ThemeChangeRequest.RequestType.THEME_UPDATED) { + builder.setThemeChangeTimestamp(System.currentTimeMillis()); + } return builder; } diff --git a/services/java/com/android/server/AppsFailureReceiver.java b/services/java/com/android/server/AppsFailureReceiver.java index 3265720..e99b7a4 100644 --- a/services/java/com/android/server/AppsFailureReceiver.java +++ b/services/java/com/android/server/AppsFailureReceiver.java @@ -23,13 +23,10 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ThemeUtils; import android.content.res.ThemeChangeRequest; +import android.content.res.ThemeChangeRequest.RequestType; import android.content.res.ThemeConfig; import android.content.res.ThemeManager; import android.os.SystemClock; -import android.provider.ThemesContract; - -import java.util.ArrayList; -import java.util.List; import com.android.internal.R; @@ -77,7 +74,8 @@ public class AppsFailureReceiver extends BroadcastReceiver { .setLockWallpaper(themePkgName) .setAlarm(themePkgName) .setNotification(themePkgName) - .setRingtone(themePkgName); + .setRingtone(themePkgName) + .setRequestType(RequestType.THEME_RESET); // Since we are resetting everything to the system theme, we can have the // theme service remove all per app themes without setting them explicitly :) tm.requestThemeChange(builder.build(), true); |