resolved conflicts for merge of 7289f3ab to klp-modular-dev-plus-aosp
Change-Id: I788ca17503e2fd225e205a76d3e7062f71d58316
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
new file mode 100644
index 0000000..5262a5f
--- /dev/null
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -0,0 +1,28 @@
+/*
+ * 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.app;
+
+/**
+ * Activity manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class ActivityManagerInternal {
+ // Called by the power manager.
+ public abstract void goingToSleep();
+ public abstract void wakingUp();
+}
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index a37a35a..9f1b56e 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1208,20 +1208,6 @@
return true;
}
- case GOING_TO_SLEEP_TRANSACTION: {
- data.enforceInterface(IActivityManager.descriptor);
- goingToSleep();
- reply.writeNoException();
- return true;
- }
-
- case WAKING_UP_TRANSACTION: {
- data.enforceInterface(IActivityManager.descriptor);
- wakingUp();
- reply.writeNoException();
- return true;
- }
-
case SET_LOCK_SCREEN_SHOWN_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
setLockScreenShown(data.readInt() != 0);
@@ -1294,17 +1280,6 @@
return true;
}
- case START_RUNNING_TRANSACTION: {
- data.enforceInterface(IActivityManager.descriptor);
- String pkg = data.readString();
- String cls = data.readString();
- String action = data.readString();
- String indata = data.readString();
- startRunning(pkg, cls, action, indata);
- reply.writeNoException();
- return true;
- }
-
case HANDLE_APPLICATION_CRASH_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder app = data.readStrongBinder();
@@ -3672,26 +3647,6 @@
reply.recycle();
return pfd;
}
- public void goingToSleep() throws RemoteException
- {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(IActivityManager.descriptor);
- mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
- reply.readException();
- data.recycle();
- reply.recycle();
- }
- public void wakingUp() throws RemoteException
- {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(IActivityManager.descriptor);
- mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
- reply.readException();
- data.recycle();
- reply.recycle();
- }
public void setLockScreenShown(boolean shown) throws RemoteException
{
Parcel data = Parcel.obtain();
@@ -3782,20 +3737,6 @@
reply.recycle();
return res;
}
- public void startRunning(String pkg, String cls, String action,
- String indata) throws RemoteException {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(IActivityManager.descriptor);
- data.writeString(pkg);
- data.writeString(cls);
- data.writeString(action);
- data.writeString(indata);
- mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
- reply.readException();
- data.recycle();
- reply.recycle();
- }
public boolean testIsSystemReady()
{
/* this base class version is never called */
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index f7416d6..bfbd339 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -229,8 +229,6 @@
public void forceStopPackage(final String packageName, int userId) throws RemoteException;
// Note: probably don't want to allow applications access to these.
- public void goingToSleep() throws RemoteException;
- public void wakingUp() throws RemoteException;
public void setLockScreenShown(boolean shown) throws RemoteException;
public void unhandledBack() throws RemoteException;
@@ -251,8 +249,6 @@
public boolean killProcessesBelowForeground(String reason) throws RemoteException;
// Special low-level communication with activity manager.
- public void startRunning(String pkg, String cls, String action,
- String data) throws RemoteException;
public void handleApplicationCrash(IBinder app,
ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException;
public boolean handleApplicationWtf(IBinder app, String tag,
@@ -546,7 +542,6 @@
// Please keep these transaction codes the same -- they are also
// sent by C++ code.
- int START_RUNNING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
int HANDLE_APPLICATION_CRASH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+1;
int START_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+2;
int UNHANDLED_BACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+3;
@@ -582,8 +577,6 @@
int UNBIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
int PUBLISH_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
int ACTIVITY_RESUMED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+38;
- int GOING_TO_SLEEP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+39;
- int WAKING_UP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+40;
int SET_DEBUG_APP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+41;
int SET_ALWAYS_FINISH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+42;
int START_INSTRUMENTATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+43;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e9be1d7d..5bfb3fb 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -24,7 +24,6 @@
import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
-
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
import android.app.AppOpsManager;
@@ -34,6 +33,7 @@
import android.graphics.Rect;
import android.os.BatteryStats;
import android.util.ArrayMap;
+
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IAppOpsService;
@@ -51,6 +51,7 @@
import com.android.server.AppOpsService;
import com.android.server.AttributeCache;
import com.android.server.IntentResolver;
+import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.SystemService;
import com.android.server.Watchdog;
@@ -72,6 +73,7 @@
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.StackInfo;
+import android.app.ActivityManagerInternal;
import android.app.ActivityManagerNative;
import android.app.ActivityOptions;
import android.app.ActivityThread;
@@ -798,9 +800,8 @@
/**
* Used to control how we initialize the service.
*/
- boolean mStartRunning = false;
ComponentName mTopComponent;
- String mTopAction;
+ String mTopAction = Intent.ACTION_MAIN;
String mTopData;
boolean mProcessesReady = false;
boolean mSystemReady = false;
@@ -2028,7 +2029,8 @@
mBatteryStatsService.publish(mContext);
mUsageStatsService.publish(mContext);
mAppOpsService.publish(mContext);
- startRunning(null, null, null, null);
+
+ LocalServices.addService(ActivityManagerInternal.class, new LocalService());
}
@Override
@@ -8422,13 +8424,7 @@
return mSleeping || mShuttingDown;
}
- public void goingToSleep() {
- if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("Requires permission "
- + android.Manifest.permission.DEVICE_POWER);
- }
-
+ void goingToSleep() {
synchronized(this) {
mWentToSleep = true;
updateEventDispatchingLocked();
@@ -8503,13 +8499,7 @@
}
}
- public void wakingUp() {
- if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("Requires permission "
- + android.Manifest.permission.DEVICE_POWER);
- }
-
+ void wakingUp() {
synchronized(this) {
mWentToSleep = false;
updateEventDispatchingLocked();
@@ -9232,25 +9222,6 @@
}
}
- public final void startRunning(String pkg, String cls, String action,
- String data) {
- synchronized(this) {
- if (mStartRunning) {
- return;
- }
- mStartRunning = true;
- mTopComponent = pkg != null && cls != null
- ? new ComponentName(pkg, cls) : null;
- mTopAction = action != null ? action : Intent.ACTION_MAIN;
- mTopData = data;
- if (!mSystemReady) {
- return;
- }
- }
-
- systemReady(null);
- }
-
private void retrieveSettings() {
final ContentResolver resolver = mContext.getContentResolver();
String debugApp = Settings.Global.getString(
@@ -9463,9 +9434,6 @@
mAppOpsService.systemReady();
mSystemReady = true;
- if (!mStartRunning) {
- return;
- }
}
ArrayList<ProcessRecord> procsToKill = null;
@@ -11145,8 +11113,7 @@
}
if (dumpAll) {
pw.println(" Total persistent processes: " + numPers);
- pw.println(" mStartRunning=" + mStartRunning
- + " mProcessesReady=" + mProcessesReady
+ pw.println(" mProcessesReady=" + mProcessesReady
+ " mSystemReady=" + mSystemReady);
pw.println(" mBooting=" + mBooting
+ " mBooted=" + mBooted
@@ -16981,4 +16948,16 @@
info.applicationInfo = getAppInfoForUser(info.applicationInfo, userId);
return info;
}
+
+ private final class LocalService extends ActivityManagerInternal {
+ @Override
+ public void goingToSleep() {
+ ActivityManagerService.this.goingToSleep();
+ }
+
+ @Override
+ public void wakingUp() {
+ ActivityManagerService.this.wakingUp();
+ }
+ }
}
diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java
index ac4a128..f72efff 100644
--- a/services/core/java/com/android/server/power/Notifier.java
+++ b/services/core/java/com/android/server/power/Notifier.java
@@ -16,10 +16,13 @@
package com.android.server.power;
+import android.app.ActivityManagerInternal;
import android.app.AppOpsManager;
+
import com.android.internal.app.IAppOpsService;
import com.android.internal.app.IBatteryStats;
import com.android.server.EventLogTags;
+import com.android.server.LocalServices;
import android.app.ActivityManagerNative;
import android.content.BroadcastReceiver;
@@ -82,6 +85,7 @@
private final SuspendBlocker mSuspendBlocker;
private final ScreenOnBlocker mScreenOnBlocker;
private final WindowManagerPolicy mPolicy;
+ private final ActivityManagerInternal mActivityManagerInternal;
private final NotifierHandler mHandler;
private final Intent mScreenOnIntent;
@@ -116,6 +120,7 @@
mSuspendBlocker = suspendBlocker;
mScreenOnBlocker = screenOnBlocker;
mPolicy = policy;
+ mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
mHandler = new NotifierHandler(looper);
mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
@@ -417,12 +422,7 @@
EventLog.writeEvent(EventLogTags.POWER_SCREEN_STATE, 1, 0, 0, 0);
mPolicy.screenTurningOn(mScreenOnListener);
-
- try {
- ActivityManagerNative.getDefault().wakingUp();
- } catch (RemoteException e) {
- // ignore it
- }
+ mActivityManagerInternal.wakingUp();
if (ActivityManagerNative.isSystemReady()) {
mContext.sendOrderedBroadcastAsUser(mScreenOnIntent, UserHandle.ALL, null,
@@ -473,11 +473,7 @@
EventLog.writeEvent(EventLogTags.POWER_SCREEN_STATE, 0, why, 0, 0);
mPolicy.screenTurnedOff(why);
- try {
- ActivityManagerNative.getDefault().goingToSleep();
- } catch (RemoteException e) {
- // ignore it.
- }
+ mActivityManagerInternal.goingToSleep();
if (ActivityManagerNative.isSystemReady()) {
mContext.sendOrderedBroadcastAsUser(mScreenOffIntent, UserHandle.ALL, null,