summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-02-23 14:44:08 -0800
committerClark Scheff <clark@cyngn.com>2016-03-04 14:01:06 -0800
commit1bd60bda797443e029846ef340b2083638b5e554 (patch)
treeb852a5e9ac5584640ab338cd827f629445e0f414 /services/java
parent8ff13dea571cefa0197d71b37d69adbe2908ad55 (diff)
downloadframeworks_base-1bd60bda797443e029846ef340b2083638b5e554.zip
frameworks_base-1bd60bda797443e029846ef340b2083638b5e554.tar.gz
frameworks_base-1bd60bda797443e029846ef340b2083638b5e554.tar.bz2
Themes: Refactor themes to CMSDK [1/6]
Change-Id: I3688b37342eddcfceeabaae982085884e9bc63ee TICKET: CYNGNOS-2126
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/AppsFailureReceiver.java118
-rw-r--r--services/java/com/android/server/SystemServer.java38
2 files changed, 0 insertions, 156 deletions
diff --git a/services/java/com/android/server/AppsFailureReceiver.java b/services/java/com/android/server/AppsFailureReceiver.java
deleted file mode 100644
index e99b7a4..0000000
--- a/services/java/com/android/server/AppsFailureReceiver.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2010, T-Mobile USA, Inc.
- * Copyright (C) 2015 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.server;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.content.BroadcastReceiver;
-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 com.android.internal.R;
-
-public class AppsFailureReceiver extends BroadcastReceiver {
-
- private static final int FAILURES_THRESHOLD = 3;
- private static final int EXPIRATION_TIME_IN_MILLISECONDS = 30000; // 30 seconds
-
- private static final int THEME_RESET_NOTIFICATION_ID = 0x4641494C;
-
- private int mFailuresCount = 0;
- private long mStartTime = 0;
-
- // This function implements the following logic.
- // If after a theme was applied the number of application launch failures
- // at any moment was equal to FAILURES_THRESHOLD
- // in less than EXPIRATION_TIME_IN_MILLISECONDS
- // the default theme is applied unconditionally.
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action.equals(Intent.ACTION_APP_FAILURE)) {
- long currentTime = SystemClock.uptimeMillis();
- String pkgName = intent.getStringExtra("package");
- if (currentTime - mStartTime > EXPIRATION_TIME_IN_MILLISECONDS) {
- // reset both the count and the timer
- mStartTime = currentTime;
- mFailuresCount = 0;
- }
- if (mFailuresCount <= FAILURES_THRESHOLD) {
- mFailuresCount++;
- if (mFailuresCount == FAILURES_THRESHOLD) {
- // let the theme manager take care of getting us back on the default theme
- ThemeManager tm =
- (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
- final String themePkgName = ThemeConfig.SYSTEM_DEFAULT;
- ThemeChangeRequest.Builder builder = new ThemeChangeRequest.Builder();
- builder.setOverlay(themePkgName)
- .setStatusBar(themePkgName)
- .setNavBar(themePkgName)
- .setIcons(themePkgName)
- .setFont(themePkgName)
- .setBootanimation(themePkgName)
- .setWallpaper(themePkgName)
- .setLockWallpaper(themePkgName)
- .setAlarm(themePkgName)
- .setNotification(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);
- postThemeResetNotification(context);
- }
- }
- } else if (action.equals(Intent.ACTION_APP_FAILURE_RESET)
- || action.equals(ThemeUtils.ACTION_THEME_CHANGED)) {
- mFailuresCount = 0;
- mStartTime = SystemClock.uptimeMillis();
- } else if (action.equals(Intent.ACTION_PACKAGE_ADDED) ||
- action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
- mFailuresCount = 0;
- mStartTime = SystemClock.uptimeMillis();
- }
- }
-
- /**
- * Posts a notification to let the user know their theme was reset
- * @param context
- */
- private void postThemeResetNotification(Context context) {
- NotificationManager nm =
- (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- String title = context.getString(R.string.theme_reset_notification_title);
- String body = context.getString(R.string.theme_reset_notification_body);
- Notification notice = new Notification.Builder(context)
- .setAutoCancel(true)
- .setOngoing(false)
- .setContentTitle(title)
- .setContentText(body)
- .setStyle(new Notification.BigTextStyle().bigText(body))
- .setSmallIcon(android.R.drawable.stat_notify_error)
- .setWhen(System.currentTimeMillis())
- .setCategory(Notification.CATEGORY_SYSTEM)
- .setPriority(Notification.PRIORITY_MAX)
- .build();
- nm.notify(THEME_RESET_NOTIFICATION_ID, notice);
- }
-}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 3146366..0ea8a51 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -25,15 +25,9 @@ import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
-import android.content.pm.ThemeUtils;
import android.content.res.Configuration;
-import android.content.res.Resources.Theme;
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.content.res.ThemeConfig;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Environment;
@@ -47,7 +41,6 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.storage.IMountService;
-import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Slog;
@@ -570,7 +563,6 @@ public final class SystemServer {
MediaRouterService mediaRouter = null;
GestureService gestureService = null;
EdgeGestureService edgeGestureService = null;
- ThemeService themeService = null;
// Bring up services needed for UI.
if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
@@ -1003,14 +995,6 @@ public final class SystemServer {
mSystemServiceManager.startService(TvInputManagerService.class);
}
- try {
- Slog.i(TAG, "Theme Service");
- themeService = new ThemeService(context);
- ServiceManager.addService(Context.THEME_SERVICE, themeService);
- } catch (Throwable e) {
- reportWtf("starting Theme Service", e);
- }
-
if (!disableNonCoreServices) {
try {
Slog.i(TAG, "Media Router Service");
@@ -1157,16 +1141,6 @@ public final class SystemServer {
}
}
- IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_APP_FAILURE);
- filter.addAction(Intent.ACTION_APP_FAILURE_RESET);
- filter.addAction(Intent.ACTION_PACKAGE_ADDED);
- filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
- filter.addAction(ThemeUtils.ACTION_THEME_CHANGED);
- filter.addCategory(Intent.CATEGORY_THEME_PACKAGE_INSTALLED_STATE_CHANGE);
- filter.addDataScheme("package");
- context.registerReceiver(new AppsFailureReceiver(), filter);
-
// These are needed to propagate to the runnable below.
final NetworkManagementService networkManagementF = networkManagement;
final NetworkStatsService networkStatsF = networkStats;
@@ -1187,7 +1161,6 @@ public final class SystemServer {
final MediaRouterService mediaRouterF = mediaRouter;
final AudioService audioServiceF = audioService;
final MmsServiceBroker mmsServiceF = mmsService;
- final ThemeService themeServiceF = themeService;
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
@@ -1326,17 +1299,6 @@ public final class SystemServer {
} catch (Throwable e) {
reportWtf("Notifying MmsService running", e);
}
-
- try {
- // now that the system is up, apply default theme if applicable
- if (themeServiceF != null) themeServiceF.systemRunning();
- ThemeConfig themeConfig =
- ThemeConfig.getBootTheme(context.getContentResolver());
- String iconPkg = themeConfig.getIconPackPkgName();
- mPackageManagerService.updateIconMapping(iconPkg);
- } catch (Throwable e) {
- reportWtf("Icon Mapping failed", e);
- }
}
});
}