Merge "Deprecate the pre-defined apps of IM in the ContactsContract."
diff --git a/Android.bp b/Android.bp
index 3d48f22..c017ada 100644
--- a/Android.bp
+++ b/Android.bp
@@ -380,6 +380,7 @@
// etc.
":framework-javastream-protos",
":statslog-framework-java-gen", // FrameworkStatsLog.java
+ ":audio_policy_configuration_V7_0",
],
}
@@ -1363,6 +1364,7 @@
metalava_framework_docs_args = "--manifest $(location core/res/AndroidManifest.xml) " +
"--ignore-classes-on-classpath " +
"--hide-package com.android.server " +
+ "--hide-package android.audio.policy.configuration.V7_0 " +
"--error UnhiddenSystemApi " +
"--hide RequiresPermission " +
"--hide CallbackInterface " +
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9ea7037..05dbf00 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -11048,6 +11048,7 @@
method public int getMtuV4();
method public int getMtuV6();
method @NonNull public java.util.List<java.net.InetAddress> getPcscfAddresses();
+ method public int getPduSessionId();
method public int getProtocolType();
method public long getRetryDurationMillis();
method @Deprecated public int getSuggestedRetryTime();
@@ -11062,6 +11063,7 @@
field public static final int LINK_STATUS_DORMANT = 1; // 0x1
field public static final int LINK_STATUS_INACTIVE = 0; // 0x0
field public static final int LINK_STATUS_UNKNOWN = -1; // 0xffffffff
+ field public static final int PDU_SESSION_ID_NOT_SET = 0; // 0x0
field public static final int RETRY_DURATION_UNDEFINED = -1; // 0xffffffff
}
@@ -11080,6 +11082,7 @@
method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV4(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List<java.net.InetAddress>);
+ method @NonNull public android.telephony.data.DataCallResponse.Builder setPduSessionId(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryDurationMillis(long);
method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int);
@@ -11144,6 +11147,7 @@
public abstract class DataService.DataServiceProvider implements java.lang.AutoCloseable {
ctor public DataService.DataServiceProvider(int);
+ method public void cancelHandover(int, @NonNull android.telephony.data.DataServiceCallback);
method public abstract void close();
method public void deactivateDataCall(int, int, @Nullable android.telephony.data.DataServiceCallback);
method public final int getSlotIndex();
@@ -11152,11 +11156,15 @@
method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @NonNull android.telephony.data.DataServiceCallback);
+ method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @IntRange(from=0, to=15) int, @NonNull android.telephony.data.DataServiceCallback);
+ method public void startHandover(int, @NonNull android.telephony.data.DataServiceCallback);
}
public class DataServiceCallback {
method public void onDataCallListChanged(@NonNull java.util.List<android.telephony.data.DataCallResponse>);
method public void onDeactivateDataCallComplete(int);
+ method public void onHandoverCancelled(int);
+ method public void onHandoverStarted(int);
method public void onRequestDataCallListComplete(int, @NonNull java.util.List<android.telephony.data.DataCallResponse>);
method public void onSetDataProfileComplete(int);
method public void onSetInitialAttachApnComplete(int);
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index f19b704..f695adf 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -935,6 +935,11 @@
package android.media {
+ public final class AudioAttributes implements android.os.Parcelable {
+ method @NonNull public static String usageToXsdString(int);
+ method public static int xsdStringToUsage(@NonNull String);
+ }
+
public final class AudioFocusRequest {
method @Nullable public android.media.AudioManager.OnAudioFocusChangeListener getOnAudioFocusChangeListener();
}
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java
index 717074c..19354e0 100644
--- a/media/java/android/media/AudioAttributes.java
+++ b/media/java/android/media/AudioAttributes.java
@@ -20,6 +20,8 @@
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
+import android.audio.policy.configuration.V7_0.AudioUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.media.audiopolicy.AudioProductStrategy;
import android.os.Build;
@@ -34,7 +36,9 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
@@ -1281,6 +1285,97 @@
}
}
+ /** @hide **/
+ @TestApi
+ @NonNull
+ public static String usageToXsdString(@AttributeUsage int usage) {
+ switch (usage) {
+ case AudioAttributes.USAGE_UNKNOWN:
+ return AudioUsage.AUDIO_USAGE_UNKNOWN.toString();
+ case AudioAttributes.USAGE_MEDIA:
+ return AudioUsage.AUDIO_USAGE_MEDIA.toString();
+ case AudioAttributes.USAGE_VOICE_COMMUNICATION:
+ return AudioUsage.AUDIO_USAGE_VOICE_COMMUNICATION.toString();
+ case AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING:
+ return AudioUsage.AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING.toString();
+ case AudioAttributes.USAGE_ALARM:
+ return AudioUsage.AUDIO_USAGE_ALARM.toString();
+ case AudioAttributes.USAGE_NOTIFICATION:
+ return AudioUsage.AUDIO_USAGE_NOTIFICATION.toString();
+ case AudioAttributes.USAGE_NOTIFICATION_RINGTONE:
+ return AudioUsage.AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE.toString();
+ case AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY:
+ return AudioUsage.AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY.toString();
+ case AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
+ return AudioUsage.AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE.toString();
+ case AudioAttributes.USAGE_ASSISTANCE_SONIFICATION:
+ return AudioUsage.AUDIO_USAGE_ASSISTANCE_SONIFICATION.toString();
+ case AudioAttributes.USAGE_GAME:
+ return AudioUsage.AUDIO_USAGE_GAME.toString();
+ case AudioAttributes.USAGE_VIRTUAL_SOURCE:
+ return AudioUsage.AUDIO_USAGE_VIRTUAL_SOURCE.toString();
+ case AudioAttributes.USAGE_ASSISTANT:
+ return AudioUsage.AUDIO_USAGE_ASSISTANT.toString();
+ case AudioAttributes.USAGE_CALL_ASSISTANT:
+ return AudioUsage.AUDIO_USAGE_CALL_ASSISTANT.toString();
+ case AudioAttributes.USAGE_EMERGENCY:
+ return AudioUsage.AUDIO_USAGE_EMERGENCY.toString();
+ case AudioAttributes.USAGE_SAFETY:
+ return AudioUsage.AUDIO_USAGE_SAFETY.toString();
+ case AudioAttributes.USAGE_VEHICLE_STATUS:
+ return AudioUsage.AUDIO_USAGE_VEHICLE_STATUS.toString();
+ case AudioAttributes.USAGE_ANNOUNCEMENT:
+ return AudioUsage.AUDIO_USAGE_ANNOUNCEMENT.toString();
+ default:
+ Log.w(TAG, "Unknown usage value " + usage);
+ return AudioUsage.AUDIO_USAGE_UNKNOWN.toString();
+ }
+ }
+
+ private static final Map<String, Integer> sXsdStringToUsage = new HashMap<>();
+
+ static {
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_UNKNOWN.toString(), USAGE_UNKNOWN);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_UNKNOWN.toString(), USAGE_UNKNOWN);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_MEDIA.toString(), USAGE_MEDIA);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_VOICE_COMMUNICATION.toString(),
+ USAGE_VOICE_COMMUNICATION);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING.toString(),
+ USAGE_VOICE_COMMUNICATION_SIGNALLING);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ALARM.toString(), USAGE_ALARM);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_NOTIFICATION.toString(), USAGE_NOTIFICATION);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE.toString(),
+ USAGE_NOTIFICATION_RINGTONE);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY.toString(),
+ USAGE_ASSISTANCE_ACCESSIBILITY);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE.toString(),
+ USAGE_ASSISTANCE_NAVIGATION_GUIDANCE);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ASSISTANCE_SONIFICATION.toString(),
+ USAGE_ASSISTANCE_SONIFICATION);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_GAME.toString(), USAGE_GAME);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_VIRTUAL_SOURCE.toString(),
+ USAGE_VIRTUAL_SOURCE);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ASSISTANT.toString(), USAGE_ASSISTANT);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_CALL_ASSISTANT.toString(),
+ USAGE_CALL_ASSISTANT);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_EMERGENCY.toString(), USAGE_EMERGENCY);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_SAFETY.toString(), USAGE_SAFETY);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_VEHICLE_STATUS.toString(),
+ USAGE_VEHICLE_STATUS);
+ sXsdStringToUsage.put(AudioUsage.AUDIO_USAGE_ANNOUNCEMENT.toString(), USAGE_ANNOUNCEMENT);
+ }
+
+ /** @hide **/
+ @TestApi
+ public static @AttributeUsage int xsdStringToUsage(@NonNull String xsdUsage) {
+ if (sXsdStringToUsage.containsKey(xsdUsage)) {
+ return sXsdStringToUsage.get(xsdUsage);
+ } else {
+ Log.w(TAG, "Usage name not found in AudioUsage enum: " + xsdUsage);
+ return USAGE_UNKNOWN;
+ }
+ }
+
/** @hide */
public String contentTypeToString() {
switch(mContentType) {
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestHal.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestHal.java
index 8c9a269..a31bcdc 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestHal.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestHal.java
@@ -78,7 +78,7 @@
}
@Override
- public void invalidateAuthenticatorId(int cookie, HardwareAuthToken hat) {
+ public void invalidateAuthenticatorId(int cookie) {
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestSession.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestSession.java
index d5afd0c..dd9150a 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestSession.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/TestSession.java
@@ -80,7 +80,7 @@
}
@Override
- public void invalidateAuthenticatorId(int cookie, HardwareAuthToken hat) {
+ public void invalidateAuthenticatorId(int cookie) {
}
diff --git a/services/core/java/com/android/server/pm/ShortcutRequestPinProcessor.java b/services/core/java/com/android/server/pm/ShortcutRequestPinProcessor.java
index eae89f0..e21c9c2 100644
--- a/services/core/java/com/android/server/pm/ShortcutRequestPinProcessor.java
+++ b/services/core/java/com/android/server/pm/ShortcutRequestPinProcessor.java
@@ -254,7 +254,8 @@
// Next, validate the incoming shortcut, etc.
final PinItemRequest request;
if (inShortcut != null) {
- request = requestPinShortcutLocked(inShortcut, resultIntent, confirmActivity);
+ request = requestPinShortcutLocked(inShortcut, resultIntent,
+ confirmActivity.first.getPackageName(), confirmActivity.second);
} else {
int launcherUid = mService.injectGetPackageUid(
confirmActivity.first.getPackageName(), launcherUserId);
@@ -275,7 +276,7 @@
public Intent createShortcutResultIntent(@NonNull ShortcutInfo inShortcut, int userId) {
// Find the default launcher activity
final int launcherUserId = mService.getParentOrSelfUserId(userId);
- final ComponentName defaultLauncher = mService.getDefaultLauncher(launcherUserId);
+ final String defaultLauncher = mService.getDefaultLauncher(launcherUserId);
if (defaultLauncher == null) {
Log.e(TAG, "Default launcher not found.");
return null;
@@ -286,8 +287,8 @@
mService.throwIfUserLockedL(launcherUserId);
// Next, validate the incoming shortcut, etc.
- final PinItemRequest request = requestPinShortcutLocked(inShortcut, null,
- Pair.create(defaultLauncher, launcherUserId));
+ final PinItemRequest request = requestPinShortcutLocked(inShortcut, null, defaultLauncher,
+ launcherUserId);
return new Intent().putExtra(LauncherApps.EXTRA_PIN_ITEM_REQUEST, request);
}
@@ -296,7 +297,7 @@
*/
@NonNull
private PinItemRequest requestPinShortcutLocked(ShortcutInfo inShortcut,
- IntentSender resultIntentOriginal, Pair<ComponentName, Integer> confirmActivity) {
+ IntentSender resultIntentOriginal, String launcherPackage, int launcherUserId) {
final ShortcutPackage ps = mService.getPackageShortcutsForPublisherLocked(
inShortcut.getPackage(), inShortcut.getUserId());
@@ -313,8 +314,6 @@
// This is the shortcut that'll be sent to the launcher.
final ShortcutInfo shortcutForLauncher;
- final String launcherPackage = confirmActivity.first.getPackageName();
- final int launcherUserId = confirmActivity.second;
IntentSender resultIntentToSend = resultIntentOriginal;
@@ -419,14 +418,14 @@
int callingUserId, int requestType) {
// Find the default launcher.
final int launcherUserId = mService.getParentOrSelfUserId(callingUserId);
- final ComponentName defaultLauncher = mService.getDefaultLauncher(launcherUserId);
+ final String defaultLauncher = mService.getDefaultLauncher(launcherUserId);
if (defaultLauncher == null) {
Log.e(TAG, "Default launcher not found.");
return null;
}
final ComponentName activity = mService.injectGetPinConfirmationActivity(
- defaultLauncher.getPackageName(), launcherUserId, requestType);
+ defaultLauncher, launcherUserId, requestType);
return (activity == null) ? null : Pair.create(activity, launcherUserId);
}
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index e471ac6..d7c46a5 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -26,6 +26,8 @@
import android.app.IUidObserver;
import android.app.IUriGrantsManager;
import android.app.UriGrantsManager;
+import android.app.role.OnRoleHoldersChangedListener;
+import android.app.role.RoleManager;
import android.app.usage.UsageStatsManagerInternal;
import android.appwidget.AppWidgetProviderInfo;
import android.content.BroadcastReceiver;
@@ -108,7 +110,6 @@
import com.android.internal.util.StatLogger;
import com.android.server.LocalServices;
import com.android.server.SystemService;
-import com.android.server.SystemService.TargetUser;
import com.android.server.pm.ShortcutUser.PackageWithUser;
import com.android.server.uri.UriGrantsManagerInternal;
@@ -347,6 +348,7 @@
private final IUriGrantsManager mUriGrantsManager;
private final UriGrantsManagerInternal mUriGrantsManagerInternal;
private final IBinder mUriPermissionOwner;
+ private final RoleManager mRoleManager;
private final ShortcutRequestPinProcessor mShortcutRequestPinProcessor;
private final ShortcutBitmapSaver mShortcutBitmapSaver;
@@ -464,10 +466,11 @@
mActivityManagerInternal = Objects.requireNonNull(
LocalServices.getService(ActivityManagerInternal.class));
- mUriGrantsManager = UriGrantsManager.getService();
+ mUriGrantsManager = Objects.requireNonNull(UriGrantsManager.getService());
mUriGrantsManagerInternal = Objects.requireNonNull(
LocalServices.getService(UriGrantsManagerInternal.class));
mUriPermissionOwner = mUriGrantsManagerInternal.newUriPermissionOwner(TAG);
+ mRoleManager = Objects.requireNonNull(mContext.getSystemService(RoleManager.class));
mShortcutRequestPinProcessor = new ShortcutRequestPinProcessor(this, mLock);
mShortcutBitmapSaver = new ShortcutBitmapSaver(this);
@@ -491,12 +494,6 @@
mContext.registerReceiverAsUser(mPackageMonitor, UserHandle.ALL,
packageFilter, null, mHandler);
- final IntentFilter preferedActivityFilter = new IntentFilter();
- preferedActivityFilter.addAction(Intent.ACTION_PREFERRED_ACTIVITY_CHANGED);
- preferedActivityFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
- mContext.registerReceiverAsUser(mPackageMonitor, UserHandle.ALL,
- preferedActivityFilter, null, mHandler);
-
final IntentFilter localeFilter = new IntentFilter();
localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
localeFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
@@ -505,6 +502,8 @@
injectRegisterUidObserver(mUidObserver, ActivityManager.UID_OBSERVER_PROCSTATE
| ActivityManager.UID_OBSERVER_GONE);
+
+ injectRegisterRoleHoldersListener(mOnRoleHoldersChangedListener);
}
long getStatStartTime() {
@@ -520,6 +519,31 @@
return LocaleList.getDefault().toLanguageTags();
}
+ private final OnRoleHoldersChangedListener mOnRoleHoldersChangedListener =
+ new OnRoleHoldersChangedListener() {
+ @Override
+ public void onRoleHoldersChanged(String roleName, UserHandle user) {
+ if (RoleManager.ROLE_HOME.equals(roleName)) {
+ injectPostToHandler(() -> handleOnDefaultLauncherChanged(user.getIdentifier()));
+ }
+ }
+ };
+
+ void handleOnDefaultLauncherChanged(int userId) {
+ if (DEBUG) {
+ Slog.v(TAG, "Default launcher changed for user: " + userId);
+ }
+
+ // Default launcher is removed or changed, revoke all URI permissions.
+ mUriGrantsManagerInternal.revokeUriPermissionFromOwner(mUriPermissionOwner, null, ~0, 0);
+
+ synchronized (mLock) {
+ // Clear the launcher cache for this user. It will be set again next time the default
+ // launcher is read from RoleManager.
+ getUserShortcutsLocked(userId).setCachedLauncher(null);
+ }
+ }
+
final private IUidObserver mUidObserver = new IUidObserver.Stub() {
@Override
public void onUidStateChanged(int uid, int procState, long procStateSeq, int capability) {
@@ -2681,35 +2705,21 @@
synchronized (mLock) {
throwIfUserLockedL(userId);
- final ShortcutUser user = getUserShortcutsLocked(userId);
+ final String defaultLauncher = getDefaultLauncher(userId);
- // Always trust the cached component.
- final ComponentName cached = user.getCachedLauncher();
- if (cached != null) {
- if (cached.getPackageName().equals(packageName)) {
- return true;
- }
- }
- // If the cached one doesn't match, then go ahead
-
- final ComponentName detected = getDefaultLauncher(userId);
-
- // Update the cache.
- user.setLauncher(detected);
- if (detected != null) {
+ if (defaultLauncher != null) {
if (DEBUG) {
- Slog.v(TAG, "Detected launcher: " + detected);
+ Slog.v(TAG, "Detected launcher: " + defaultLauncher + " user: " + userId);
}
- return detected.getPackageName().equals(packageName);
+ return defaultLauncher.equals(packageName);
} else {
- // Default launcher not found.
return false;
}
}
}
@Nullable
- ComponentName getDefaultLauncher(@UserIdInt int userId) {
+ String getDefaultLauncher(@UserIdInt int userId) {
final long start = getStatStartTime();
final long token = injectClearCallingIdentity();
try {
@@ -2717,64 +2727,27 @@
throwIfUserLockedL(userId);
final ShortcutUser user = getUserShortcutsLocked(userId);
+ String cachedLauncher = user.getCachedLauncher();
+ if (cachedLauncher != null) {
+ return cachedLauncher;
+ }
- final List<ResolveInfo> allHomeCandidates = new ArrayList<>();
+ // Default launcher from role manager.
+ final long startGetHomeRoleHoldersAsUser = getStatStartTime();
+ final String defaultLauncher = injectGetHomeRoleHolderAsUser(userId);
+ logDurationStat(Stats.GET_DEFAULT_HOME, startGetHomeRoleHoldersAsUser);
- // Default launcher from package manager.
- final long startGetHomeActivitiesAsUser = getStatStartTime();
- final ComponentName defaultLauncher = mPackageManagerInternal
- .getHomeActivitiesAsUser(allHomeCandidates, userId);
- logDurationStat(Stats.GET_DEFAULT_HOME, startGetHomeActivitiesAsUser);
-
- ComponentName detected = null;
if (defaultLauncher != null) {
- detected = defaultLauncher;
if (DEBUG) {
- Slog.v(TAG, "Default launcher from PM: " + detected);
+ Slog.v(TAG, "Default launcher from RoleManager: " + defaultLauncher
+ + " user: " + userId);
}
+ user.setCachedLauncher(defaultLauncher);
} else {
- detected = user.getLastKnownLauncher();
-
- if (detected != null) {
- if (injectIsActivityEnabledAndExported(detected, userId)) {
- if (DEBUG) {
- Slog.v(TAG, "Cached launcher: " + detected);
- }
- } else {
- Slog.w(TAG, "Cached launcher " + detected + " no longer exists");
- detected = null;
- user.clearLauncher();
- }
- }
+ Slog.e(TAG, "Default launcher not found." + " user: " + userId);
}
- if (detected == null) {
- // If we reach here, that means it's the first check since the user was created,
- // and there's already multiple launchers and there's no default set.
- // Find the system one with the highest priority.
- // (We need to check the priority too because of FallbackHome in Settings.)
- // If there's no system launcher yet, then no one can access shortcuts, until
- // the user explicitly
- final int size = allHomeCandidates.size();
-
- int lastPriority = Integer.MIN_VALUE;
- for (int i = 0; i < size; i++) {
- final ResolveInfo ri = allHomeCandidates.get(i);
- if (!ri.activityInfo.applicationInfo.isSystemApp()) {
- continue;
- }
- if (DEBUG) {
- Slog.d(TAG, String.format("hasShortcutPermissionInner: pkg=%s prio=%d",
- ri.activityInfo.getComponentName(), ri.priority));
- }
- if (ri.priority < lastPriority) {
- continue;
- }
- detected = ri.activityInfo.getComponentName();
- lastPriority = ri.priority;
- }
- }
- return detected;
+ return defaultLauncher;
}
} finally {
injectRestoreCallingIdentity(token);
@@ -3351,11 +3324,11 @@
Objects.requireNonNull(callingPackage);
final int userId = UserHandle.getUserId(callingUid);
- final ComponentName defaultLauncher = getDefaultLauncher(userId);
+ final String defaultLauncher = getDefaultLauncher(userId);
if (defaultLauncher == null) {
return false;
}
- if (!callingPackage.equals(defaultLauncher.getPackageName())) {
+ if (!callingPackage.equals(defaultLauncher)) {
return false;
}
synchronized (mLock) {
@@ -3426,22 +3399,6 @@
}
return;
}
-
- // Whenever we get one of those package broadcasts, or get
- // ACTION_PREFERRED_ACTIVITY_CHANGED, we purge the default launcher cache.
- final ShortcutUser user = getUserShortcutsLocked(userId);
- user.clearLauncher();
- }
- if (Intent.ACTION_PREFERRED_ACTIVITY_CHANGED.equals(action)) {
- final ShortcutUser user = getUserShortcutsLocked(userId);
- final ComponentName lastLauncher = user.getLastKnownLauncher();
- final ComponentName currentLauncher = getDefaultLauncher(userId);
- if (currentLauncher == null || !currentLauncher.equals(lastLauncher)) {
- // Default launcher is removed or changed, revoke all URI permissions.
- mUriGrantsManagerInternal.revokeUriPermissionFromOwner(mUriPermissionOwner,
- null, ~0, 0);
- }
- return;
}
final Uri intentUri = intent.getData();
@@ -4629,9 +4586,6 @@
case "reset-config":
handleResetConfig();
break;
- case "clear-default-launcher":
- handleClearDefaultLauncher();
- break;
case "get-default-launcher":
handleGetDefaultLauncher();
break;
@@ -4672,11 +4626,10 @@
pw.println("cmd shortcut reset-config");
pw.println(" Reset the configuration set with \"update-config\"");
pw.println();
- pw.println("cmd shortcut clear-default-launcher [--user USER_ID]");
- pw.println(" Clear the cached default launcher");
- pw.println();
- pw.println("cmd shortcut get-default-launcher [--user USER_ID]");
+ pw.println("[Deprecated] cmd shortcut get-default-launcher [--user USER_ID]");
pw.println(" Show the default launcher");
+ pw.println(" Note: This command is deprecated. Callers should query the default"
+ + " launcher directly from RoleManager instead.");
pw.println();
pw.println("cmd shortcut unload-user [--user USER_ID]");
pw.println(" Unload a user from the memory");
@@ -4723,36 +4676,17 @@
}
}
- private void clearLauncher() {
- synchronized (mLock) {
- getUserShortcutsLocked(mUserId).forceClearLauncher();
- }
- }
-
- private void showLauncher() {
- synchronized (mLock) {
- // This ensures to set the cached launcher. Package name doesn't matter.
- hasShortcutHostPermissionInner("-", mUserId);
-
- getOutPrintWriter().println("Launcher: "
- + getUserShortcutsLocked(mUserId).getLastKnownLauncher());
- }
- }
-
- private void handleClearDefaultLauncher() throws CommandException {
- synchronized (mLock) {
- parseOptionsLocked(/* takeUser =*/ true);
-
- clearLauncher();
- }
- }
-
+ // This method is used by various cts modules to get the current default launcher. Tests
+ // should query this information directly from RoleManager instead. Keeping the old behavior
+ // by returning the result from package manager.
private void handleGetDefaultLauncher() throws CommandException {
synchronized (mLock) {
parseOptionsLocked(/* takeUser =*/ true);
-
- clearLauncher();
- showLauncher();
+ final List<ResolveInfo> allHomeCandidates = new ArrayList<>();
+ // Default launcher from package manager.
+ final ComponentName defaultLauncher = mPackageManagerInternal
+ .getHomeActivitiesAsUser(allHomeCandidates, mUserId);
+ getOutPrintWriter().println("Launcher: " + defaultLauncher);
}
}
@@ -4881,6 +4815,19 @@
}
}
+ @VisibleForTesting
+ void injectRegisterRoleHoldersListener(OnRoleHoldersChangedListener listener) {
+ mRoleManager.addOnRoleHoldersChangedListenerAsUser(mContext.getMainExecutor(), listener,
+ UserHandle.ALL);
+ }
+
+ @VisibleForTesting
+ String injectGetHomeRoleHolderAsUser(int userId) {
+ List<String> roleHolders = mRoleManager.getRoleHoldersAsUser(
+ RoleManager.ROLE_HOME, UserHandle.of(userId));
+ return roleHolders.isEmpty() ? null : roleHolders.get(0);
+ }
+
File getUserBitmapFilePath(@UserIdInt int userId) {
return new File(injectUserDataPath(userId), DIRECTORY_BITMAPS);
}
diff --git a/services/core/java/com/android/server/pm/ShortcutUser.java b/services/core/java/com/android/server/pm/ShortcutUser.java
index df6d321..5c1d8fb 100644
--- a/services/core/java/com/android/server/pm/ShortcutUser.java
+++ b/services/core/java/com/android/server/pm/ShortcutUser.java
@@ -18,7 +18,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
-import android.content.ComponentName;
import android.content.pm.ShortcutManager;
import android.metrics.LogMaker;
import android.os.FileUtils;
@@ -119,15 +118,8 @@
private final ArrayMap<PackageWithUser, ShortcutLauncher> mLaunchers = new ArrayMap<>();
- /**
- * Last known launcher. It's used when the default launcher isn't set in PM -- i.e.
- * when getHomeActivitiesAsUser() return null. We need it so that in this situation the
- * previously default launcher can still access shortcuts.
- */
- private ComponentName mLastKnownLauncher;
-
/** In-memory-cached default launcher. */
- private ComponentName mCachedLauncher;
+ private String mCachedLauncher;
private String mKnownLocales;
@@ -350,8 +342,6 @@
mLastAppScanOsFingerprint);
ShortcutService.writeAttr(out, ATTR_RESTORE_SOURCE_FINGERPRINT,
mRestoreFromOsFingerprint);
-
- ShortcutService.writeTagValue(out, TAG_LAUNCHER, mLastKnownLauncher);
} else {
ShortcutService.writeAttr(out, ATTR_RESTORE_SOURCE_FINGERPRINT,
mService.injectBuildFingerprint());
@@ -448,11 +438,6 @@
if (depth == outerDepth + 1) {
switch (tag) {
- case TAG_LAUNCHER: {
- ret.mLastKnownLauncher = ShortcutService.parseComponentNameAttribute(
- parser, ATTR_VALUE);
- continue;
- }
case ShortcutPackage.TAG_ROOT: {
final ShortcutPackage shortcuts = ShortcutPackage.loadFromXml(
s, ret, parser, fromBackup);
@@ -515,41 +500,11 @@
}
}
- public ComponentName getLastKnownLauncher() {
- return mLastKnownLauncher;
+ public void setCachedLauncher(String launcher) {
+ mCachedLauncher = launcher;
}
- public void setLauncher(ComponentName launcherComponent) {
- setLauncher(launcherComponent, /* allowPurgeLastKnown */ false);
- }
-
- /** Clears the launcher information without clearing the last known one */
- public void clearLauncher() {
- setLauncher(null);
- }
-
- /**
- * Clears the launcher information *with(* clearing the last known one; we do this witl
- * "cmd shortcut clear-default-launcher".
- */
- public void forceClearLauncher() {
- setLauncher(null, /* allowPurgeLastKnown */ true);
- }
-
- private void setLauncher(ComponentName launcherComponent, boolean allowPurgeLastKnown) {
- mCachedLauncher = launcherComponent; // Always update the in-memory cache.
-
- if (Objects.equals(mLastKnownLauncher, launcherComponent)) {
- return;
- }
- if (!allowPurgeLastKnown && launcherComponent == null) {
- return;
- }
- mLastKnownLauncher = launcherComponent;
- mService.scheduleSaveUser(mUserId);
- }
-
- public ComponentName getCachedLauncher() {
+ public String getCachedLauncher() {
return mCachedLauncher;
}
@@ -640,16 +595,10 @@
pw.print(mRestoreFromOsFingerprint);
pw.println();
-
pw.print(prefix);
pw.print("Cached launcher: ");
pw.print(mCachedLauncher);
pw.println();
-
- pw.print(prefix);
- pw.print("Last known launcher: ");
- pw.print(mLastKnownLauncher);
- pw.println();
}
for (int i = 0; i < mLaunchers.size(); i++) {
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 3b91d6a..b1035e3 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -4019,15 +4019,13 @@
if (removeUser(userId)) {
return UserManager.REMOVE_RESULT_REMOVED;
}
-
- Slog.w(LOG_TAG, "Unable to immediately remove non-current user: " + userId
- + ". User is still set as ephemeral and will be removed on user "
- + "switch or reboot.");
}
-
// If the user was not immediately removed, make sure it is marked as ephemeral.
// Don't mark as disabled since, per UserInfo.FLAG_DISABLED documentation, an
// ephemeral user should only be marked as disabled when its removal is in progress.
+ Slog.i(LOG_TAG, "Unable to immediately remove user " + userId + " (current user is "
+ + currentUser + "). User is set as ephemeral and will be removed on user "
+ + "switch or reboot.");
userData.info.flags |= UserInfo.FLAG_EPHEMERAL;
writeUserLP(userData);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 9b91e3a..8cbeccd 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2575,7 +2575,7 @@
WindowSurfaceController surfaceController;
try {
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "createSurfaceControl");
- surfaceController = winAnimator.createSurfaceLocked(win.mAttrs.type, win.mOwnerUid);
+ surfaceController = winAnimator.createSurfaceLocked(win.mAttrs.type);
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 0fd8146..9cc72a2 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -420,7 +420,7 @@
}
}
- WindowSurfaceController createSurfaceLocked(int windowType, int ownerUid) {
+ WindowSurfaceController createSurfaceLocked(int windowType) {
final WindowState w = mWin;
if (mSurfaceController != null) {
@@ -480,7 +480,7 @@
}
mSurfaceController = new WindowSurfaceController(attrs.getTitle().toString(), width,
- height, format, flags, this, windowType, ownerUid);
+ height, format, flags, this, windowType);
mSurfaceController.setColorSpaceAgnostic((attrs.privateFlags
& WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC) != 0);
diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java
index db93c89..ec79c59 100644
--- a/services/core/java/com/android/server/wm/WindowSurfaceController.java
+++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java
@@ -82,7 +82,7 @@
boolean mChildrenDetached;
WindowSurfaceController(String name, int w, int h, int format,
- int flags, WindowStateAnimator animator, int windowType, int ownerUid) {
+ int flags, WindowStateAnimator animator, int windowType) {
mAnimator = animator;
mSurfaceW = w;
@@ -104,7 +104,7 @@
.setFormat(format)
.setFlags(flags)
.setMetadata(METADATA_WINDOW_TYPE, windowType)
- .setMetadata(METADATA_OWNER_UID, ownerUid)
+ .setMetadata(METADATA_OWNER_UID, mWindowSession.mUid)
.setMetadata(METADATA_OWNER_PID, mWindowSession.mPid)
.setCallsite("WindowSurfaceController");
diff --git a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
index f78c01a..c4d185c 100644
--- a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
@@ -45,6 +45,7 @@
import android.app.IUidObserver;
import android.app.Person;
import android.app.admin.DevicePolicyManager;
+import android.app.role.OnRoleHoldersChangedListener;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
@@ -150,6 +151,10 @@
return mMockUserManager;
case Context.DEVICE_POLICY_SERVICE:
return mMockDevicePolicyManager;
+ case Context.ROLE_SERVICE:
+ // RoleManager is final and cannot be mocked, so we only override the inject
+ // accessor methods in ShortcutService.
+ return getTestContext().getSystemService(name);
}
throw new UnsupportedOperationException("Couldn't find system service: " + name);
}
@@ -355,10 +360,24 @@
}
@Override
- ComponentName getDefaultLauncher(@UserIdInt int userId) {
- final ComponentName activity = mDefaultLauncher.get(userId);
- if (activity != null) {
- return activity;
+ void injectRegisterRoleHoldersListener(OnRoleHoldersChangedListener listener) {
+ // Do nothing.
+ }
+
+ @Override
+ String injectGetHomeRoleHolderAsUser(@UserIdInt int userId) {
+ final String packageName = mHomeRoleHolderAsUser.get(userId);
+ if (packageName != null) {
+ return packageName;
+ }
+ return super.injectGetHomeRoleHolderAsUser(userId);
+ }
+
+ @Override
+ String getDefaultLauncher(@UserIdInt int userId) {
+ final String packageName = mDefaultLauncher.get(userId);
+ if (packageName != null) {
+ return packageName;
}
return super.getDefaultLauncher(userId);
}
@@ -642,6 +661,7 @@
protected UriPermissionOwner mUriPermissionOwner;
+
protected static final String CALLING_PACKAGE_1 = "com.android.test.1";
protected static final int CALLING_UID_1 = 10001;
@@ -708,7 +728,7 @@
LAUNCHER_1.equals(callingPackage) || LAUNCHER_2.equals(callingPackage)
|| LAUNCHER_3.equals(callingPackage) || LAUNCHER_4.equals(callingPackage);
- private final Map<Integer, ComponentName> mDefaultLauncher = new ArrayMap<>();
+ private final Map<Integer, String> mDefaultLauncher = new ArrayMap<>();
protected BiPredicate<ComponentName, Integer> mMainActivityChecker =
(activity, userId) -> true;
@@ -761,6 +781,8 @@
protected boolean mInjectHasUnlimitedShortcutsApiCallsPermission = false;
+ private final Map<Integer, String> mHomeRoleHolderAsUser = new ArrayMap<>();
+
static {
QUERY_ALL.setQueryFlags(
ShortcutQuery.FLAG_GET_ALL_KINDS);
@@ -1293,7 +1315,7 @@
/**
* This controls {@link ShortcutService#hasShortcutHostPermission}, but
* not {@link ShortcutService#getDefaultLauncher(int)}. To control the later, use
- * {@link #setDefaultLauncher(int, ComponentName)}.
+ * {@link #setDefaultLauncher(int, String)}.
*/
protected void setDefaultLauncherChecker(BiPredicate<String, Integer> p) {
mDefaultLauncherChecker = p;
@@ -1303,13 +1325,13 @@
* Set the default launcher. This will update {@link #mDefaultLauncherChecker} set by
* {@link #setDefaultLauncherChecker} too.
*/
- protected void setDefaultLauncher(int userId, ComponentName launcherActivity) {
- mDefaultLauncher.put(userId, launcherActivity);
+ protected void setDefaultLauncher(int userId, String launcherPackage) {
+ mDefaultLauncher.put(userId, launcherPackage);
final BiPredicate<String, Integer> oldChecker = mDefaultLauncherChecker;
mDefaultLauncherChecker = (checkPackageName, checkUserId) -> {
- if ((checkUserId == userId) && (launcherActivity != null)) {
- return launcherActivity.getPackageName().equals(checkPackageName);
+ if ((checkUserId == userId) && (launcherPackage != null)) {
+ return launcherPackage.equals(checkPackageName);
}
return oldChecker.test(checkPackageName, checkUserId);
};
@@ -2267,6 +2289,12 @@
return sb.toString();
}
+ protected void prepareGetRoleHoldersAsUser(String homeRoleHolder, int userId) {
+ mHomeRoleHolderAsUser.put(userId, homeRoleHolder);
+ mService.handleOnDefaultLauncherChanged(userId);
+ }
+
+ // Used for get-default-launcher command which is deprecated. Will remove later.
protected void prepareGetHomeActivitiesAsUser(ComponentName preferred,
List<ResolveInfo> candidates, int userId) {
doAnswer(inv -> {
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
index 90989b9..c7a05ba 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
@@ -3810,9 +3810,6 @@
assertEquals(2, mManager.getRemainingCallCount());
});
- mService.getShortcutsForTest().get(UserHandle.USER_SYSTEM).setLauncher(
- new ComponentName("pkg1", "class"));
-
// Restore.
mService.saveDirtyInfo();
initService();
@@ -3843,9 +3840,6 @@
assertEquals("title2-2", getCallerShortcut("s2").getTitle());
});
- assertEquals("pkg1", mService.getShortcutsForTest().get(UserHandle.USER_SYSTEM)
- .getLastKnownLauncher().getPackageName());
-
// Start another user
mService.handleUnlockUser(USER_10);
@@ -3860,7 +3854,6 @@
assertEquals("title10-1-1", getCallerShortcut("s1").getTitle());
assertEquals("title10-1-2", getCallerShortcut("s2").getTitle());
});
- assertNull(mService.getShortcutsForTest().get(USER_10).getLastKnownLauncher());
// Try stopping the user
mService.handleStopUser(USER_10);
@@ -6440,7 +6433,7 @@
});
// Prepare for requestPinShortcut().
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
mPinConfirmActivityFetcher = (packageName, userId) ->
new ComponentName(packageName, PIN_CONFIRM_ACTIVITY_CLASS);
@@ -6465,7 +6458,7 @@
});
// Now, change the launcher to launcher2, and request pin again.
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_2, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_2);
reset(mServiceContext);
@@ -8514,10 +8507,9 @@
}
public void testIsForegroundDefaultLauncher_true() {
- final ComponentName defaultLauncher = new ComponentName("default", "launcher");
final int uid = 1024;
- setDefaultLauncher(UserHandle.USER_SYSTEM, defaultLauncher);
+ setDefaultLauncher(UserHandle.USER_SYSTEM, "default");
makeUidForeground(uid);
assertTrue(mInternal.isForegroundDefaultLauncher("default", uid));
@@ -8525,20 +8517,18 @@
public void testIsForegroundDefaultLauncher_defaultButNotForeground() {
- final ComponentName defaultLauncher = new ComponentName("default", "launcher");
final int uid = 1024;
- setDefaultLauncher(UserHandle.USER_SYSTEM, defaultLauncher);
+ setDefaultLauncher(UserHandle.USER_SYSTEM, "default");
makeUidBackground(uid);
assertFalse(mInternal.isForegroundDefaultLauncher("default", uid));
}
public void testIsForegroundDefaultLauncher_foregroundButNotDefault() {
- final ComponentName defaultLauncher = new ComponentName("default", "launcher");
final int uid = 1024;
- setDefaultLauncher(UserHandle.USER_SYSTEM, defaultLauncher);
+ setDefaultLauncher(UserHandle.USER_SYSTEM, "default");
makeUidForeground(uid);
assertFalse(mInternal.isForegroundDefaultLauncher("another", uid));
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java
index ae01b40..eceb17a 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest10.java
@@ -51,15 +51,8 @@
return request;
}
- public void testCreateShortcutResult_noDefaultLauncher() {
- runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
- ShortcutInfo s1 = makeShortcut("s1");
- assertNull(mManager.createShortcutResultIntent(s1));
- });
- }
-
public void testCreateShortcutResult_validResult() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcut("s1");
@@ -74,7 +67,7 @@
}
public void testCreateShortcutResult_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertTrue(mManager.setDynamicShortcuts(list(makeShortcut("s1"))));
@@ -107,7 +100,7 @@
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_P0);
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcut("s1");
Intent intent = mManager.createShortcutResultIntent(s1);
@@ -122,7 +115,7 @@
}
public void testCreateShortcutResult_defaultLauncherChanges() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcut("s1");
@@ -130,7 +123,7 @@
mRequest = verifyAndGetCreateShortcutResult(intent);
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_2, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_2);
// Verify that other launcher can't use this request
runWithCaller(LAUNCHER_2, USER_0, () -> {
assertFalse(mRequest.isValid());
@@ -166,7 +159,7 @@
public void testStartConfigActivity_defaultLauncher() {
LauncherActivityInfo info = setupMockActivityInfo();
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(LAUNCHER_1, USER_0, () ->
assertNotNull(mLauncherApps.getShortcutConfigActivityIntent(info))
);
@@ -174,7 +167,7 @@
public void testStartConfigActivity_nonDefaultLauncher() {
LauncherActivityInfo info = setupMockActivityInfo();
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(LAUNCHER_2, USER_0, () ->
assertExpectException(SecurityException.class, null, () ->
mLauncherApps.getShortcutConfigActivityIntent(info))
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest6.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest6.java
index 3684ca0..63df4bc 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest6.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest6.java
@@ -15,199 +15,60 @@
*/
package com.android.server.pm;
-import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doAnswer;
-
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
import android.test.suitebuilder.annotation.SmallTest;
-import java.util.List;
-
/**
* Tests for {@link ShortcutService#hasShortcutHostPermissionInner}, which includes
* {@link ShortcutService#getDefaultLauncher}.
*/
@SmallTest
public class ShortcutManagerTest6 extends BaseShortcutManagerTest {
- public void testHasShortcutHostPermissionInner_systemLauncherOnly() {
- // Preferred isn't set, use the system launcher.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
- list(getSystemLauncher(), getFallbackLauncher()),
- USER_0);
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
-
- // Should be cached.
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- // Also make sure the last known is saved, but the cached is not.
-
- initService();
-
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(null,
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
- }
-
- public void testHasShortcutHostPermissionInner_with3pLauncher() {
- // Preferred isn't set, still use the system launcher.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_0);
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
-
- // Should be cached.
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
- }
-
public void testHasShortcutHostPermissionInner_with3pLauncher_complicated() {
- // Preferred is set. That's the default launcher.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ cn(CALLING_PACKAGE_2, "name"),
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_0);
+ // Set the default launcher.
+ prepareGetRoleHoldersAsUser(CALLING_PACKAGE_2, USER_0);
assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
- // Should be cached.
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
+ // Last known launcher should be set.
+ assertEquals(CALLING_PACKAGE_2,
mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- // Once set, even after the preferred launcher is cleared, SM still allows it to access
- // shortcuts.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_0);
-
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
-
- // Should be cached.
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- // However, if the component has been disabled, then we'll recalculate it.
- mEnabledActivityChecker = (comp, user) -> false;
-
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
-
- mEnabledActivityChecker = (comp, user) -> true;
-
- // Now the preferred changed.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ cn(CALLING_PACKAGE_1, "xyz"),
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_0);
+ // Now the default launcher has changed.
+ prepareGetRoleHoldersAsUser(CALLING_PACKAGE_1, USER_0);
assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- // Should be cached.
- assertEquals(cn(CALLING_PACKAGE_1, "xyz"),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(CALLING_PACKAGE_1, "xyz"),
+ // Last known launcher should be set.
+ assertEquals(CALLING_PACKAGE_1,
mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
+ // Change the default launcher again.
+ prepareGetRoleHoldersAsUser(
+ getSystemLauncher().activityInfo.getComponentName().getPackageName(), USER_0);
- // As long as there's the cached launcher set, even if getHomeActivitiesAsUser()
- // returns different values, the cached one is still the default.
- prepareGetHomeActivitiesAsUser(
- /* preferred */ getSystemLauncher().activityInfo.getComponentName(),
- list(getSystemLauncher(), getFallbackLauncher()),
- USER_0);
-
- assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
-
- // Cached ones haven't changed.
- assertEquals(cn(CALLING_PACKAGE_1, "xyz"),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(CALLING_PACKAGE_1, "xyz"),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- // However, now the "real" default launcher is the system one. So if the system
- // launcher asks for shortcuts, we'll allow it.
assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
-
- // Since the cache is updated, CALLING_PACKAGE_1 no longer has the permission.
assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
- // Cached ones haven't changed.
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
+ // Last known launcher should be set to default.
+ assertEquals(PACKAGE_SYSTEM_LAUNCHER,
mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
}
public void testHasShortcutHostPermissionInner_multiUser() {
mRunningUsers.put(USER_10, true);
- prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
- list(getSystemLauncher(), getFallbackLauncher()),
- USER_0);
+ prepareGetRoleHoldersAsUser(PACKAGE_FALLBACK_LAUNCHER, USER_0);
+ prepareGetRoleHoldersAsUser(CALLING_PACKAGE_2, USER_10);
- prepareGetHomeActivitiesAsUser(
- /* preferred */ cn(CALLING_PACKAGE_2, "name"),
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_10);
-
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
+ assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
+ assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_FALLBACK_LAUNCHER, USER_0));
assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_0));
assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_0));
- // Check the cache.
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getLastKnownLauncher());
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
+ // Last known launcher should be set.
+ assertEquals(PACKAGE_FALLBACK_LAUNCHER,
mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
assertFalse(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_10));
@@ -215,68 +76,8 @@
assertFalse(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_1, USER_10));
assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_10));
- // Check the cache.
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_10).getLastKnownLauncher());
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
+ // Last known launcher should be set.
+ assertEquals(CALLING_PACKAGE_2,
mService.getUserShortcutsLocked(USER_10).getCachedLauncher());
}
-
- public void testHasShortcutHostPermissionInner_clearCache() {
- mRunningUsers.put(USER_10, true);
-
- prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
- list(getSystemLauncher(), getFallbackLauncher()),
- USER_0);
-
- prepareGetHomeActivitiesAsUser(
- /* preferred */ cn(CALLING_PACKAGE_2, "name"),
- list(getSystemLauncher(), getFallbackLauncher(),
- ri(CALLING_PACKAGE_1, "name", false, 0),
- ri(CALLING_PACKAGE_2, "name", false, 0)
- ),
- USER_10);
-
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
- assertTrue(mService.hasShortcutHostPermissionInner(CALLING_PACKAGE_2, USER_10));
-
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_10).getCachedLauncher());
-
- // Test it on a non-running user.
- // Send ACTION_PREFERRED_ACTIVITY_CHANGED on user 10.
- // But the user is not running, so will be ignored.
- mRunningUsers.put(USER_10, false);
-
- mService.mPackageMonitor.onReceive(mServiceContext,
- new Intent(Intent.ACTION_PREFERRED_ACTIVITY_CHANGED).putExtra(
- Intent.EXTRA_USER_HANDLE, USER_10));
-
- // Need to run the user again to access the internal status.
- mRunningUsers.put(USER_10, true);
-
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- assertEquals(cn(CALLING_PACKAGE_2, "name"),
- mService.getUserShortcutsLocked(USER_10).getCachedLauncher());
-
- // Send it again after starting the user.
- mRunningUsers.put(USER_10, true);
- mService.mPackageMonitor.onReceive(mServiceContext,
- new Intent(Intent.ACTION_PREFERRED_ACTIVITY_CHANGED).putExtra(
- Intent.EXTRA_USER_HANDLE, USER_10));
-
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
- // Only user-10's cache is cleared.
- assertEquals(null,
- mService.getUserShortcutsLocked(USER_10).getCachedLauncher());
-
- }
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest7.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest7.java
index da641b9..e6c3d7c 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest7.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest7.java
@@ -213,9 +213,10 @@
});
}
+ // This command is deprecated. Will remove the test later.
public void testLauncherCommands() throws Exception {
prepareGetHomeActivitiesAsUser(
- /* preferred */ null,
+ /* preferred */ getSystemLauncher().activityInfo.getComponentName(),
list(getSystemLauncher(), getFallbackLauncher()),
USER_0);
@@ -227,10 +228,7 @@
),
USER_10);
- assertTrue(mService.hasShortcutHostPermissionInner(PACKAGE_SYSTEM_LAUNCHER, USER_0));
-
// First, test "get".
-
mRunningUsers.put(USER_10, true);
mUnlockedUsers.put(USER_10, true);
mInjectedCallingUid = Process.SHELL_UID;
@@ -242,23 +240,10 @@
assertSuccess(callShellCommand("get-default-launcher", "--user", "10")),
"Launcher: ComponentInfo{com.android.test.2/name}");
- // Next, test "clear".
- assertSuccess(callShellCommand("clear-default-launcher", "--user", "10"));
-
- // User-10's launcher should be cleared.
- assertEquals(null, mService.getUserShortcutsLocked(USER_10).getLastKnownLauncher());
- assertEquals(null, mService.getUserShortcutsLocked(USER_10).getCachedLauncher());
-
- // but user'0's shouldn't.
- assertEquals(cn(PACKAGE_SYSTEM_LAUNCHER, PACKAGE_SYSTEM_LAUNCHER_NAME),
- mService.getUserShortcutsLocked(USER_0).getCachedLauncher());
-
// Change user-0's launcher.
prepareGetHomeActivitiesAsUser(
/* preferred */ cn(CALLING_PACKAGE_1, "name"),
- list(
- ri(CALLING_PACKAGE_1, "name", false, 0)
- ),
+ list(ri(CALLING_PACKAGE_1, "name", false, 0)),
USER_0);
assertContains(
assertSuccess(callShellCommand("get-default-launcher")),
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest8.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest8.java
index 8a489d2..12e6786 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest8.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest8.java
@@ -89,8 +89,8 @@
}
public void testIsRequestPinShortcutSupported() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
- setDefaultLauncher(USER_10, mMainActivityFetcher.apply(LAUNCHER_2, USER_10));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
+ setDefaultLauncher(USER_10, LAUNCHER_2);
Pair<ComponentName, Integer> actual;
// User 0
@@ -167,7 +167,7 @@
public void testRequestPinShortcut_notSupported() {
// User-0's launcher has no confirmation activity.
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
mPinConfirmActivityFetcher = (packageName, userId) ->
!LAUNCHER_2.equals(packageName)
@@ -220,7 +220,7 @@
}
public void testNotForeground() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
makeCallerBackground();
@@ -249,8 +249,8 @@
* - Shortcut doesn't pre-exist.
*/
private void checkRequestPinShortcut(@Nullable IntentSender resultIntent) {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
- setDefaultLauncher(USER_10, mMainActivityFetcher.apply(LAUNCHER_2, USER_10));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
+ setDefaultLauncher(USER_10, LAUNCHER_2);
final Icon res32x32 = Icon.createWithResource(getTestContext(), R.drawable.black_32x32);
@@ -332,8 +332,8 @@
}
public void testRequestPinShortcut_explicitTargetActivity() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
- setDefaultLauncher(USER_10, mMainActivityFetcher.apply(LAUNCHER_2, USER_10));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
+ setDefaultLauncher(USER_10, LAUNCHER_2);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcutWithActivity("s1",
@@ -388,7 +388,7 @@
}
public void testRequestPinShortcut_wrongTargetActivity() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
// Create dynamic shortcut
@@ -406,8 +406,8 @@
}
public void testRequestPinShortcut_noTargetActivity_noMainActivity() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
- setDefaultLauncher(USER_10, mMainActivityFetcher.apply(LAUNCHER_2, USER_10));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
+ setDefaultLauncher(USER_10, LAUNCHER_2);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
/// Create a shortcut with no target activity.
@@ -471,7 +471,7 @@
}
public void testRequestPinShortcut_dynamicExists() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
final Icon res32x32 = Icon.createWithResource(getTestContext(), R.drawable.black_32x32);
@@ -529,7 +529,7 @@
}
public void testRequestPinShortcut_manifestExists() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -586,7 +586,7 @@
}
public void testRequestPinShortcut_dynamicExists_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
final Icon res32x32 = Icon.createWithResource(getTestContext(), R.drawable.black_32x32);
@@ -671,7 +671,7 @@
}
public void testRequestPinShortcut_manifestExists_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -753,7 +753,7 @@
}
public void testRequestPinShortcut_wasDynamic_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertTrue(mManager.setDynamicShortcuts(list(makeShortcut("s1"))));
@@ -781,7 +781,7 @@
}
public void testRequestPinShortcut_wasDynamic_disabled_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertTrue(mManager.setDynamicShortcuts(list(makeShortcut("s1"))));
@@ -812,7 +812,7 @@
}
public void testRequestPinShortcut_wasManifest_alreadyPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -854,7 +854,7 @@
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_P0);
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertWith(getCallerShortcuts())
@@ -916,7 +916,7 @@
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("ms1"), HANDLE_USER_P0);
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertWith(getCallerShortcuts())
@@ -975,7 +975,7 @@
* the existing one.
*/
public void testRequestPinShortcut_launcherAlreadyHasPinned() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
assertTrue(mManager.setDynamicShortcuts(list(makeShortcut("s1"), makeShortcut("s2"))));
@@ -1037,7 +1037,7 @@
* When trying to pin an existing shortcut, the new fields shouldn't override existing fields.
*/
public void testRequestPinShortcut_dynamicExists_titleWontChange() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
final Icon res32x32 = Icon.createWithResource(getTestContext(), R.drawable.black_32x32);
@@ -1102,7 +1102,7 @@
* When trying to pin an existing shortcut, the new fields shouldn't override existing fields.
*/
public void testRequestPinShortcut_manifestExists_titleWontChange() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -1169,7 +1169,7 @@
* has a partial shortcut, accept() should fail.
*/
public void testRequestPinShortcut_dynamicExists_thenRemoved_error() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
// Create dynamic shortcut
@@ -1227,7 +1227,7 @@
* has all the mandatory fields, we can go ahead and still publish it.
*/
public void testRequestPinShortcut_dynamicExists_thenRemoved_okay() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
// Create dynamic shortcut
@@ -1283,7 +1283,7 @@
* has a partial shortcut, accept() should fail.
*/
public void testRequestPinShortcut_manifestExists_thenRemoved_error() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -1340,7 +1340,7 @@
* has all the mandatory fields, we can go ahead and still publish it.
*/
public void testRequestPinShortcut_manifestExists_thenRemoved_okay() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -1400,7 +1400,7 @@
* has a partial shortcut, accept() should fail.
*/
public void testRequestPinShortcut_dynamicExists_thenDisabled_error() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcut("s1");
@@ -1414,7 +1414,7 @@
// Then, pin by another launcher and disable it.
// We have to pin it here so that disable() won't remove it.
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_2, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_2);
runWithCaller(LAUNCHER_2, USER_0, () -> {
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("s1"), HANDLE_USER_P0);
});
@@ -1426,7 +1426,7 @@
.areAllDisabled();
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(LAUNCHER_1, USER_0, () -> {
// Check the intent passed to startActivityAsUser().
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
@@ -1474,7 +1474,7 @@
* has a partial shortcut, accept() should fail.
*/
public void testRequestPinShortcut_manifestExists_thenDisabled_error() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
publishManifestShortcutsAsCaller(R.xml.shortcut_1);
@@ -1487,7 +1487,7 @@
// Then, pin by another launcher and disable it.
// We have to pin it here so that disable() won't remove it.
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_2, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_2);
runWithCaller(LAUNCHER_2, USER_0, () -> {
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("ms1"), HANDLE_USER_P0);
});
@@ -1500,7 +1500,7 @@
.areAllDisabled();
});
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(LAUNCHER_1, USER_0, () -> {
// Check the intent passed to startActivityAsUser().
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
@@ -1546,7 +1546,7 @@
}
public void testRequestPinShortcut_wrongLauncherCannotAccept() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
ShortcutInfo s1 = makeShortcut("s1");
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest9.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest9.java
index edb9df5..c21a3a7 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest9.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest9.java
@@ -88,7 +88,7 @@
}
public void testNotForeground() {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
makeCallerBackground();
@@ -105,8 +105,8 @@
}
private void checkRequestPinAppWidget(@Nullable PendingIntent resultIntent) {
- setDefaultLauncher(USER_0, mMainActivityFetcher.apply(LAUNCHER_1, USER_0));
- setDefaultLauncher(USER_10, mMainActivityFetcher.apply(LAUNCHER_2, USER_10));
+ setDefaultLauncher(USER_0, LAUNCHER_1);
+ setDefaultLauncher(USER_10, LAUNCHER_2);
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
AppWidgetProviderInfo info = makeProviderInfo("c1");
diff --git a/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java
index 96c69af..907f887 100644
--- a/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java
+++ b/services/tests/shortcutmanagerutils/src/com/android/server/pm/shortcutmanagertest/ShortcutManagerTestUtils.java
@@ -198,7 +198,7 @@
final String POSTFIX = "}";
final List<String> result = runShortcutCommandForSuccess(
instrumentation, "get-default-launcher --user "
- + instrumentation.getContext().getUserId());
+ + instrumentation.getContext().getUserId());
for (String s : result) {
if (s.startsWith(PREFIX) && s.endsWith(POSTFIX)) {
return s.substring(PREFIX.length(), s.length() - POSTFIX.length());
@@ -212,9 +212,6 @@
runCommand(instrumentation, "cmd package set-home-activity --user "
+ instrumentation.getContext().getUserId() + " " + component,
result -> result.contains("Success"));
- runCommand(instrumentation, "cmd shortcut clear-default-launcher --user "
- + instrumentation.getContext().getUserId(),
- result -> result.contains("Success"));
}
public static void setDefaultLauncher(Instrumentation instrumentation, Context packageContext) {
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
index 993e07a..aae7713 100644
--- a/telephony/java/android/telephony/data/DataCallResponse.java
+++ b/telephony/java/android/telephony/data/DataCallResponse.java
@@ -115,6 +115,11 @@
*/
public static final int RETRY_DURATION_UNDEFINED = -1;
+ /**
+ * Indicates that the pdu session id is not set.
+ */
+ public static final int PDU_SESSION_ID_NOT_SET = 0;
+
private final @DataFailureCause int mCause;
private final long mSuggestedRetryTime;
private final int mId;
@@ -129,6 +134,7 @@
private final int mMtuV4;
private final int mMtuV6;
private final @HandoverFailureMode int mHandoverFailureMode;
+ private final int mPduSessionId;
/**
* @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -176,6 +182,7 @@
? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
mMtu = mMtuV4 = mMtuV6 = mtu;
mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
+ mPduSessionId = PDU_SESSION_ID_NOT_SET;
}
private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id,
@@ -183,7 +190,7 @@
@Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
@Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
@Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6,
- @HandoverFailureMode int handoverFailureMode) {
+ @HandoverFailureMode int handoverFailureMode, int pduSessionId) {
mCause = cause;
mSuggestedRetryTime = suggestedRetryTime;
mId = id;
@@ -202,6 +209,7 @@
mMtuV4 = mtuV4;
mMtuV6 = mtuV6;
mHandoverFailureMode = handoverFailureMode;
+ mPduSessionId = pduSessionId;
}
/** @hide */
@@ -225,6 +233,7 @@
mMtuV4 = source.readInt();
mMtuV6 = source.readInt();
mHandoverFailureMode = source.readInt();
+ mPduSessionId = source.readInt();
}
/**
@@ -341,6 +350,13 @@
return mHandoverFailureMode;
}
+ /**
+ * @return The pdu session id
+ */
+ public int getPduSessionId() {
+ return mPduSessionId;
+ }
+
@NonNull
@Override
public String toString() {
@@ -360,6 +376,7 @@
.append(" mtuV4=").append(getMtuV4())
.append(" mtuV6=").append(getMtuV6())
.append(" handoverFailureMode=").append(getHandoverFailureMode())
+ .append(" pduSessionId=").append(getPduSessionId())
.append("}");
return sb.toString();
}
@@ -390,14 +407,15 @@
&& mMtu == other.mMtu
&& mMtuV4 == other.mMtuV4
&& mMtuV6 == other.mMtuV6
- && mHandoverFailureMode == other.mHandoverFailureMode;
+ && mHandoverFailureMode == other.mHandoverFailureMode
+ && mPduSessionId == other.mPduSessionId;
}
@Override
public int hashCode() {
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
- mMtu, mMtuV4, mMtuV6, mHandoverFailureMode);
+ mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
}
@Override
@@ -421,6 +439,7 @@
dest.writeInt(mMtuV4);
dest.writeInt(mMtuV6);
dest.writeInt(mHandoverFailureMode);
+ dest.writeInt(mPduSessionId);
}
public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -498,6 +517,8 @@
private @HandoverFailureMode int mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
+ private int mPduSessionId = PDU_SESSION_ID_NOT_SET;
+
/**
* Default constructor for Builder.
*/
@@ -681,6 +702,17 @@
}
/**
+ * Set pdu session id.
+ *
+ * @param pduSessionId Pdu Session Id of the data call.
+ * @return The same instance of the builder.
+ */
+ public @NonNull Builder setPduSessionId(int pduSessionId) {
+ mPduSessionId = pduSessionId;
+ return this;
+ }
+
+ /**
* Build the DataCallResponse.
*
* @return the DataCallResponse object.
@@ -688,7 +720,7 @@
public @NonNull DataCallResponse build() {
return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
- mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode);
+ mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
}
}
}
diff --git a/telephony/java/android/telephony/data/DataService.java b/telephony/java/android/telephony/data/DataService.java
index f56bbe1..7768597 100644
--- a/telephony/java/android/telephony/data/DataService.java
+++ b/telephony/java/android/telephony/data/DataService.java
@@ -17,6 +17,7 @@
package android.telephony.data;
import android.annotation.IntDef;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -30,7 +31,7 @@
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
-import android.telephony.AccessNetworkConstants;
+import android.util.Log;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
@@ -104,6 +105,8 @@
private static final int DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED = 9;
private static final int DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED = 10;
private static final int DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED = 11;
+ private static final int DATA_SERVICE_REQUEST_START_HANDOVER = 12;
+ private static final int DATA_SERVICE_REQUEST_CANCEL_HANDOVER = 13;
private final HandlerThread mHandlerThread;
@@ -147,7 +150,7 @@
* the provided callback to notify the platform.
*
* @param accessNetworkType Access network type that the data call will be established on.
- * Must be one of {@link AccessNetworkConstants.AccessNetworkType}.
+ * Must be one of {@link android.telephony.AccessNetworkConstants.AccessNetworkType}.
* @param dataProfile Data profile used for data call setup. See {@link DataProfile}
* @param isRoaming True if the device is data roaming.
* @param allowRoaming True if data roaming is allowed by the user.
@@ -158,10 +161,9 @@
* @param callback The result callback for this request.
*/
public void setupDataCall(int accessNetworkType, @NonNull DataProfile dataProfile,
- boolean isRoaming, boolean allowRoaming,
- @SetupDataReason int reason,
- @Nullable LinkProperties linkProperties,
- @NonNull DataServiceCallback callback) {
+ boolean isRoaming, boolean allowRoaming,
+ @SetupDataReason int reason, @Nullable LinkProperties linkProperties,
+ @NonNull DataServiceCallback callback) {
// The default implementation is to return unsupported.
if (callback != null) {
callback.onSetupDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED,
@@ -170,6 +172,37 @@
}
/**
+ * Setup a data connection. The data service provider must implement this method to support
+ * establishing a packet data connection. When completed or error, the service must invoke
+ * the provided callback to notify the platform.
+ *
+ * @param accessNetworkType Access network type that the data call will be established on.
+ * Must be one of {@link android.telephony.AccessNetworkConstants.AccessNetworkType}.
+ * @param dataProfile Data profile used for data call setup. See {@link DataProfile}
+ * @param isRoaming True if the device is data roaming.
+ * @param allowRoaming True if data roaming is allowed by the user.
+ * @param reason The reason for data setup. Must be {@link #REQUEST_REASON_NORMAL} or
+ * {@link #REQUEST_REASON_HANDOVER}.
+ * @param linkProperties If {@code reason} is {@link #REQUEST_REASON_HANDOVER}, this is the
+ * link properties of the existing data connection, otherwise null.
+ * @param pduSessionId The pdu session id to be used for this data call.
+ * The standard range of values are 1-15 while 0 means no pdu session id
+ * was attached to this call. Reference: 3GPP TS 24.007 section
+ * 11.2.3.1b.
+ * @param callback The result callback for this request.
+ */
+ public void setupDataCall(int accessNetworkType, @NonNull DataProfile dataProfile,
+ boolean isRoaming, boolean allowRoaming,
+ @SetupDataReason int reason,
+ @Nullable LinkProperties linkProperties,
+ @IntRange(from = 0, to = 15) int pduSessionId,
+ @NonNull DataServiceCallback callback) {
+ /* Call the old version since the new version isn't supported */
+ setupDataCall(accessNetworkType, dataProfile, isRoaming, allowRoaming, reason,
+ linkProperties, callback);
+ }
+
+ /**
* Deactivate a data connection. The data service provider must implement this method to
* support data connection tear down. When completed or error, the service must invoke the
* provided callback to notify the platform.
@@ -224,6 +257,53 @@
}
/**
+ * Indicates that a handover has begun. This is called on the source transport.
+ *
+ * Any resources being transferred cannot be released while a
+ * handover is underway.
+ *
+ * If a handover was unsuccessful, then the framework calls
+ * {@link DataService#cancelHandover}. The target transport retains ownership over any of
+ * the resources being transferred.
+ *
+ * If a handover was successful, the framework calls {@link DataService#deactivateDataCall}
+ * with reason {@link DataService.REQUEST_REASON_HANDOVER}. The target transport now owns
+ * the transferred resources and is responsible for releasing them.
+ *
+ * @param cid The identifier of the data call which is provided in {@link DataCallResponse}
+ * @param callback The result callback for this request.
+ */
+ public void startHandover(int cid, @NonNull DataServiceCallback callback) {
+ // The default implementation is to return unsupported.
+ if (callback != null) {
+ Log.d(TAG, "startHandover: " + cid);
+ callback.onHandoverStarted(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ } else {
+ Log.e(TAG, "startHandover: " + cid + ", callback is null");
+ }
+ }
+
+ /**
+ * Indicates that a handover was cancelled after a call to
+ * {@link DataService#startHandover}. This is called on the source transport.
+ *
+ * Since the handover was unsuccessful, the source transport retains ownership over any of
+ * the resources being transferred and is still responsible for releasing them.
+ *
+ * @param cid The identifier of the data call which is provided in {@link DataCallResponse}
+ * @param callback The result callback for this request.
+ */
+ public void cancelHandover(int cid, @NonNull DataServiceCallback callback) {
+ // The default implementation is to return unsupported.
+ if (callback != null) {
+ Log.d(TAG, "cancelHandover: " + cid);
+ callback.onHandoverCancelled(DataServiceCallback.RESULT_ERROR_UNSUPPORTED);
+ } else {
+ Log.e(TAG, "cancelHandover: " + cid + ", callback is null");
+ }
+ }
+
+ /**
* Get the active data call list.
*
* @param callback The result callback for this request.
@@ -278,16 +358,18 @@
public final boolean allowRoaming;
public final int reason;
public final LinkProperties linkProperties;
+ public final int pduSessionId;
public final IDataServiceCallback callback;
SetupDataCallRequest(int accessNetworkType, DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, LinkProperties linkProperties,
- IDataServiceCallback callback) {
+ int pduSessionId, IDataServiceCallback callback) {
this.accessNetworkType = accessNetworkType;
this.dataProfile = dataProfile;
this.isRoaming = isRoaming;
this.allowRoaming = allowRoaming;
this.linkProperties = linkProperties;
this.reason = reason;
+ this.pduSessionId = pduSessionId;
this.callback = callback;
}
}
@@ -327,6 +409,16 @@
}
}
+ private static final class BeginCancelHandoverRequest {
+ public final int cid;
+ public final IDataServiceCallback callback;
+ BeginCancelHandoverRequest(int cid,
+ IDataServiceCallback callback) {
+ this.cid = cid;
+ this.callback = callback;
+ }
+ }
+
private static final class DataCallListChangedIndication {
public final List<DataCallResponse> dataCallList;
public final IDataServiceCallback callback;
@@ -377,7 +469,7 @@
serviceProvider.setupDataCall(setupDataCallRequest.accessNetworkType,
setupDataCallRequest.dataProfile, setupDataCallRequest.isRoaming,
setupDataCallRequest.allowRoaming, setupDataCallRequest.reason,
- setupDataCallRequest.linkProperties,
+ setupDataCallRequest.linkProperties, setupDataCallRequest.pduSessionId,
(setupDataCallRequest.callback != null)
? new DataServiceCallback(setupDataCallRequest.callback)
: null);
@@ -438,6 +530,20 @@
loge("Failed to call onDataCallListChanged. " + e);
}
break;
+ case DATA_SERVICE_REQUEST_START_HANDOVER:
+ if (serviceProvider == null) break;
+ BeginCancelHandoverRequest bReq = (BeginCancelHandoverRequest) message.obj;
+ serviceProvider.startHandover(bReq.cid,
+ (bReq.callback != null)
+ ? new DataServiceCallback(bReq.callback) : null);
+ break;
+ case DATA_SERVICE_REQUEST_CANCEL_HANDOVER:
+ if (serviceProvider == null) break;
+ BeginCancelHandoverRequest cReq = (BeginCancelHandoverRequest) message.obj;
+ serviceProvider.cancelHandover(cReq.cid,
+ (cReq.callback != null)
+ ? new DataServiceCallback(cReq.callback) : null);
+ break;
}
}
}
@@ -506,11 +612,11 @@
@Override
public void setupDataCall(int slotIndex, int accessNetworkType, DataProfile dataProfile,
- boolean isRoaming, boolean allowRoaming, int reason,
- LinkProperties linkProperties, IDataServiceCallback callback) {
+ boolean isRoaming, boolean allowRoaming, int reason,
+ LinkProperties linkProperties, int pduSessionId, IDataServiceCallback callback) {
mHandler.obtainMessage(DATA_SERVICE_REQUEST_SETUP_DATA_CALL, slotIndex, 0,
new SetupDataCallRequest(accessNetworkType, dataProfile, isRoaming,
- allowRoaming, reason, linkProperties, callback))
+ allowRoaming, reason, linkProperties, pduSessionId, callback))
.sendToTarget();
}
@@ -566,6 +672,29 @@
mHandler.obtainMessage(DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED,
slotIndex, 0, callback).sendToTarget();
}
+
+ @Override
+ public void startHandover(int slotIndex, int cid, IDataServiceCallback callback) {
+ if (callback == null) {
+ loge("startHandover: callback is null");
+ return;
+ }
+ BeginCancelHandoverRequest req = new BeginCancelHandoverRequest(cid, callback);
+ mHandler.obtainMessage(DATA_SERVICE_REQUEST_START_HANDOVER,
+ slotIndex, 0, req)
+ .sendToTarget();
+ }
+
+ @Override
+ public void cancelHandover(int slotIndex, int cid, IDataServiceCallback callback) {
+ if (callback == null) {
+ loge("cancelHandover: callback is null");
+ return;
+ }
+ BeginCancelHandoverRequest req = new BeginCancelHandoverRequest(cid, callback);
+ mHandler.obtainMessage(DATA_SERVICE_REQUEST_CANCEL_HANDOVER,
+ slotIndex, 0, req).sendToTarget();
+ }
}
private void log(String s) {
diff --git a/telephony/java/android/telephony/data/DataServiceCallback.java b/telephony/java/android/telephony/data/DataServiceCallback.java
index 72b68e4..eef0e01 100644
--- a/telephony/java/android/telephony/data/DataServiceCallback.java
+++ b/telephony/java/android/telephony/data/DataServiceCallback.java
@@ -79,7 +79,7 @@
* @param response Setup data call response.
*/
public void onSetupDataCallComplete(@ResultCode int result,
- @Nullable DataCallResponse response) {
+ @Nullable DataCallResponse response) {
if (mCallback != null) {
try {
if (DBG) Rlog.d(TAG, "onSetupDataCallComplete");
@@ -156,7 +156,7 @@
* set it to an empty list.
*/
public void onRequestDataCallListComplete(@ResultCode int result,
- @NonNull List<DataCallResponse> dataCallList) {
+ @NonNull List<DataCallResponse> dataCallList) {
if (mCallback != null) {
try {
mCallback.onRequestDataCallListComplete(result, dataCallList);
@@ -186,4 +186,66 @@
Rlog.e(TAG, "onDataCallListChanged: callback is null!");
}
}
+
+ /**
+ * Called to indicate result for the request {@link DataService#startHandover}.
+ *
+ * @param result The result code. Must be one of the {@link ResultCode}
+ */
+ public void onHandoverStarted(@ResultCode int result) {
+ if (mCallback != null) {
+ try {
+ if (DBG) Rlog.d(TAG, "onHandoverStarted");
+ mCallback.onHandoverStarted(result);
+ } catch (RemoteException e) {
+ Rlog.e(TAG, "Failed to onHandoverStarted on the remote");
+ }
+ } else {
+ Rlog.e(TAG, "onHandoverStarted: callback is null!");
+ }
+ }
+
+ /**
+ * Called to indicate result for the request {@link DataService#cancelHandover}.
+ *
+ * @param result The result code. Must be one of the {@link ResultCode}
+ */
+ public void onHandoverCancelled(@ResultCode int result) {
+ if (mCallback != null) {
+ try {
+ if (DBG) Rlog.d(TAG, "onHandoverCancelled");
+ mCallback.onHandoverCancelled(result);
+ } catch (RemoteException e) {
+ Rlog.e(TAG, "Failed to onHandoverCancelled on the remote");
+ }
+ } else {
+ Rlog.e(TAG, "onHandoverCancelled: callback is null!");
+ }
+ }
+
+ /**
+ * Get the result code as a string
+ *
+ * @param resultCode The result code. Must be one of the {@link ResultCode}
+ * @return the string representation
+ *
+ * @hide
+ */
+ @NonNull
+ public static String resultCodeToString(@DataServiceCallback.ResultCode int resultCode) {
+ switch(resultCode) {
+ case RESULT_SUCCESS:
+ return "RESULT_SUCCESS";
+ case RESULT_ERROR_UNSUPPORTED:
+ return "RESULT_ERROR_UNSUPPORTED";
+ case RESULT_ERROR_INVALID_ARG:
+ return "RESULT_ERROR_INVALID_ARG";
+ case RESULT_ERROR_BUSY:
+ return "RESULT_ERROR_BUSY";
+ case RESULT_ERROR_ILLEGAL_STATE:
+ return "RESULT_ERROR_ILLEGAL_STATE";
+ default:
+ return "Missing case for result code=" + resultCode;
+ }
+ }
}
diff --git a/telephony/java/android/telephony/data/IDataService.aidl b/telephony/java/android/telephony/data/IDataService.aidl
index 9c74dcc..33226fe 100644
--- a/telephony/java/android/telephony/data/IDataService.aidl
+++ b/telephony/java/android/telephony/data/IDataService.aidl
@@ -29,7 +29,7 @@
void removeDataServiceProvider(int slotId);
void setupDataCall(int slotId, int accessNetwork, in DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, in LinkProperties linkProperties,
- IDataServiceCallback callback);
+ int pduSessionId, IDataServiceCallback callback);
void deactivateDataCall(int slotId, int cid, int reason, IDataServiceCallback callback);
void setInitialAttachApn(int slotId, in DataProfile dataProfile, boolean isRoaming,
IDataServiceCallback callback);
@@ -38,4 +38,6 @@
void requestDataCallList(int slotId, IDataServiceCallback callback);
void registerForDataCallListChanged(int slotId, IDataServiceCallback callback);
void unregisterForDataCallListChanged(int slotId, IDataServiceCallback callback);
+ void startHandover(int slotId, int cid, IDataServiceCallback callback);
+ void cancelHandover(int slotId, int cid, IDataServiceCallback callback);
}
diff --git a/telephony/java/android/telephony/data/IDataServiceCallback.aidl b/telephony/java/android/telephony/data/IDataServiceCallback.aidl
index cec757d..d296e7b 100644
--- a/telephony/java/android/telephony/data/IDataServiceCallback.aidl
+++ b/telephony/java/android/telephony/data/IDataServiceCallback.aidl
@@ -30,4 +30,6 @@
void onSetDataProfileComplete(int result);
void onRequestDataCallListComplete(int result, in List<DataCallResponse> dataCallList);
void onDataCallListChanged(in List<DataCallResponse> dataCallList);
+ void onHandoverStarted(int result);
+ void onHandoverCancelled(int result);
}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 9160746..9d4072f 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -517,7 +517,7 @@
int RIL_REQUEST_IS_NR_DUAL_CONNECTIVITY_ENABLED = 214;
int RIL_REQUEST_ALLOCATE_PDU_SESSION_ID = 215;
int RIL_REQUEST_RELEASE_PDU_SESSION_ID = 216;
- int RIL_REQUEST_BEGIN_HANDOVER = 217;
+ int RIL_REQUEST_START_HANDOVER = 217;
int RIL_REQUEST_CANCEL_HANDOVER = 218;
/* Responses begin */
diff --git a/wifi/api/system-current.txt b/wifi/api/system-current.txt
index 1d2bed8..c4a1766 100644
--- a/wifi/api/system-current.txt
+++ b/wifi/api/system-current.txt
@@ -500,9 +500,11 @@
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startLocalOnlyHotspot(@NonNull android.net.wifi.SoftApConfiguration, @Nullable java.util.concurrent.Executor, @Nullable android.net.wifi.WifiManager.LocalOnlyHotspotCallback);
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public boolean startScan(android.os.WorkSource);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startSubscriptionProvisioning(@NonNull android.net.wifi.hotspot2.OsuProvider, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.hotspot2.ProvisioningCallback);
+ method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void startTemporarilyDisablingAllNonCarrierMergedWifi(int);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startTetheredHotspot(@Nullable android.net.wifi.SoftApConfiguration);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void stopEasyConnectSession();
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean stopSoftAp();
+ method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void stopTemporarilyDisablingAllNonCarrierMergedWifi();
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void unregisterNetworkRequestMatchCallback(@NonNull android.net.wifi.WifiManager.NetworkRequestMatchCallback);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void unregisterSoftApCallback(@NonNull android.net.wifi.WifiManager.SoftApCallback);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void unregisterTrafficStateCallback(@NonNull android.net.wifi.WifiManager.TrafficStateCallback);
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 48e2312..cc864ea 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -277,4 +277,8 @@
boolean isAutoWakeupEnabled();
int getNetworkSuggestionUserApprovalStatus(String packageName);
+
+ void startTemporarilyDisablingAllNonCarrierMergedWifi(int subId);
+
+ void stopTemporarilyDisablingAllNonCarrierMergedWifi();
}
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 84cd818..85b3170 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -3255,7 +3255,11 @@
return key;
}
- private String getDefaultSecurityType() {
+ /**
+ * Get the default security type string.
+ * @hide
+ */
+ public String getDefaultSecurityType() {
String key;
if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
key = KeyMgmt.strings[KeyMgmt.WPA_PSK];
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 7e04d8f..9db50b3 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -4292,6 +4292,45 @@
}
/**
+ * Temporarily disable autojoin for all currently visible and provisioned (saved, suggested)
+ * wifi networks except merged carrier networks from the provided subscription ID.
+ *
+ * Disabled networks will get automatically re-enabled when they are out of range for a period
+ * of time, or after the maximum disable duration specified in the framework.
+ *
+ * Calling {@link #stopTemporarilyDisablingAllNonCarrierMergedWifi()} will immediately re-enable
+ * autojoin on all disabled networks.
+ *
+ * @param subscriptionId the subscription ID of the carrier whose merged wifi networks won't be
+ * disabled {@link android.telephony.SubscriptionInfo#getSubscriptionId()}
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
+ public void startTemporarilyDisablingAllNonCarrierMergedWifi(int subscriptionId) {
+ try {
+ mService.startTemporarilyDisablingAllNonCarrierMergedWifi(subscriptionId);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Re-enable autojoin for all non carrier merged wifi networks temporarily disconnected by
+ * {@link #startTemporarilyDisablingAllNonCarrierMergedWifi(int)}.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
+ public void stopTemporarilyDisablingAllNonCarrierMergedWifi() {
+ try {
+ mService.stopTemporarilyDisablingAllNonCarrierMergedWifi();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Save the given network to the list of configured networks for the
* foreground user. If the network already exists, the configuration
* is updated. Any new network is enabled by default.
diff --git a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
index bd9a103..e606d53 100644
--- a/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
+++ b/wifi/java/android/net/wifi/WifiNetworkSuggestion.java
@@ -1180,7 +1180,8 @@
@Override
public int hashCode() {
return Objects.hash(wifiConfiguration.SSID, wifiConfiguration.BSSID,
- wifiConfiguration.allowedKeyManagement, wifiConfiguration.getKey(),
+ wifiConfiguration.getDefaultSecurityType(),
+ wifiConfiguration.getPasspointUniqueId(),
wifiConfiguration.subscriptionId, wifiConfiguration.carrierId);
}
@@ -1202,10 +1203,10 @@
return TextUtils.equals(this.wifiConfiguration.SSID, lhs.wifiConfiguration.SSID)
&& TextUtils.equals(this.wifiConfiguration.BSSID, lhs.wifiConfiguration.BSSID)
- && Objects.equals(this.wifiConfiguration.allowedKeyManagement,
- lhs.wifiConfiguration.allowedKeyManagement)
- && TextUtils.equals(this.wifiConfiguration.getKey(),
- lhs.wifiConfiguration.getKey())
+ && TextUtils.equals(this.wifiConfiguration.getDefaultSecurityType(),
+ lhs.wifiConfiguration.getDefaultSecurityType())
+ && TextUtils.equals(this.wifiConfiguration.getPasspointUniqueId(),
+ lhs.wifiConfiguration.getPasspointUniqueId())
&& this.wifiConfiguration.carrierId == lhs.wifiConfiguration.carrierId
&& this.wifiConfiguration.subscriptionId == lhs.wifiConfiguration.subscriptionId;
}
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index 5729247..aefebbc 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -1634,6 +1634,24 @@
}
/**
+ * Verify the call to startTemporarilyDisablingAllNonCarrierMergedWifi goes to WifiServiceImpl.
+ */
+ @Test
+ public void testStartTemporarilyDisablingAllNonCarrierMergedWifi() throws Exception {
+ mWifiManager.startTemporarilyDisablingAllNonCarrierMergedWifi(1);
+ verify(mWifiService).startTemporarilyDisablingAllNonCarrierMergedWifi(1);
+ }
+
+ /**
+ * Verify the call to stopTemporarilyDisablingAllNonCarrierMergedWifi goes to WifiServiceImpl.
+ */
+ @Test
+ public void testStopTemporarilyDisablingAllNonCarrierMergedWifi() throws Exception {
+ mWifiManager.stopTemporarilyDisablingAllNonCarrierMergedWifi();
+ verify(mWifiService).stopTemporarilyDisablingAllNonCarrierMergedWifi();
+ }
+
+ /**
* Verify the call to addOnWifiUsabilityStatsListener goes to WifiServiceImpl.
*/
@Test