Loading services/core/java/com/android/server/role/RoleManagerService.java +14 −3 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.os.ResultReceiver; import android.os.ShellCallback; import android.os.UserHandle; import android.os.UserManagerInternal; import android.provider.Telephony; import android.service.sms.FinancialSmsService; import android.telephony.IFinancialSmsCallback; import android.text.TextUtils; Loading @@ -60,6 +61,7 @@ import android.util.SparseArray; import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.telephony.SmsApplication; import com.android.internal.util.ArrayUtils; import com.android.internal.util.BitUtils; import com.android.internal.util.CollectionUtils; Loading Loading @@ -377,13 +379,16 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } @Override public void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId) { public void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder) { mListenerHandler.sendMessage(PooledLambda.obtainMessage( RoleManagerService::notifyRoleHoldersChanged, this, roleName, userId)); RoleManagerService::notifyRoleHoldersChanged, this, roleName, userId, removedHolder, addedHolder)); } @WorkerThread private void notifyRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId) { private void notifyRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder) { RemoteCallbackList<IOnRoleHoldersChangedListener> listeners = getListeners(userId); if (listeners != null) { notifyRoleHoldersChangedForListeners(listeners, roleName, userId); Loading @@ -394,6 +399,12 @@ public class RoleManagerService extends SystemService implements RoleUserState.C if (allUsersListeners != null) { notifyRoleHoldersChangedForListeners(allUsersListeners, roleName, userId); } // Legacy: sms app changed broadcasts if (RoleManager.ROLE_SMS.equals(roleName)) { SmsApplication.broadcastSmsAppChange(getContext(), UserHandle.of(userId), removedHolder, addedHolder); } } @WorkerThread Loading services/core/java/com/android/server/role/RoleUserState.java +4 −3 Original line number Diff line number Diff line Loading @@ -294,7 +294,7 @@ public class RoleUserState { } if (changed) { mCallback.onRoleHoldersChanged(roleName, mUserId); mCallback.onRoleHoldersChanged(roleName, mUserId, null, packageName); } return true; } Loading Loading @@ -328,7 +328,7 @@ public class RoleUserState { } if (changed) { mCallback.onRoleHoldersChanged(roleName, mUserId); mCallback.onRoleHoldersChanged(roleName, mUserId, packageName, null); } return true; } Loading Loading @@ -632,6 +632,7 @@ public class RoleUserState { * @param roleName the name of the role whose holders are changed * @param userId the user id for this role holder change */ void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId); void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder); } } telephony/java/com/android/internal/telephony/SmsApplication.java +57 −36 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import android.Manifest.permission; import android.annotation.Nullable; import android.app.AppOpsManager; import android.app.role.RoleManager; import android.content.ComponentName; Loading Loading @@ -662,18 +663,37 @@ public final class SmsApplication { } defaultSmsAppChanged(context); } } /** * Sends broadcasts on sms app change: * {@link Intent#ACTION_DEFAULT_SMS_PACKAGE_CHANGED} * {@link Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL} */ public static void broadcastSmsAppChange(Context context, UserHandle userHandle, @Nullable String oldPackage, @Nullable String newPackage) { Collection<SmsApplicationData> apps = getApplicationCollection(context); broadcastSmsAppChange(context, userHandle, getApplicationForPackage(apps, oldPackage), getApplicationForPackage(apps, newPackage)); } private static void broadcastSmsAppChange(Context context, UserHandle userHandle, @Nullable SmsApplicationData oldAppData, @Nullable SmsApplicationData applicationData) { if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal oldAppData=" + oldAppData); } if (oldAppData != null && oldAppData.mSmsAppChangedReceiverClass != null) { // Notify the old sms app that it's no longer the default final Intent oldAppIntent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); final ComponentName component = new ComponentName(oldAppData.mPackageName, oldAppData.mSmsAppChangedReceiverClass); oldAppIntent.setComponent(component); oldAppIntent.putExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, false); oldAppIntent.putExtra(Intents.EXTRA_IS_DEFAULT_SMS_APP, false); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal old=" + oldAppData.mPackageName); } Loading @@ -685,15 +705,15 @@ public final class SmsApplication { Log.i(LOG_TAG, "setDefaultApplicationInternal new applicationData=" + applicationData); } if (applicationData.mSmsAppChangedReceiverClass != null) { if (applicationData != null && applicationData.mSmsAppChangedReceiverClass != null) { final Intent intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); final ComponentName component = new ComponentName(applicationData.mPackageName, applicationData.mSmsAppChangedReceiverClass); intent.setComponent(component); intent.putExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, true); intent.putExtra(Intents.EXTRA_IS_DEFAULT_SMS_APP, true); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal new=" + packageName); Log.i(LOG_TAG, "setDefaultApplicationInternal new=" + applicationData.mPackageName); } context.sendBroadcastAsUser(intent, userHandle); } Loading @@ -701,10 +721,11 @@ public final class SmsApplication { // Send an implicit broadcast for the system server. // (or anyone with MONITOR_DEFAULT_SMS_PACKAGE, really.) final Intent intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL); context.sendBroadcastAsUser(intent, userHandle, permission.MONITOR_DEFAULT_SMS_PACKAGE); if (applicationData != null) { MetricsLogger.action(context, MetricsEvent.ACTION_DEFAULT_SMS_APP_CHANGED, applicationData.mPackageName); } Loading Loading
services/core/java/com/android/server/role/RoleManagerService.java +14 −3 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.os.ResultReceiver; import android.os.ShellCallback; import android.os.UserHandle; import android.os.UserManagerInternal; import android.provider.Telephony; import android.service.sms.FinancialSmsService; import android.telephony.IFinancialSmsCallback; import android.text.TextUtils; Loading @@ -60,6 +61,7 @@ import android.util.SparseArray; import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.telephony.SmsApplication; import com.android.internal.util.ArrayUtils; import com.android.internal.util.BitUtils; import com.android.internal.util.CollectionUtils; Loading Loading @@ -377,13 +379,16 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } @Override public void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId) { public void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder) { mListenerHandler.sendMessage(PooledLambda.obtainMessage( RoleManagerService::notifyRoleHoldersChanged, this, roleName, userId)); RoleManagerService::notifyRoleHoldersChanged, this, roleName, userId, removedHolder, addedHolder)); } @WorkerThread private void notifyRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId) { private void notifyRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder) { RemoteCallbackList<IOnRoleHoldersChangedListener> listeners = getListeners(userId); if (listeners != null) { notifyRoleHoldersChangedForListeners(listeners, roleName, userId); Loading @@ -394,6 +399,12 @@ public class RoleManagerService extends SystemService implements RoleUserState.C if (allUsersListeners != null) { notifyRoleHoldersChangedForListeners(allUsersListeners, roleName, userId); } // Legacy: sms app changed broadcasts if (RoleManager.ROLE_SMS.equals(roleName)) { SmsApplication.broadcastSmsAppChange(getContext(), UserHandle.of(userId), removedHolder, addedHolder); } } @WorkerThread Loading
services/core/java/com/android/server/role/RoleUserState.java +4 −3 Original line number Diff line number Diff line Loading @@ -294,7 +294,7 @@ public class RoleUserState { } if (changed) { mCallback.onRoleHoldersChanged(roleName, mUserId); mCallback.onRoleHoldersChanged(roleName, mUserId, null, packageName); } return true; } Loading Loading @@ -328,7 +328,7 @@ public class RoleUserState { } if (changed) { mCallback.onRoleHoldersChanged(roleName, mUserId); mCallback.onRoleHoldersChanged(roleName, mUserId, packageName, null); } return true; } Loading Loading @@ -632,6 +632,7 @@ public class RoleUserState { * @param roleName the name of the role whose holders are changed * @param userId the user id for this role holder change */ void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId); void onRoleHoldersChanged(@NonNull String roleName, @UserIdInt int userId, @Nullable String removedHolder, @Nullable String addedHolder); } }
telephony/java/com/android/internal/telephony/SmsApplication.java +57 −36 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import android.Manifest.permission; import android.annotation.Nullable; import android.app.AppOpsManager; import android.app.role.RoleManager; import android.content.ComponentName; Loading Loading @@ -662,18 +663,37 @@ public final class SmsApplication { } defaultSmsAppChanged(context); } } /** * Sends broadcasts on sms app change: * {@link Intent#ACTION_DEFAULT_SMS_PACKAGE_CHANGED} * {@link Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL} */ public static void broadcastSmsAppChange(Context context, UserHandle userHandle, @Nullable String oldPackage, @Nullable String newPackage) { Collection<SmsApplicationData> apps = getApplicationCollection(context); broadcastSmsAppChange(context, userHandle, getApplicationForPackage(apps, oldPackage), getApplicationForPackage(apps, newPackage)); } private static void broadcastSmsAppChange(Context context, UserHandle userHandle, @Nullable SmsApplicationData oldAppData, @Nullable SmsApplicationData applicationData) { if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal oldAppData=" + oldAppData); } if (oldAppData != null && oldAppData.mSmsAppChangedReceiverClass != null) { // Notify the old sms app that it's no longer the default final Intent oldAppIntent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); final ComponentName component = new ComponentName(oldAppData.mPackageName, oldAppData.mSmsAppChangedReceiverClass); oldAppIntent.setComponent(component); oldAppIntent.putExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, false); oldAppIntent.putExtra(Intents.EXTRA_IS_DEFAULT_SMS_APP, false); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal old=" + oldAppData.mPackageName); } Loading @@ -685,15 +705,15 @@ public final class SmsApplication { Log.i(LOG_TAG, "setDefaultApplicationInternal new applicationData=" + applicationData); } if (applicationData.mSmsAppChangedReceiverClass != null) { if (applicationData != null && applicationData.mSmsAppChangedReceiverClass != null) { final Intent intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED); final ComponentName component = new ComponentName(applicationData.mPackageName, applicationData.mSmsAppChangedReceiverClass); intent.setComponent(component); intent.putExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, true); intent.putExtra(Intents.EXTRA_IS_DEFAULT_SMS_APP, true); if (DEBUG_MULTIUSER) { Log.i(LOG_TAG, "setDefaultApplicationInternal new=" + packageName); Log.i(LOG_TAG, "setDefaultApplicationInternal new=" + applicationData.mPackageName); } context.sendBroadcastAsUser(intent, userHandle); } Loading @@ -701,10 +721,11 @@ public final class SmsApplication { // Send an implicit broadcast for the system server. // (or anyone with MONITOR_DEFAULT_SMS_PACKAGE, really.) final Intent intent = new Intent(Telephony.Sms.Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL); new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL); context.sendBroadcastAsUser(intent, userHandle, permission.MONITOR_DEFAULT_SMS_PACKAGE); if (applicationData != null) { MetricsLogger.action(context, MetricsEvent.ACTION_DEFAULT_SMS_APP_CHANGED, applicationData.mPackageName); } Loading