diff options
3 files changed, 50 insertions, 31 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index f3bef08..b97539c 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -1007,8 +1007,8 @@ public class LockPatternUtils { * or null if there is no next alarm. */ public String getNextAlarm() { - String nextAlarm = Settings.System.getString(mContentResolver, - Settings.System.NEXT_ALARM_FORMATTED); + String nextAlarm = Settings.System.getStringForUser(mContentResolver, + Settings.System.NEXT_ALARM_FORMATTED, UserHandle.USER_CURRENT); if (nextAlarm == null || TextUtils.isEmpty(nextAlarm)) { return null; } @@ -1035,8 +1035,9 @@ public class LockPatternUtils { public int[] getUserDefinedWidgets() { int appWidgetId = -1; - String appWidgetIdString = Settings.Secure.getString( - mContentResolver, Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID); + String appWidgetIdString = Settings.Secure.getStringForUser( + mContentResolver, Settings.Secure.LOCK_SCREEN_USER_SELECTED_APPWIDGET_ID, + UserHandle.USER_CURRENT); if (appWidgetIdString != null) { appWidgetId = (int) Integer.decode(appWidgetIdString); } @@ -1046,8 +1047,9 @@ public class LockPatternUtils { public int getStatusWidget() { int appWidgetId = -1; - String appWidgetIdString = Settings.Secure.getString( - mContentResolver, Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID); + String appWidgetIdString = Settings.Secure.getStringForUser( + mContentResolver, Settings.Secure.LOCK_SCREEN_STATUS_APPWIDGET_ID, + UserHandle.USER_CURRENT); if (appWidgetIdString != null) { appWidgetId = (int) Integer.decode(appWidgetIdString); } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java index ba22f09..b30913a 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java @@ -28,6 +28,7 @@ import libcore.util.MutableInt; import android.content.ContentResolver; import android.content.Context; import android.graphics.Typeface; +import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import android.text.format.DateFormat; @@ -178,9 +179,10 @@ class KeyguardStatusViewManager { private void updateOwnerInfo() { final ContentResolver res = getContext().getContentResolver(); - final boolean ownerInfoEnabled = Settings.Secure.getInt(res, - Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1) != 0; - String text = Settings.Secure.getString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO); + final boolean ownerInfoEnabled = Settings.Secure.getIntForUser(res, + Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1, UserHandle.USER_CURRENT) != 0; + String text = Settings.Secure.getStringForUser(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO, + UserHandle.USER_CURRENT); if (ownerInfoEnabled && !TextUtils.isEmpty(text)) { maybeSetUpperCaseText(mOwnerInfoView, text); mOwnerInfoView.setVisibility(View.VISIBLE); diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index 385681e..9be7045 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -16,6 +16,7 @@ package com.android.server; +import android.app.ActivityManagerNative; import android.app.AlarmManager; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; @@ -27,6 +28,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; +import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; @@ -193,31 +195,44 @@ class AppWidgetService extends IAppWidgetService.Stub }, UserHandle.ALL, userFilter, null, null); } + private int getCallingOrCurrentUserId() { + int callingUid = Binder.getCallingUid(); + if (callingUid == android.os.Process.myUid()) { + try { + return ActivityManagerNative.getDefault().getCurrentUser().id; + } catch (RemoteException re) { + return UserHandle.getUserId(callingUid); + } + } else { + return UserHandle.getUserId(callingUid); + } + } + @Override public int allocateAppWidgetId(String packageName, int hostId) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).allocateAppWidgetId( + return getImplForUser(getCallingOrCurrentUserId()).allocateAppWidgetId( packageName, hostId); } @Override public void deleteAppWidgetId(int appWidgetId) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).deleteAppWidgetId(appWidgetId); + getImplForUser(getCallingOrCurrentUserId()).deleteAppWidgetId(appWidgetId); } @Override public void deleteHost(int hostId) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).deleteHost(hostId); + getImplForUser(getCallingOrCurrentUserId()).deleteHost(hostId); } @Override public void deleteAllHosts() throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).deleteAllHosts(); + getImplForUser(getCallingOrCurrentUserId()).deleteAllHosts(); } @Override public void bindAppWidgetId(int appWidgetId, ComponentName provider, Bundle options) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).bindAppWidgetId(appWidgetId, provider, + getImplForUser(getCallingOrCurrentUserId()).bindAppWidgetId(appWidgetId, provider, options); } @@ -225,34 +240,34 @@ class AppWidgetService extends IAppWidgetService.Stub public boolean bindAppWidgetIdIfAllowed( String packageName, int appWidgetId, ComponentName provider, Bundle options) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).bindAppWidgetIdIfAllowed( + return getImplForUser(getCallingOrCurrentUserId()).bindAppWidgetIdIfAllowed( packageName, appWidgetId, provider, options); } @Override public boolean hasBindAppWidgetPermission(String packageName) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).hasBindAppWidgetPermission( + return getImplForUser(getCallingOrCurrentUserId()).hasBindAppWidgetPermission( packageName); } @Override public void setBindAppWidgetPermission(String packageName, boolean permission) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).setBindAppWidgetPermission( + getImplForUser(getCallingOrCurrentUserId()).setBindAppWidgetPermission( packageName, permission); } @Override public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).bindRemoteViewsService( + getImplForUser(getCallingOrCurrentUserId()).bindRemoteViewsService( appWidgetId, intent, connection); } @Override public int[] startListening(IAppWidgetHost host, String packageName, int hostId, List<RemoteViews> updatedViews) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).startListening(host, + return getImplForUser(getCallingOrCurrentUserId()).startListening(host, packageName, hostId, updatedViews); } @@ -287,27 +302,27 @@ class AppWidgetService extends IAppWidgetService.Stub @Override public int[] getAppWidgetIds(ComponentName provider) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).getAppWidgetIds(provider); + return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetIds(provider); } @Override public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).getAppWidgetInfo(appWidgetId); + return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetInfo(appWidgetId); } @Override public RemoteViews getAppWidgetViews(int appWidgetId) throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).getAppWidgetViews(appWidgetId); + return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetViews(appWidgetId); } @Override public void updateAppWidgetOptions(int appWidgetId, Bundle options) { - getImplForUser(UserHandle.getCallingUserId()).updateAppWidgetOptions(appWidgetId, options); + getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetOptions(appWidgetId, options); } @Override public Bundle getAppWidgetOptions(int appWidgetId) { - return getImplForUser(UserHandle.getCallingUserId()).getAppWidgetOptions(appWidgetId); + return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetOptions(appWidgetId); } static int[] getAppWidgetIds(Provider p) { @@ -321,43 +336,43 @@ class AppWidgetService extends IAppWidgetService.Stub @Override public List<AppWidgetProviderInfo> getInstalledProviders() throws RemoteException { - return getImplForUser(UserHandle.getCallingUserId()).getInstalledProviders(); + return getImplForUser(getCallingOrCurrentUserId()).getInstalledProviders(); } @Override public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, int viewId) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).notifyAppWidgetViewDataChanged( + getImplForUser(getCallingOrCurrentUserId()).notifyAppWidgetViewDataChanged( appWidgetIds, viewId); } @Override public void partiallyUpdateAppWidgetIds(int[] appWidgetIds, RemoteViews views) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).partiallyUpdateAppWidgetIds( + getImplForUser(getCallingOrCurrentUserId()).partiallyUpdateAppWidgetIds( appWidgetIds, views); } @Override public void stopListening(int hostId) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).stopListening(hostId); + getImplForUser(getCallingOrCurrentUserId()).stopListening(hostId); } @Override public void unbindRemoteViewsService(int appWidgetId, Intent intent) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).unbindRemoteViewsService( + getImplForUser(getCallingOrCurrentUserId()).unbindRemoteViewsService( appWidgetId, intent); } @Override public void updateAppWidgetIds(int[] appWidgetIds, RemoteViews views) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).updateAppWidgetIds(appWidgetIds, views); + getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetIds(appWidgetIds, views); } @Override public void updateAppWidgetProvider(ComponentName provider, RemoteViews views) throws RemoteException { - getImplForUser(UserHandle.getCallingUserId()).updateAppWidgetProvider(provider, views); + getImplForUser(getCallingOrCurrentUserId()).updateAppWidgetProvider(provider, views); } @Override |
