Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.app;
     18 
     19 import android.annotation.NonNull;
     20 import android.content.ComponentName;
     21 import android.content.IIntentSender;
     22 import android.content.Intent;
     23 import android.content.res.Configuration;
     24 import android.os.Bundle;
     25 import android.os.IBinder;
     26 import android.service.voice.IVoiceInteractionSession;
     27 
     28 import com.android.internal.app.IVoiceInteractor;
     29 
     30 import java.util.List;
     31 
     32 /**
     33  * Activity manager local system service interface.
     34  *
     35  * @hide Only for use within the system server.
     36  */
     37 public abstract class ActivityManagerInternal {
     38 
     39     /**
     40      * Type for {@link #notifyAppTransitionStarting}: The transition was started because we had
     41      * the surface saved.
     42      */
     43     public static final int APP_TRANSITION_SAVED_SURFACE = 0;
     44 
     45     /**
     46      * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
     47      * the starting window.
     48      */
     49     public static final int APP_TRANSITION_STARTING_WINDOW = 1;
     50 
     51     /**
     52      * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
     53      * app windows were drawn
     54      */
     55     public static final int APP_TRANSITION_WINDOWS_DRAWN = 2;
     56 
     57     /**
     58      * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
     59      * timeout.
     60      */
     61     public static final int APP_TRANSITION_TIMEOUT = 3;
     62 
     63     // Called by the power manager.
     64     public abstract void onWakefulnessChanged(int wakefulness);
     65 
     66     public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
     67             String processName, String abiOverride, int uid, Runnable crashHandler);
     68 
     69     /**
     70      * Acquires a sleep token with the specified tag.
     71      *
     72      * @param tag A string identifying the purpose of the token (eg. "Dream").
     73      */
     74     public abstract SleepToken acquireSleepToken(@NonNull String tag);
     75 
     76     /**
     77      * Sleep tokens cause the activity manager to put the top activity to sleep.
     78      * They are used by components such as dreams that may hide and block interaction
     79      * with underlying activities.
     80      */
     81     public static abstract class SleepToken {
     82 
     83         /**
     84          * Releases the sleep token.
     85          */
     86         public abstract void release();
     87     }
     88 
     89     /**
     90      * Returns home activity for the specified user.
     91      *
     92      * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
     93      */
     94     public abstract ComponentName getHomeActivityForUser(int userId);
     95 
     96     /**
     97      * Called when a user has been deleted. This can happen during normal device usage
     98      * or just at startup, when partially removed users are purged. Any state persisted by the
     99      * ActivityManager should be purged now.
    100      *
    101      * @param userId The user being cleaned up.
    102      */
    103     public abstract void onUserRemoved(int userId);
    104 
    105     public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
    106             IVoiceInteractionSession mSession,
    107             IVoiceInteractor mInteractor);
    108 
    109     /**
    110      * Callback for window manager to let activity manager know that the starting window has been
    111      * drawn
    112      */
    113     public abstract void notifyStartingWindowDrawn();
    114 
    115     /**
    116      * Callback for window manager to let activity manager know that we are finally starting the
    117      * app transition;
    118      *
    119      * @param reason The reason why the app transition started. Must be one of the APP_TRANSITION_*
    120      *               values.
    121      */
    122     public abstract void notifyAppTransitionStarting(int reason);
    123 
    124     /**
    125      * Callback for window manager to let activity manager know that the app transition was
    126      * cancelled.
    127      */
    128     public abstract void notifyAppTransitionCancelled();
    129 
    130     /**
    131      * Callback for window manager to let activity manager know that the app transition is finished.
    132      */
    133     public abstract void notifyAppTransitionFinished();
    134 
    135     /**
    136      * Returns the top activity from each of the currently visible stacks. The first entry will be
    137      * the focused activity.
    138      */
    139     public abstract List<IBinder> getTopVisibleActivities();
    140 
    141     /**
    142      * Callback for window manager to let activity manager know that docked stack changes its
    143      * minimized state.
    144      */
    145     public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
    146 
    147     /**
    148      * Kill foreground apps from the specified user.
    149      */
    150     public abstract void killForegroundAppsForUser(int userHandle);
    151 
    152     /**
    153      *  Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
    154      *  such as Power Save mode.
    155      */
    156     public abstract void setPendingIntentWhitelistDuration(IIntentSender target, long duration);
    157 
    158     /**
    159      * Updates and persists the {@link Configuration} for a given user.
    160      *
    161      * @param values the configuration to update
    162      * @param userId the user to update the configuration for
    163      */
    164     public abstract void updatePersistentConfigurationForUser(@NonNull Configuration values,
    165             int userId);
    166 
    167     /**
    168      * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
    169      *
    170      * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
    171      */
    172     public abstract int startActivitiesAsPackage(String packageName,
    173             int userId, Intent[] intents, Bundle bOptions);
    174 
    175     /**
    176      * Get the procstate for the UID.  The return value will be between
    177      * {@link ActivityManager#MIN_PROCESS_STATE} and {@link ActivityManager#MAX_PROCESS_STATE}.
    178      * Note if the UID doesn't exist, it'll return {@link ActivityManager#PROCESS_STATE_NONEXISTENT}
    179      * (-1).
    180      */
    181     public abstract int getUidProcessState(int uid);
    182 }
    183