summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2014-01-16 11:44:20 -0800
committerJeff Brown <jeffbrown@google.com>2014-01-16 11:44:20 -0800
commit09d30981f8e882ffaa336aa4665bfe348557895a (patch)
treef146e7f462d50382bc79e79c4ecb4f8681555bf7 /core/java
parentd3ee63b6c6999475288502ccd37eb8840fb8a1c0 (diff)
parent6f357d3284a833cc50a990e14b39f389b8972254 (diff)
downloadframeworks_base-09d30981f8e882ffaa336aa4665bfe348557895a.zip
frameworks_base-09d30981f8e882ffaa336aa4665bfe348557895a.tar.gz
frameworks_base-09d30981f8e882ffaa336aa4665bfe348557895a.tar.bz2
resolved conflicts for merge of 6f357d32 to master
Change-Id: I1979e6ed1acddbe656f5010114fd900f10865e75
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/FactoryTest.java14
-rw-r--r--core/java/android/os/PowerManagerInternal.java60
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java9
-rw-r--r--core/java/com/android/internal/os/BinderInternal.java1
-rw-r--r--core/java/com/android/server/SystemServiceManager.java19
5 files changed, 97 insertions, 6 deletions
diff --git a/core/java/android/os/FactoryTest.java b/core/java/android/os/FactoryTest.java
index ec99697..7a252f9 100644
--- a/core/java/android/os/FactoryTest.java
+++ b/core/java/android/os/FactoryTest.java
@@ -25,6 +25,20 @@ package android.os;
* {@hide}
*/
public final class FactoryTest {
+ public static final int FACTORY_TEST_OFF = 0;
+ public static final int FACTORY_TEST_LOW_LEVEL = 1;
+ public static final int FACTORY_TEST_HIGH_LEVEL = 2;
+
+ /**
+ * Gets the current factory test mode.
+ *
+ * @return One of: {@link #FACTORY_TEST_OFF}, {@link #FACTORY_TEST_LOW_LEVEL},
+ * or {@link #FACTORY_TEST_HIGH_LEVEL}.
+ */
+ public static int getMode() {
+ return SystemProperties.getInt("ro.factorytest", FACTORY_TEST_OFF);
+ }
+
/**
* When true, long-press on power should immediately cause the device to
* shut down, without prompting the user.
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
new file mode 100644
index 0000000..8144576
--- /dev/null
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 The Android Open Source 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 android.os;
+
+import android.view.WindowManagerPolicy;
+
+/**
+ * Power manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public interface PowerManagerInternal {
+ /**
+ * Used by the window manager to override the screen brightness based on the
+ * current foreground activity.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param brightness The overridden brightness, or -1 to disable the override.
+ */
+ public void setScreenBrightnessOverrideFromWindowManager(int brightness);
+
+ /**
+ * Used by the window manager to override the button brightness based on the
+ * current foreground activity.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param brightness The overridden brightness, or -1 to disable the override.
+ */
+ public void setButtonBrightnessOverrideFromWindowManager(int brightness);
+
+ /**
+ * Used by the window manager to override the user activity timeout based on the
+ * current foreground activity. It can only be used to make the timeout shorter
+ * than usual, not longer.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param timeoutMillis The overridden timeout, or -1 to disable the override.
+ */
+ public void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis);
+
+ // TODO: Remove this and retrieve as a local service instead.
+ public void setPolicy(WindowManagerPolicy policy);
+}
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 7d17839..f692948 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -27,6 +27,7 @@ import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.FileUtils;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.ParcelFormatException;
@@ -114,6 +115,10 @@ public final class BatteryStatsImpl extends BatteryStats {
}
final class MyHandler extends Handler {
+ public MyHandler(Looper looper) {
+ super(looper, null, true);
+ }
+
@Override
public void handleMessage(Message msg) {
BatteryCallback cb = mCallback;
@@ -4688,9 +4693,9 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
- public BatteryStatsImpl(String filename) {
+ public BatteryStatsImpl(String filename, Handler handler) {
mFile = new JournaledFile(new File(filename), new File(filename + ".tmp"));
- mHandler = new MyHandler();
+ mHandler = new MyHandler(handler.getLooper());
mStartCount++;
mScreenOnTimer = new StopwatchTimer(null, -1, null, mUnpluggables);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
diff --git a/core/java/com/android/internal/os/BinderInternal.java b/core/java/com/android/internal/os/BinderInternal.java
index 9841f62..3b0f0f4 100644
--- a/core/java/com/android/internal/os/BinderInternal.java
+++ b/core/java/com/android/internal/os/BinderInternal.java
@@ -19,6 +19,7 @@ package com.android.internal.os;
import android.os.IBinder;
import android.os.SystemClock;
import android.util.EventLog;
+
import java.lang.ref.WeakReference;
/**
diff --git a/core/java/com/android/server/SystemServiceManager.java b/core/java/com/android/server/SystemServiceManager.java
index e2a6063..06ad7f4 100644
--- a/core/java/com/android/server/SystemServiceManager.java
+++ b/core/java/com/android/server/SystemServiceManager.java
@@ -43,11 +43,18 @@ public class SystemServiceManager {
mContext = context;
}
- public void startService(String className) {
+ /**
+ * Starts a service by name if the class exists, otherwise ignores it.
+ *
+ * @return The service instance, or null if not found.
+ */
+ @SuppressWarnings("unchecked")
+ public SystemService startServiceIfExists(String className) {
try {
- startService(Class.forName(className));
+ return startService((Class<SystemService>)Class.forName(className));
} catch (ClassNotFoundException cnfe) {
Slog.i(TAG, className + " not available, ignoring.");
+ return null;
}
}
@@ -56,10 +63,12 @@ public class SystemServiceManager {
* {@link com.android.server.SystemService}.
*
* @param serviceClass A Java class that implements the SystemService interface.
+ * @return The service instance, never null.
* @throws RuntimeException if the service fails to start.
*/
- public void startService(Class<?> serviceClass) {
- final SystemService serviceInstance = createInstance(serviceClass);
+ @SuppressWarnings("unchecked")
+ public <T extends SystemService> T startService(Class<T> serviceClass) {
+ final T serviceInstance = (T)createInstance(serviceClass);
try {
Slog.i(TAG, "Creating " + serviceClass.getSimpleName());
serviceInstance.init(mContext, this);
@@ -75,6 +84,8 @@ public class SystemServiceManager {
} catch (Throwable e) {
throw new RuntimeException("Failed to start service " + serviceClass.getName(), e);
}
+
+ return serviceInstance;
}
/**