blob: 06d37dc32a390837984ca7dba45304809bc661db [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
17package com.android.server;
18
Amith Yamasani8fd96ec2012-09-21 17:48:49 -070019import android.app.ActivityManagerNative;
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070020import android.appwidget.AppWidgetProviderInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.BroadcastReceiver;
22import android.content.ComponentName;
23import android.content.Context;
24import android.content.Intent;
25import android.content.IntentFilter;
Winson Chung81f39eb2011-01-11 18:05:01 -080026import android.content.pm.PackageManager;
Amith Yamasani8fd96ec2012-09-21 17:48:49 -070027import android.os.Binder;
Adam Cohene8724c82012-04-19 17:11:40 -070028import android.os.Bundle;
Winson Chung81f39eb2011-01-11 18:05:01 -080029import android.os.IBinder;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.RemoteException;
Dianne Hackborn41203752012-08-31 14:05:51 -070031import android.os.UserHandle;
Joe Onorato8a9b2202010-02-26 18:56:32 -080032import android.util.Slog;
Amith Yamasani742a6712011-05-04 14:49:28 -070033import android.util.SparseArray;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.widget.RemoteViews;
35
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070036import com.android.internal.appwidget.IAppWidgetHost;
Winson Chung81f39eb2011-01-11 18:05:01 -080037import com.android.internal.appwidget.IAppWidgetService;
Amith Yamasani8320de82012-10-05 16:10:38 -070038import com.android.internal.util.IndentingPrintWriter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039
Adam Cohen97300312011-10-12 15:48:13 -070040import java.io.FileDescriptor;
Adam Cohen97300312011-10-12 15:48:13 -070041import java.io.PrintWriter;
Adam Cohen97300312011-10-12 15:48:13 -070042import java.util.List;
43import java.util.Locale;
44
Amith Yamasani742a6712011-05-04 14:49:28 -070045
46/**
47 * Redirects calls to this service to the instance of the service for the appropriate user.
48 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070049class AppWidgetService extends IAppWidgetService.Stub
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050{
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070051 private static final String TAG = "AppWidgetService";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 Context mContext;
Eric Fischer63c2d9e2009-10-22 15:22:50 -070054 Locale mLocale;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 PackageManager mPackageManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 boolean mSafeMode;
57
Amith Yamasani742a6712011-05-04 14:49:28 -070058 private final SparseArray<AppWidgetServiceImpl> mAppWidgetServices;
Adam Cohen7bb98832011-10-05 18:10:13 -070059
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070060 AppWidgetService(Context context) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 mContext = context;
Amith Yamasani742a6712011-05-04 14:49:28 -070062 mAppWidgetServices = new SparseArray<AppWidgetServiceImpl>(5);
63 AppWidgetServiceImpl primary = new AppWidgetServiceImpl(context, 0);
64 mAppWidgetServices.append(0, primary);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065 }
66
67 public void systemReady(boolean safeMode) {
68 mSafeMode = safeMode;
69
Amith Yamasani742a6712011-05-04 14:49:28 -070070 mAppWidgetServices.get(0).systemReady(safeMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071
72 // Register for the boot completed broadcast, so we can send the
Amith Yamasani742a6712011-05-04 14:49:28 -070073 // ENABLE broacasts. If we try to send them now, they time out,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 // because the system isn't ready to handle them yet.
Dianne Hackborn20e80982012-08-31 19:00:44 -070075 mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);
77
Eric Fischer63c2d9e2009-10-22 15:22:50 -070078 // Register for configuration changes so we can update the names
79 // of the widgets when the locale changes.
Dianne Hackbornfd8bf5c2012-09-04 18:48:37 -070080 mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
81 new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED), null, null);
Eric Fischer63c2d9e2009-10-22 15:22:50 -070082
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 // Register for broadcasts about package install, etc., so we can
84 // update the provider list.
85 IntentFilter filter = new IntentFilter();
86 filter.addAction(Intent.ACTION_PACKAGE_ADDED);
Joe Onoratod070e892011-01-07 20:50:37 -080087 filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
89 filter.addDataScheme("package");
Dianne Hackborn20e80982012-08-31 19:00:44 -070090 mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
91 filter, null, null);
Suchi Amalapurapu08675a32010-01-28 09:57:30 -080092 // Register for events related to sdcard installation.
93 IntentFilter sdFilter = new IntentFilter();
Suchi Amalapurapub56ae202010-02-04 22:51:07 -080094 sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
95 sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
Dianne Hackborn20e80982012-08-31 19:00:44 -070096 mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
97 sdFilter, null, null);
Amith Yamasani13593602012-03-22 16:16:17 -070098
99 IntentFilter userFilter = new IntentFilter();
100 userFilter.addAction(Intent.ACTION_USER_REMOVED);
Amith Yamasani756901d2012-10-12 12:30:07 -0700101 userFilter.addAction(Intent.ACTION_USER_STOPPING);
Amith Yamasani13593602012-03-22 16:16:17 -0700102 mContext.registerReceiver(new BroadcastReceiver() {
103 @Override
104 public void onReceive(Context context, Intent intent) {
Amith Yamasani756901d2012-10-12 12:30:07 -0700105 if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
106 onUserRemoved(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
107 UserHandle.USER_NULL));
108 } else if (Intent.ACTION_USER_STOPPING.equals(intent.getAction())) {
109 onUserStopping(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
110 UserHandle.USER_NULL));
111 }
Amith Yamasani13593602012-03-22 16:16:17 -0700112 }
113 }, userFilter);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 }
115
Amith Yamasani8320de82012-10-05 16:10:38 -0700116 /**
117 * This returns the user id of the caller, if the caller is not the system process,
118 * otherwise it assumes that the calls are from the lockscreen and hence are meant for the
119 * current user. TODO: Instead, have lockscreen make explicit calls with userId
120 */
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700121 private int getCallingOrCurrentUserId() {
122 int callingUid = Binder.getCallingUid();
Amith Yamasani8320de82012-10-05 16:10:38 -0700123 // Also check the PID because Settings (power control widget) also runs as System UID
124 if (callingUid == android.os.Process.myUid()
125 && Binder.getCallingPid() == android.os.Process.myPid()) {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700126 try {
127 return ActivityManagerNative.getDefault().getCurrentUser().id;
128 } catch (RemoteException re) {
129 return UserHandle.getUserId(callingUid);
130 }
131 } else {
132 return UserHandle.getUserId(callingUid);
133 }
134 }
135
Amith Yamasani742a6712011-05-04 14:49:28 -0700136 @Override
137 public int allocateAppWidgetId(String packageName, int hostId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700138 return getImplForUser(getCallingOrCurrentUserId()).allocateAppWidgetId(
Dianne Hackborn41203752012-08-31 14:05:51 -0700139 packageName, hostId);
Jeff Sharkey15d161f2011-09-01 21:30:56 -0700140 }
Amith Yamasani742a6712011-05-04 14:49:28 -0700141
142 @Override
143 public void deleteAppWidgetId(int appWidgetId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700144 getImplForUser(getCallingOrCurrentUserId()).deleteAppWidgetId(appWidgetId);
Adam Cohen7bb98832011-10-05 18:10:13 -0700145 }
146
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 @Override
Amith Yamasani742a6712011-05-04 14:49:28 -0700148 public void deleteHost(int hostId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700149 getImplForUser(getCallingOrCurrentUserId()).deleteHost(hostId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 }
151
Amith Yamasani742a6712011-05-04 14:49:28 -0700152 @Override
153 public void deleteAllHosts() throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700154 getImplForUser(getCallingOrCurrentUserId()).deleteAllHosts();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155 }
156
Amith Yamasani742a6712011-05-04 14:49:28 -0700157 @Override
Adam Cohen0aa2d422012-09-07 17:37:26 -0700158 public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options)
159 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700160 getImplForUser(getCallingOrCurrentUserId()).bindAppWidgetId(appWidgetId, provider,
Adam Cohen0aa2d422012-09-07 17:37:26 -0700161 options);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 }
163
Amith Yamasani742a6712011-05-04 14:49:28 -0700164 @Override
Michael Jurka61a5b012012-04-13 10:39:45 -0700165 public boolean bindAppWidgetIdIfAllowed(
Adam Cohen0aa2d422012-09-07 17:37:26 -0700166 String packageName, int appWidgetId, ComponentName provider, Bundle options)
167 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700168 return getImplForUser(getCallingOrCurrentUserId()).bindAppWidgetIdIfAllowed(
Adam Cohen0aa2d422012-09-07 17:37:26 -0700169 packageName, appWidgetId, provider, options);
Michael Jurka61a5b012012-04-13 10:39:45 -0700170 }
171
172 @Override
173 public boolean hasBindAppWidgetPermission(String packageName) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700174 return getImplForUser(getCallingOrCurrentUserId()).hasBindAppWidgetPermission(
Dianne Hackborn41203752012-08-31 14:05:51 -0700175 packageName);
Michael Jurka61a5b012012-04-13 10:39:45 -0700176 }
177
178 @Override
179 public void setBindAppWidgetPermission(String packageName, boolean permission)
180 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700181 getImplForUser(getCallingOrCurrentUserId()).setBindAppWidgetPermission(
Dianne Hackborn41203752012-08-31 14:05:51 -0700182 packageName, permission);
Michael Jurka61a5b012012-04-13 10:39:45 -0700183 }
184
185 @Override
Amith Yamasani742a6712011-05-04 14:49:28 -0700186 public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection)
187 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700188 getImplForUser(getCallingOrCurrentUserId()).bindRemoteViewsService(
Dianne Hackborn41203752012-08-31 14:05:51 -0700189 appWidgetId, intent, connection);
Winson Chung81f39eb2011-01-11 18:05:01 -0800190 }
191
Amith Yamasani742a6712011-05-04 14:49:28 -0700192 @Override
193 public int[] startListening(IAppWidgetHost host, String packageName, int hostId,
194 List<RemoteViews> updatedViews) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700195 return getImplForUser(getCallingOrCurrentUserId()).startListening(host,
Dianne Hackborn41203752012-08-31 14:05:51 -0700196 packageName, hostId, updatedViews);
Winson Chung81f39eb2011-01-11 18:05:01 -0800197 }
198
Amith Yamasani13593602012-03-22 16:16:17 -0700199 public void onUserRemoved(int userId) {
Amith Yamasani13593602012-03-22 16:16:17 -0700200 if (userId < 1) return;
Amith Yamasani8320de82012-10-05 16:10:38 -0700201 synchronized (mAppWidgetServices) {
202 AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
203 mAppWidgetServices.remove(userId);
Amith Yamasani756901d2012-10-12 12:30:07 -0700204
Amith Yamasani8320de82012-10-05 16:10:38 -0700205 if (impl == null) {
206 AppWidgetServiceImpl.getSettingsFile(userId).delete();
207 } else {
208 impl.onUserRemoved();
209 }
Amith Yamasani13593602012-03-22 16:16:17 -0700210 }
Winson Chung84bbb022011-02-21 13:57:45 -0800211 }
212
Amith Yamasani756901d2012-10-12 12:30:07 -0700213 public void onUserStopping(int userId) {
214 if (userId < 1) return;
215 synchronized (mAppWidgetServices) {
216 AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
217 if (impl != null) {
218 mAppWidgetServices.remove(userId);
219 impl.onUserStopping();
220 }
221 }
Dianne Hackborn20e80982012-08-31 19:00:44 -0700222 }
223
Dianne Hackborn41203752012-08-31 14:05:51 -0700224 private AppWidgetServiceImpl getImplForUser(int userId) {
Amith Yamasani8320de82012-10-05 16:10:38 -0700225 boolean sendInitial = false;
226 AppWidgetServiceImpl service;
227 synchronized (mAppWidgetServices) {
228 service = mAppWidgetServices.get(userId);
229 if (service == null) {
230 Slog.i(TAG, "Unable to find AppWidgetServiceImpl for user " + userId + ", adding");
231 // TODO: Verify that it's a valid user
232 service = new AppWidgetServiceImpl(mContext, userId);
233 service.systemReady(mSafeMode);
234 // Assume that BOOT_COMPLETED was received, as this is a non-primary user.
235 mAppWidgetServices.append(userId, service);
236 sendInitial = true;
237 }
Winson Chung84bbb022011-02-21 13:57:45 -0800238 }
Amith Yamasani8320de82012-10-05 16:10:38 -0700239 if (sendInitial) {
240 service.sendInitialBroadcasts();
241 }
Amith Yamasani742a6712011-05-04 14:49:28 -0700242 return service;
Winson Chung84bbb022011-02-21 13:57:45 -0800243 }
244
Amith Yamasani742a6712011-05-04 14:49:28 -0700245 @Override
246 public int[] getAppWidgetIds(ComponentName provider) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700247 return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetIds(provider);
Winson Chung84bbb022011-02-21 13:57:45 -0800248 }
249
Amith Yamasani742a6712011-05-04 14:49:28 -0700250 @Override
251 public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700252 return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetInfo(appWidgetId);
Winson Chung81f39eb2011-01-11 18:05:01 -0800253 }
254
Amith Yamasani742a6712011-05-04 14:49:28 -0700255 @Override
256 public RemoteViews getAppWidgetViews(int appWidgetId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700257 return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetViews(appWidgetId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 }
259
Adam Cohene8724c82012-04-19 17:11:40 -0700260 @Override
Adam Cohend2097eb2012-05-01 18:10:28 -0700261 public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700262 getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetOptions(appWidgetId, options);
Adam Cohene8724c82012-04-19 17:11:40 -0700263 }
264
265 @Override
Adam Cohend2097eb2012-05-01 18:10:28 -0700266 public Bundle getAppWidgetOptions(int appWidgetId) {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700267 return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetOptions(appWidgetId);
Adam Cohene8724c82012-04-19 17:11:40 -0700268 }
269
Amith Yamasani742a6712011-05-04 14:49:28 -0700270 @Override
271 public List<AppWidgetProviderInfo> getInstalledProviders() throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700272 return getImplForUser(getCallingOrCurrentUserId()).getInstalledProviders();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 }
274
Amith Yamasani742a6712011-05-04 14:49:28 -0700275 @Override
276 public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, int viewId)
277 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700278 getImplForUser(getCallingOrCurrentUserId()).notifyAppWidgetViewDataChanged(
Dianne Hackborn41203752012-08-31 14:05:51 -0700279 appWidgetIds, viewId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 }
281
Amith Yamasani742a6712011-05-04 14:49:28 -0700282 @Override
283 public void partiallyUpdateAppWidgetIds(int[] appWidgetIds, RemoteViews views)
284 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700285 getImplForUser(getCallingOrCurrentUserId()).partiallyUpdateAppWidgetIds(
Dianne Hackborn41203752012-08-31 14:05:51 -0700286 appWidgetIds, views);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 }
288
Amith Yamasani742a6712011-05-04 14:49:28 -0700289 @Override
290 public void stopListening(int hostId) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700291 getImplForUser(getCallingOrCurrentUserId()).stopListening(hostId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 }
293
Amith Yamasani742a6712011-05-04 14:49:28 -0700294 @Override
295 public void unbindRemoteViewsService(int appWidgetId, Intent intent) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700296 getImplForUser(getCallingOrCurrentUserId()).unbindRemoteViewsService(
Dianne Hackborn41203752012-08-31 14:05:51 -0700297 appWidgetId, intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 }
299
Amith Yamasani742a6712011-05-04 14:49:28 -0700300 @Override
301 public void updateAppWidgetIds(int[] appWidgetIds, RemoteViews views) throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700302 getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetIds(appWidgetIds, views);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 }
Adam Cohen97300312011-10-12 15:48:13 -0700304
Amith Yamasani742a6712011-05-04 14:49:28 -0700305 @Override
306 public void updateAppWidgetProvider(ComponentName provider, RemoteViews views)
307 throws RemoteException {
Amith Yamasani8fd96ec2012-09-21 17:48:49 -0700308 getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetProvider(provider, views);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800309 }
310
Amith Yamasani742a6712011-05-04 14:49:28 -0700311 @Override
312 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Jeff Sharkey52801aa2012-10-12 16:06:16 -0700313 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
314
Amith Yamasani742a6712011-05-04 14:49:28 -0700315 // Dump the state of all the app widget providers
Amith Yamasani8320de82012-10-05 16:10:38 -0700316 synchronized (mAppWidgetServices) {
317 IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
318 for (int i = 0; i < mAppWidgetServices.size(); i++) {
319 pw.println("User: " + mAppWidgetServices.keyAt(i));
320 ipw.increaseIndent();
321 AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
322 service.dump(fd, ipw, args);
323 ipw.decreaseIndent();
324 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 }
326 }
327
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
329 public void onReceive(Context context, Intent intent) {
330 String action = intent.getAction();
Amith Yamasani742a6712011-05-04 14:49:28 -0700331 // Slog.d(TAG, "received " + action);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
Amith Yamasani756901d2012-10-12 12:30:07 -0700333 int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
Dianne Hackborn41203752012-08-31 14:05:51 -0700334 if (userId >= 0) {
335 getImplForUser(userId).sendInitialBroadcasts();
336 } else {
Amith Yamasani756901d2012-10-12 12:30:07 -0700337 Slog.w(TAG, "Incorrect user handle supplied in " + intent);
Dianne Hackborn41203752012-08-31 14:05:51 -0700338 }
Eric Fischer63c2d9e2009-10-22 15:22:50 -0700339 } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
Amith Yamasani742a6712011-05-04 14:49:28 -0700340 for (int i = 0; i < mAppWidgetServices.size(); i++) {
341 AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
342 service.onConfigurationChanged();
Eric Fischer63c2d9e2009-10-22 15:22:50 -0700343 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800344 } else {
Dianne Hackborn20e80982012-08-31 19:00:44 -0700345 int sendingUser = getSendingUserId();
346 if (sendingUser == UserHandle.USER_ALL) {
347 for (int i = 0; i < mAppWidgetServices.size(); i++) {
348 AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
349 service.onBroadcastReceived(intent);
350 }
351 } else {
352 AppWidgetServiceImpl service = mAppWidgetServices.get(sendingUser);
353 if (service != null) {
354 service.onBroadcastReceived(intent);
355 }
Amith Yamasani483f3b02012-03-13 16:08:00 -0700356 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 }
358 }
359 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360}