Skip to content

Commit d65afc6

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "More multi-user stuff." into jb-mr1-dev
2 parents 398bad0 + 5dc5a00 commit d65afc6

20 files changed

+664
-193
lines changed

Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ LOCAL_SRC_FILES += \
7979
core/java/android/app/IThumbnailRetriever.aidl \
8080
core/java/android/app/ITransientNotification.aidl \
8181
core/java/android/app/IUiModeManager.aidl \
82+
core/java/android/app/IUserSwitchObserver.aidl \
8283
core/java/android/app/IWallpaperManager.aidl \
8384
core/java/android/app/IWallpaperManagerCallback.aidl \
8485
core/java/android/app/admin/IDevicePolicyManager.aidl \

api/current.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,6 +4169,7 @@ package android.app {
41694169
method public android.graphics.drawable.Drawable getFastDrawable();
41704170
method public static android.app.WallpaperManager getInstance(android.content.Context);
41714171
method public android.app.WallpaperInfo getWallpaperInfo();
4172+
method public boolean hasResourceWallpaper(int);
41724173
method public android.graphics.drawable.Drawable peekDrawable();
41734174
method public android.graphics.drawable.Drawable peekFastDrawable();
41744175
method public void sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle);
@@ -5843,6 +5844,9 @@ package android.content {
58435844
field public static final deprecated java.lang.String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
58445845
field public static final deprecated java.lang.String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
58455846
field public static final java.lang.String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
5847+
field public static final java.lang.String ACTION_USER_BACKGROUND = "android.intent.action.USER_BACKGROUND";
5848+
field public static final java.lang.String ACTION_USER_FOREGROUND = "android.intent.action.USER_FOREGROUND";
5849+
field public static final java.lang.String ACTION_USER_INITIALIZE = "android.intent.action.USER_INITIALIZE";
58465850
field public static final java.lang.String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
58475851
field public static final java.lang.String ACTION_VIEW = "android.intent.action.VIEW";
58485852
field public static final java.lang.String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";

core/java/android/app/ActivityManagerNative.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,22 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
17341734
return true;
17351735
}
17361736

1737+
case REGISTER_USER_SWITCH_OBSERVER_TRANSACTION: {
1738+
data.enforceInterface(IActivityManager.descriptor);
1739+
IUserSwitchObserver observer = IUserSwitchObserver.Stub.asInterface(
1740+
data.readStrongBinder());
1741+
registerUserSwitchObserver(observer);
1742+
return true;
1743+
}
1744+
1745+
case UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION: {
1746+
data.enforceInterface(IActivityManager.descriptor);
1747+
IUserSwitchObserver observer = IUserSwitchObserver.Stub.asInterface(
1748+
data.readStrongBinder());
1749+
unregisterUserSwitchObserver(observer);
1750+
return true;
1751+
}
1752+
17371753
}
17381754

17391755
return super.onTransact(code, data, reply, flags);
@@ -3955,5 +3971,27 @@ public int getLaunchedFromUid(IBinder activityToken) throws RemoteException {
39553971
return result;
39563972
}
39573973

3974+
public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException {
3975+
Parcel data = Parcel.obtain();
3976+
Parcel reply = Parcel.obtain();
3977+
data.writeInterfaceToken(IActivityManager.descriptor);
3978+
data.writeStrongBinder(observer != null ? observer.asBinder() : null);
3979+
mRemote.transact(REGISTER_USER_SWITCH_OBSERVER_TRANSACTION, data, reply, 0);
3980+
reply.readException();
3981+
data.recycle();
3982+
reply.recycle();
3983+
}
3984+
3985+
public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException {
3986+
Parcel data = Parcel.obtain();
3987+
Parcel reply = Parcel.obtain();
3988+
data.writeInterfaceToken(IActivityManager.descriptor);
3989+
data.writeStrongBinder(observer != null ? observer.asBinder() : null);
3990+
mRemote.transact(UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION, data, reply, 0);
3991+
reply.readException();
3992+
data.recycle();
3993+
reply.recycle();
3994+
}
3995+
39583996
private IBinder mRemote;
39593997
}

