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

Commit 6fdb5e6d authored by Jeff Brown's avatar Jeff Brown
Browse files

resolved conflicts for merge of 7289f3ab to klp-modular-dev-plus-aosp

Change-Id: I5bdc8862828b56557410a95e7f9b14def81a0ded
parents 280fe930 7289f3ab
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
/*
 * 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();
}
+0 −59
Original line number Diff line number Diff line
@@ -1199,20 +1199,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            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);
@@ -1283,17 +1269,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            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();
@@ -3586,26 +3561,6 @@ class ActivityManagerProxy implements IActivityManager
        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();
@@ -3693,20 +3648,6 @@ class ActivityManagerProxy implements IActivityManager
        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 */
+0 −7
Original line number Diff line number Diff line
@@ -228,8 +228,6 @@ public interface IActivityManager extends IInterface {
    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;
@@ -249,8 +247,6 @@ public interface IActivityManager extends IInterface {
    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,
@@ -525,7 +521,6 @@ public interface IActivityManager extends IInterface {

    // 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;
@@ -561,8 +556,6 @@ public interface IActivityManager extends IInterface {
    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;
+21 −42
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.internal.util.XmlUtils.writeLongAttribute;
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;
@@ -33,6 +32,7 @@ import android.app.IActivityContainerCallback;
import android.appwidget.AppWidgetManager;
import android.graphics.Rect;
import android.util.ArrayMap;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IAppOpsService;
@@ -50,6 +50,7 @@ import com.android.internal.util.Preconditions;
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;
@@ -71,6 +72,7 @@ import android.app.Activity;
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;
@@ -797,9 +799,8 @@ public final class ActivityManagerService extends ActivityManagerNative
    /**
     * 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;
@@ -2006,7 +2007,8 @@ public final class ActivityManagerService extends ActivityManagerNative
        mBatteryStatsService.publish(mContext);
        mUsageStatsService.publish(mContext);
        mAppOpsService.publish(mContext);
        startRunning(null, null, null, null);
        LocalServices.addService(ActivityManagerInternal.class, new LocalService());
    }
    @Override
@@ -8185,13 +8187,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        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();
@@ -8266,13 +8262,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    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();
@@ -8994,25 +8984,6 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    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(
@@ -9225,9 +9196,6 @@ public final class ActivityManagerService extends ActivityManagerNative
            mAppOpsService.systemReady();
            mSystemReady = true;
            if (!mStartRunning) {
                return;
            }
        }
        ArrayList<ProcessRecord> procsToKill = null;
@@ -10907,8 +10875,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
            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
@@ -16562,4 +16529,16 @@ public final class ActivityManagerService extends ActivityManagerNative
        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();
        }
    }
}
+7 −11
Original line number Diff line number Diff line
@@ -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;
@@ -81,6 +84,7 @@ final class Notifier {
    private final SuspendBlocker mSuspendBlocker;
    private final ScreenOnBlocker mScreenOnBlocker;
    private final WindowManagerPolicy mPolicy;
    private final ActivityManagerInternal mActivityManagerInternal;

    private final NotifierHandler mHandler;
    private final Intent mScreenOnIntent;
@@ -115,6 +119,7 @@ final class Notifier {
        mSuspendBlocker = suspendBlocker;
        mScreenOnBlocker = screenOnBlocker;
        mPolicy = policy;
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);

        mHandler = new NotifierHandler(looper);
        mScreenOnIntent = new Intent(Intent.ACTION_SCREEN_ON);
@@ -379,12 +384,7 @@ final class Notifier {
        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,
@@ -435,11 +435,7 @@ final class Notifier {
        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,