2009-03-03 19:31:44 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 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 com.android.server;
|
|
|
|
|
2013-02-07 16:53:32 -08:00
|
|
|
import android.app.ActivityManager;
|
2009-03-11 12:11:56 -07:00
|
|
|
import android.appwidget.AppWidgetProviderInfo;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.ComponentName;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
2011-01-11 18:05:01 -08:00
|
|
|
import android.content.pm.PackageManager;
|
2012-09-21 17:48:49 -07:00
|
|
|
import android.os.Binder;
|
2012-04-19 17:11:40 -07:00
|
|
|
import android.os.Bundle;
|
2012-11-01 14:06:16 -07:00
|
|
|
import android.os.Handler;
|
2011-01-11 18:05:01 -08:00
|
|
|
import android.os.IBinder;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.os.RemoteException;
|
2012-08-31 14:05:51 -07:00
|
|
|
import android.os.UserHandle;
|
2010-02-26 18:56:32 -08:00
|
|
|
import android.util.Slog;
|
2011-05-04 14:49:28 -07:00
|
|
|
import android.util.SparseArray;
|
2009-03-03 19:31:44 -08:00
|
|
|
import android.widget.RemoteViews;
|
|
|
|
|
2009-03-11 12:11:56 -07:00
|
|
|
import com.android.internal.appwidget.IAppWidgetHost;
|
2011-01-11 18:05:01 -08:00
|
|
|
import com.android.internal.appwidget.IAppWidgetService;
|
2013-04-30 17:24:15 -07:00
|
|
|
import com.android.internal.os.BackgroundThread;
|
2012-10-05 16:10:38 -07:00
|
|
|
import com.android.internal.util.IndentingPrintWriter;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2011-10-12 15:48:13 -07:00
|
|
|
import java.io.FileDescriptor;
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Redirects calls to this service to the instance of the service for the appropriate user.
|
|
|
|
*/
|
2009-03-11 12:11:56 -07:00
|
|
|
class AppWidgetService extends IAppWidgetService.Stub
|
2009-03-03 19:31:44 -08:00
|
|
|
{
|
2009-03-11 12:11:56 -07:00
|
|
|
private static final String TAG = "AppWidgetService";
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
Context mContext;
|
2009-10-22 15:22:50 -07:00
|
|
|
Locale mLocale;
|
2009-03-03 19:31:44 -08:00
|
|
|
PackageManager mPackageManager;
|
|
|
|
boolean mSafeMode;
|
2012-11-01 14:06:16 -07:00
|
|
|
private final Handler mSaveStateHandler;
|
2009-03-03 19:31:44 -08:00
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
private final SparseArray<AppWidgetServiceImpl> mAppWidgetServices;
|
2011-10-05 18:10:13 -07:00
|
|
|
|
2009-03-11 12:11:56 -07:00
|
|
|
AppWidgetService(Context context) {
|
2009-03-03 19:31:44 -08:00
|
|
|
mContext = context;
|
2012-11-01 14:06:16 -07:00
|
|
|
|
2013-04-30 17:24:15 -07:00
|
|
|
mSaveStateHandler = BackgroundThread.getHandler();
|
2012-11-01 14:06:16 -07:00
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
mAppWidgetServices = new SparseArray<AppWidgetServiceImpl>(5);
|
2012-11-01 14:06:16 -07:00
|
|
|
AppWidgetServiceImpl primary = new AppWidgetServiceImpl(context, 0, mSaveStateHandler);
|
2011-05-04 14:49:28 -07:00
|
|
|
mAppWidgetServices.append(0, primary);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2013-06-25 14:59:53 -07:00
|
|
|
public void systemRunning(boolean safeMode) {
|
2009-03-03 19:31:44 -08:00
|
|
|
mSafeMode = safeMode;
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
mAppWidgetServices.get(0).systemReady(safeMode);
|
2009-03-03 19:31:44 -08:00
|
|
|
|
|
|
|
// Register for the boot completed broadcast, so we can send the
|
2011-05-04 14:49:28 -07:00
|
|
|
// ENABLE broacasts. If we try to send them now, they time out,
|
2009-03-03 19:31:44 -08:00
|
|
|
// because the system isn't ready to handle them yet.
|
2012-08-31 19:00:44 -07:00
|
|
|
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
2009-03-03 19:31:44 -08:00
|
|
|
new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);
|
|
|
|
|
2009-10-22 15:22:50 -07:00
|
|
|
// Register for configuration changes so we can update the names
|
|
|
|
// of the widgets when the locale changes.
|
2012-09-04 18:48:37 -07:00
|
|
|
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
|
|
|
new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED), null, null);
|
2009-10-22 15:22:50 -07:00
|
|
|
|
2009-03-03 19:31:44 -08:00
|
|
|
// Register for broadcasts about package install, etc., so we can
|
|
|
|
// update the provider list.
|
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
|
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
2011-01-07 20:50:37 -08:00
|
|
|
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
2009-03-03 19:31:44 -08:00
|
|
|
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
|
|
|
filter.addDataScheme("package");
|
2012-08-31 19:00:44 -07:00
|
|
|
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
|
|
|
filter, null, null);
|
2010-01-28 09:57:30 -08:00
|
|
|
// Register for events related to sdcard installation.
|
|
|
|
IntentFilter sdFilter = new IntentFilter();
|
2010-02-04 22:51:07 -08:00
|
|
|
sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
|
|
|
sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
2012-08-31 19:00:44 -07:00
|
|
|
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
|
|
|
|
sdFilter, null, null);
|
2012-03-22 16:16:17 -07:00
|
|
|
|
|
|
|
IntentFilter userFilter = new IntentFilter();
|
|
|
|
userFilter.addAction(Intent.ACTION_USER_REMOVED);
|
2012-10-12 12:30:07 -07:00
|
|
|
userFilter.addAction(Intent.ACTION_USER_STOPPING);
|
2012-03-22 16:16:17 -07:00
|
|
|
mContext.registerReceiver(new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2012-10-12 12:30:07 -07:00
|
|
|
if (Intent.ACTION_USER_REMOVED.equals(intent.getAction())) {
|
|
|
|
onUserRemoved(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
|
|
|
|
UserHandle.USER_NULL));
|
|
|
|
} else if (Intent.ACTION_USER_STOPPING.equals(intent.getAction())) {
|
|
|
|
onUserStopping(intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
|
|
|
|
UserHandle.USER_NULL));
|
|
|
|
}
|
2012-03-22 16:16:17 -07:00
|
|
|
}
|
|
|
|
}, userFilter);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public int allocateAppWidgetId(String packageName, int hostId, int userId)
|
|
|
|
throws RemoteException {
|
|
|
|
return getImplForUser(userId).allocateAppWidgetId(packageName, hostId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2012-11-15 18:22:47 -08:00
|
|
|
|
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public int[] getAppWidgetIdsForHost(int hostId, int userId) throws RemoteException {
|
|
|
|
return getImplForUser(userId).getAppWidgetIdsForHost(hostId);
|
2012-11-15 18:22:47 -08:00
|
|
|
}
|
2013-02-07 16:53:32 -08:00
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void deleteAppWidgetId(int appWidgetId, int userId) throws RemoteException {
|
|
|
|
getImplForUser(userId).deleteAppWidgetId(appWidgetId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void deleteHost(int hostId, int userId) throws RemoteException {
|
|
|
|
getImplForUser(userId).deleteHost(hostId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void deleteAllHosts(int userId) throws RemoteException {
|
|
|
|
getImplForUser(userId).deleteAllHosts();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options, int userId)
|
2012-09-07 17:37:26 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).bindAppWidgetId(appWidgetId, provider, options);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2012-04-13 10:39:45 -07:00
|
|
|
@Override
|
|
|
|
public boolean bindAppWidgetIdIfAllowed(
|
2013-02-07 16:53:32 -08:00
|
|
|
String packageName, int appWidgetId, ComponentName provider, Bundle options, int userId)
|
2012-09-07 17:37:26 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
return getImplForUser(userId).bindAppWidgetIdIfAllowed(
|
2012-09-07 17:37:26 -07:00
|
|
|
packageName, appWidgetId, provider, options);
|
2012-04-13 10:39:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public boolean hasBindAppWidgetPermission(String packageName, int userId)
|
|
|
|
throws RemoteException {
|
|
|
|
return getImplForUser(userId).hasBindAppWidgetPermission(packageName);
|
2012-04-13 10:39:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void setBindAppWidgetPermission(String packageName, boolean permission, int userId)
|
2012-04-13 10:39:45 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).setBindAppWidgetPermission(packageName, permission);
|
2012-04-13 10:39:45 -07:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2012-11-30 15:26:21 -08:00
|
|
|
public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection,
|
|
|
|
int userId) throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).bindRemoteViewsService(appWidgetId, intent, connection);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
|
|
|
public int[] startListening(IAppWidgetHost host, String packageName, int hostId,
|
2012-11-30 15:26:21 -08:00
|
|
|
List<RemoteViews> updatedViews, int userId) throws RemoteException {
|
|
|
|
return getImplForUser(userId).startListening(host, packageName, hostId, updatedViews);
|
|
|
|
}
|
|
|
|
|
2012-03-22 16:16:17 -07:00
|
|
|
public void onUserRemoved(int userId) {
|
|
|
|
if (userId < 1) return;
|
2012-10-05 16:10:38 -07:00
|
|
|
synchronized (mAppWidgetServices) {
|
|
|
|
AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
|
|
|
|
mAppWidgetServices.remove(userId);
|
2012-10-12 12:30:07 -07:00
|
|
|
|
2012-10-05 16:10:38 -07:00
|
|
|
if (impl == null) {
|
|
|
|
AppWidgetServiceImpl.getSettingsFile(userId).delete();
|
|
|
|
} else {
|
|
|
|
impl.onUserRemoved();
|
|
|
|
}
|
2012-03-22 16:16:17 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2012-10-12 12:30:07 -07:00
|
|
|
public void onUserStopping(int userId) {
|
|
|
|
if (userId < 1) return;
|
|
|
|
synchronized (mAppWidgetServices) {
|
|
|
|
AppWidgetServiceImpl impl = mAppWidgetServices.get(userId);
|
|
|
|
if (impl != null) {
|
|
|
|
mAppWidgetServices.remove(userId);
|
|
|
|
impl.onUserStopping();
|
|
|
|
}
|
|
|
|
}
|
2012-08-31 19:00:44 -07:00
|
|
|
}
|
|
|
|
|
2013-02-07 16:53:32 -08:00
|
|
|
private void checkPermission(int userId) {
|
|
|
|
int realUserId = ActivityManager.handleIncomingUser(
|
|
|
|
Binder.getCallingPid(),
|
|
|
|
Binder.getCallingUid(),
|
|
|
|
userId,
|
|
|
|
false, /* allowAll */
|
|
|
|
true, /* requireFull */
|
|
|
|
this.getClass().getSimpleName(),
|
|
|
|
this.getClass().getPackage().getName());
|
|
|
|
}
|
|
|
|
|
2012-08-31 14:05:51 -07:00
|
|
|
private AppWidgetServiceImpl getImplForUser(int userId) {
|
2013-02-07 16:53:32 -08:00
|
|
|
checkPermission(userId);
|
2012-10-05 16:10:38 -07:00
|
|
|
boolean sendInitial = false;
|
|
|
|
AppWidgetServiceImpl service;
|
|
|
|
synchronized (mAppWidgetServices) {
|
|
|
|
service = mAppWidgetServices.get(userId);
|
|
|
|
if (service == null) {
|
|
|
|
Slog.i(TAG, "Unable to find AppWidgetServiceImpl for user " + userId + ", adding");
|
|
|
|
// TODO: Verify that it's a valid user
|
2012-11-01 14:06:16 -07:00
|
|
|
service = new AppWidgetServiceImpl(mContext, userId, mSaveStateHandler);
|
2012-10-05 16:10:38 -07:00
|
|
|
service.systemReady(mSafeMode);
|
|
|
|
// Assume that BOOT_COMPLETED was received, as this is a non-primary user.
|
|
|
|
mAppWidgetServices.append(userId, service);
|
|
|
|
sendInitial = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sendInitial) {
|
2011-05-04 14:49:28 -07:00
|
|
|
service.sendInitialBroadcasts();
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2011-05-04 14:49:28 -07:00
|
|
|
return service;
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public int[] getAppWidgetIds(ComponentName provider, int userId) throws RemoteException {
|
|
|
|
return getImplForUser(userId).getAppWidgetIds(provider);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId, int userId)
|
|
|
|
throws RemoteException {
|
|
|
|
return getImplForUser(userId).getAppWidgetInfo(appWidgetId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public RemoteViews getAppWidgetViews(int appWidgetId, int userId) throws RemoteException {
|
|
|
|
return getImplForUser(userId).getAppWidgetViews(appWidgetId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2012-04-19 17:11:40 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void updateAppWidgetOptions(int appWidgetId, Bundle options, int userId) {
|
|
|
|
getImplForUser(userId).updateAppWidgetOptions(appWidgetId, options);
|
2012-04-19 17:11:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public Bundle getAppWidgetOptions(int appWidgetId, int userId) {
|
|
|
|
return getImplForUser(userId).getAppWidgetOptions(appWidgetId);
|
2012-04-19 17:11:40 -07:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter, int userId)
|
2012-11-28 16:34:57 -08:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
return getImplForUser(userId).getInstalledProviders(categoryFilter);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, int viewId, int userId)
|
2011-05-04 14:49:28 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).notifyAppWidgetViewDataChanged(
|
2012-08-31 14:05:51 -07:00
|
|
|
appWidgetIds, viewId);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void partiallyUpdateAppWidgetIds(int[] appWidgetIds, RemoteViews views, int userId)
|
2011-05-04 14:49:28 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).partiallyUpdateAppWidgetIds(
|
2012-08-31 14:05:51 -07:00
|
|
|
appWidgetIds, views);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void stopListening(int hostId, int userId) throws RemoteException {
|
2012-11-30 15:26:21 -08:00
|
|
|
getImplForUser(userId).stopListening(hostId);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void unbindRemoteViewsService(int appWidgetId, Intent intent, int userId)
|
|
|
|
throws RemoteException {
|
|
|
|
getImplForUser(userId).unbindRemoteViewsService(
|
2012-08-31 14:05:51 -07:00
|
|
|
appWidgetId, intent);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
2011-10-12 15:48:13 -07:00
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void updateAppWidgetIds(int[] appWidgetIds, RemoteViews views, int userId)
|
|
|
|
throws RemoteException {
|
|
|
|
getImplForUser(userId).updateAppWidgetIds(appWidgetIds, views);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
2013-02-07 16:53:32 -08:00
|
|
|
public void updateAppWidgetProvider(ComponentName provider, RemoteViews views, int userId)
|
2011-05-04 14:49:28 -07:00
|
|
|
throws RemoteException {
|
2013-02-07 16:53:32 -08:00
|
|
|
getImplForUser(userId).updateAppWidgetProvider(provider, views);
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
@Override
|
|
|
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
2012-10-12 16:06:16 -07:00
|
|
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
|
|
|
|
|
2011-05-04 14:49:28 -07:00
|
|
|
// Dump the state of all the app widget providers
|
2012-10-05 16:10:38 -07:00
|
|
|
synchronized (mAppWidgetServices) {
|
|
|
|
IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
|
|
|
|
for (int i = 0; i < mAppWidgetServices.size(); i++) {
|
|
|
|
pw.println("User: " + mAppWidgetServices.keyAt(i));
|
|
|
|
ipw.increaseIndent();
|
|
|
|
AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
|
|
|
|
service.dump(fd, ipw, args);
|
|
|
|
ipw.decreaseIndent();
|
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
String action = intent.getAction();
|
2011-05-04 14:49:28 -07:00
|
|
|
// Slog.d(TAG, "received " + action);
|
2009-03-03 19:31:44 -08:00
|
|
|
if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
2012-10-12 12:30:07 -07:00
|
|
|
int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
|
2012-08-31 14:05:51 -07:00
|
|
|
if (userId >= 0) {
|
|
|
|
getImplForUser(userId).sendInitialBroadcasts();
|
|
|
|
} else {
|
2012-10-12 12:30:07 -07:00
|
|
|
Slog.w(TAG, "Incorrect user handle supplied in " + intent);
|
2012-08-31 14:05:51 -07:00
|
|
|
}
|
2009-10-22 15:22:50 -07:00
|
|
|
} else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
|
2011-05-04 14:49:28 -07:00
|
|
|
for (int i = 0; i < mAppWidgetServices.size(); i++) {
|
|
|
|
AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
|
|
|
|
service.onConfigurationChanged();
|
2009-10-22 15:22:50 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
} else {
|
2012-08-31 19:00:44 -07:00
|
|
|
int sendingUser = getSendingUserId();
|
|
|
|
if (sendingUser == UserHandle.USER_ALL) {
|
|
|
|
for (int i = 0; i < mAppWidgetServices.size(); i++) {
|
|
|
|
AppWidgetServiceImpl service = mAppWidgetServices.valueAt(i);
|
|
|
|
service.onBroadcastReceived(intent);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AppWidgetServiceImpl service = mAppWidgetServices.get(sendingUser);
|
|
|
|
if (service != null) {
|
|
|
|
service.onBroadcastReceived(intent);
|
|
|
|
}
|
2012-03-13 16:08:00 -07:00
|
|
|
}
|
2009-03-03 19:31:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|