core/java/android/app/IActivityManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent
360360
// manage your activity to make sure it is always the uid you expect.
361361
public int getLaunchedFromUid(IBinder activityToken) throws RemoteException;
362362

363+
public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
364+
public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
365+
363366
/*
364367
* Private non-Binder interfaces
365368
*/
@@ -609,4 +612,6 @@ private WaitResult(Parcel source) {
609612
int IS_INTENT_SENDER_AN_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+151;
610613
int START_ACTIVITY_AS_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+152;
611614
int STOP_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+153;
615+
int REGISTER_USER_SWITCH_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+154;
616+
int UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+155;
612617
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2012 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.os.IRemoteCallback;
20+
21+
/** {@hide} */
22+
oneway interface IUserSwitchObserver {
23+
void onUserSwitching(int newUserId, IRemoteCallback reply);
24+
void onUserSwitchComplete(int newUserId);
25+
}

core/java/android/app/IWallpaperManager.aidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ interface IWallpaperManager {
5151
*/
5252
void clearWallpaper();
5353

54+
/**
55+
* Return whether there is a wallpaper set with the given name.
56+
*/
57+
boolean hasNamedWallpaper(String name);
58+
5459
/**
5560
* Sets the dimension hint for the wallpaper. These hints indicate the desired
5661
* minimum width and height for the wallpaper.

core/java/android/app/WallpaperManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,25 @@ private void setWallpaper(InputStream data, FileOutputStream fos)
589589
}
590590
}
591591

592+
/**
593+
* Return whether any users are currently set to use the wallpaper
594+
* with the given resource ID. That is, their wallpaper has been
595+
* set through {@link #setResource(int)} with the same resource id.
596+
*/
597+
public boolean hasResourceWallpaper(int resid) {
598+
if (sGlobals.mService == null) {
599+
Log.w(TAG, "WallpaperService not running");
600+
return false;
601+
}
602+
try {
603+
Resources resources = mContext.getResources();
604+
String name = "res:" + resources.getResourceName(resid);
605+
return sGlobals.mService.hasNamedWallpaper(name);
606+
} catch (RemoteException e) {
607+
return false;
608+
}
609+
}
610+
592611
/**
593612
* Returns the desired minimum width for the wallpaper. Callers of
594613
* {@link #setBitmap(android.graphics.Bitmap)} or

core/java/android/content/Intent.java

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,34 +2286,84 @@ public static Intent createChooser(Intent target, CharSequence title) {
22862286
public static final String ACTION_PRE_BOOT_COMPLETED =
22872287
"android.intent.action.PRE_BOOT_COMPLETED";
22882288

2289+
/**
2290+
* Sent the first time a user is starting, to allow system apps to
2291+
* perform one time initialization. (This will not be seen by third
2292+
* party applications because a newly initialized user does not have any
2293+
* third party applications installed for it.) This is sent early in
2294+
* starting the user, around the time the home app is started, before
2295+
* {@link #ACTION_BOOT_COMPLETED} is sent.
2296+
*/
2297+
public static final String ACTION_USER_INITIALIZE =
2298+
"android.intent.action.USER_INITIALIZE";
2299+
2300+
/**
2301+
* Sent when a user switch is happening, causing the process's user to be
2302+
* brought to the foreground. This is only sent to receivers registered
2303+
* through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2304+
* Context.registerReceiver}. It is sent to the user that is going to the
2305+
* foreground.
2306+
*/
2307+
public static final String ACTION_USER_FOREGROUND =
2308+
"android.intent.action.USER_FOREGROUND";
2309+
2310+
/**
2311+
* Sent when a user switch is happening, causing the process's user to be
2312+
* sent to the background. This is only sent to receivers registered
2313+
* through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2314+
* Context.registerReceiver}. It is sent to the user that is going to the
2315+
* background.
2316+
*/
2317+
public static final String ACTION_USER_BACKGROUND =
2318+
"android.intent.action.USER_BACKGROUND";
2319+
22892320
/**
22902321
* Broadcast sent to the system when a user is added. Carries an extra EXTRA_USER_HANDLE that has the
2291-
* userHandle of the new user.
2322+
* userHandle of the new user. It is sent to all running users. You must hold
2323+
* {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
22922324
* @hide
22932325
*/
22942326
public static final String ACTION_USER_ADDED =
22952327
"android.intent.action.USER_ADDED";
22962328

2329+
/**
2330+
* Broadcast sent to the system when a user is started. Carries an extra EXTRA_USER_HANDLE that has
2331+
* the userHandle of the user. This is only sent to
2332+
* registered receivers, not manifest receivers. It is sent to the user
2333+
* that has been started.
2334+
* @hide
2335+
*/
2336+
public static final String ACTION_USER_STARTED =
2337+
"android.intent.action.USER_STARTED";
2338+
22972339
/**
22982340
* Broadcast sent to the system when a user is stopped. Carries an extra EXTRA_USER_HANDLE that has
22992341
* the userHandle of the user. This is similar to {@link #ACTION_PACKAGE_RESTARTED},
2300-
* but for an entire user instead of a specific package.
2342+
* but for an entire user instead of a specific package. This is only sent to
2343+
* registered receivers, not manifest receivers. It is sent to all running
2344+
* users <em>except</em> the one that has just been stopped (which is no
2345+
* longer running).
23012346
* @hide
23022347
*/
23032348
public static final String ACTION_USER_STOPPED =
23042349
"android.intent.action.USER_STOPPED";
23052350

23062351
/**
23072352
* Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
2308-
* the userHandle of the user.
2353+
* the userHandle of the user. It is sent to all running users except the
2354+
* one that has been removed. You must hold
2355+
* {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
23092356
* @hide
23102357
*/
23112358
public static final String ACTION_USER_REMOVED =
23122359
"android.intent.action.USER_REMOVED";
23132360

23142361
/**
23152362
* Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
2316-
* the userHandle of the user to become the current one.
2363+
* the userHandle of the user to become the current one. This is only sent to
2364+
* registered receivers, not manifest receivers. It is sent to all running users.
2365+
* You must hold
2366+
* {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
23172367
* @hide
23182368
*/
23192369
public static final String ACTION_USER_SWITCHED =

core/java/android/content/pm/UserInfo.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class UserInfo implements Parcelable {
2929
/** 6 bits for user type */
3030
public static final int FLAG_MASK_USER_TYPE = 0x0000003F;
3131

32+
/**
33+
* *************************** NOTE ***************************
34+
* These flag values CAN NOT CHANGE because they are written
35+
* directly to storage.
36+
*/
37+
3238
/**
3339
* Primary user. Only one user can have this flag set. Meaning of this
3440
* flag TBD.
@@ -52,6 +58,11 @@ public class UserInfo implements Parcelable {
5258
*/
5359
public static final int FLAG_RESTRICTED = 0x00000008;
5460

61+
/**
62+
* Indicates that this user has gone through its first-time initialization.
63+
*/
64+
public static final int FLAG_INITIALIZED = 0x00000010;
65+
5566
public int id;
5667
public int serialNumber;
5768
public String name;

core/java/android/service/wallpaper/IWallpaperConnection.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ import android.service.wallpaper.IWallpaperEngine;
2424
*/
2525
interface IWallpaperConnection {
2626
void attachEngine(IWallpaperEngine engine);
27+
void engineShown(IWallpaperEngine engine);
2728
ParcelFileDescriptor setWallpaper(String name);
2829
}

0 commit comments

Comments
 (0)