Merge "Remove updateShortcutVisibility" into sc-dev
This commit is contained in:
@@ -13079,7 +13079,6 @@ package android.content.pm {
|
|||||||
method public void reportShortcutUsed(String);
|
method public void reportShortcutUsed(String);
|
||||||
method @WorkerThread public boolean requestPinShortcut(@NonNull android.content.pm.ShortcutInfo, @Nullable android.content.IntentSender);
|
method @WorkerThread public boolean requestPinShortcut(@NonNull android.content.pm.ShortcutInfo, @Nullable android.content.IntentSender);
|
||||||
method @WorkerThread public boolean setDynamicShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
|
method @WorkerThread public boolean setDynamicShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
|
||||||
method public void updateShortcutVisibility(@NonNull String, @Nullable byte[], boolean);
|
|
||||||
method @WorkerThread public boolean updateShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
|
method @WorkerThread public boolean updateShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
|
||||||
field public static final int FLAG_MATCH_CACHED = 8; // 0x8
|
field public static final int FLAG_MATCH_CACHED = 8; // 0x8
|
||||||
field public static final int FLAG_MATCH_DYNAMIC = 2; // 0x2
|
field public static final int FLAG_MATCH_DYNAMIC = 2; // 0x2
|
||||||
|
|||||||
@@ -81,7 +81,4 @@ interface IShortcutService {
|
|||||||
AndroidFuture<ParceledListSlice> getShortcuts(String packageName, int matchFlags, int userId);
|
AndroidFuture<ParceledListSlice> getShortcuts(String packageName, int matchFlags, int userId);
|
||||||
|
|
||||||
AndroidFuture pushDynamicShortcut(String packageName, in ShortcutInfo shortcut, int userId);
|
AndroidFuture pushDynamicShortcut(String packageName, in ShortcutInfo shortcut, int userId);
|
||||||
|
|
||||||
AndroidFuture updateShortcutVisibility(String callingPkg, String packageName,
|
|
||||||
in byte[] certificate, in boolean visible, int userId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.infra.AndroidFuture;
|
import com.android.internal.infra.AndroidFuture;
|
||||||
@@ -790,23 +789,6 @@ public class ShortcutManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Granting another app the access to the shortcuts you own. You must provide the package name
|
|
||||||
* and their SHA256 certificate digest in order to granting the access.
|
|
||||||
*
|
|
||||||
* Once granted, the other app can retain a copy of all the shortcuts you own when calling
|
|
||||||
* {@link LauncherApps#getShortcuts(LauncherApps.ShortcutQuery, UserHandle)}.
|
|
||||||
*/
|
|
||||||
public void updateShortcutVisibility(@NonNull final String packageName,
|
|
||||||
@Nullable final byte[] certificate, final boolean visible) {
|
|
||||||
try {
|
|
||||||
getFutureOrThrow(mService.updateShortcutVisibility(mContext.getPackageName(),
|
|
||||||
packageName, certificate, visible, injectMyUserId()));
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> T getFutureOrThrow(@NonNull AndroidFuture<T> future) {
|
private static <T> T getFutureOrThrow(@NonNull AndroidFuture<T> future) {
|
||||||
try {
|
try {
|
||||||
return future.get();
|
return future.get();
|
||||||
|
|||||||
@@ -2253,24 +2253,6 @@ public class ShortcutService extends IShortcutService.Stub {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AndroidFuture updateShortcutVisibility(String callingPkg, String packageName,
|
|
||||||
byte[] certificate, boolean visible, int userId) {
|
|
||||||
final AndroidFuture<Void> ret = new AndroidFuture<>();
|
|
||||||
injectPostToHandlerIfAppSearch(() -> {
|
|
||||||
try {
|
|
||||||
synchronized (mLock) {
|
|
||||||
getPackageShortcutsForPublisherLocked(callingPkg, userId)
|
|
||||||
.updateVisibility(packageName, certificate, visible);
|
|
||||||
}
|
|
||||||
ret.complete(null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
ret.completeExceptionally(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AndroidFuture requestPinShortcut(String packageName, ShortcutInfo shortcut,
|
public AndroidFuture requestPinShortcut(String packageName, ShortcutInfo shortcut,
|
||||||
IntentSender resultIntent, int userId) {
|
IntentSender resultIntent, int userId) {
|
||||||
|
|||||||
@@ -15,20 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.server.pm;
|
package com.android.server.pm;
|
||||||
|
|
||||||
import static android.provider.DeviceConfig.NAMESPACE_SYSTEMUI;
|
|
||||||
|
|
||||||
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
|
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.appsearch.PackageIdentifier;
|
|
||||||
import android.content.pm.AppSearchShortcutInfo;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.DeviceConfig;
|
|
||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link android.app.appsearch.AppSearchManager} and relevant APIs in ShortcutManager.
|
* Tests for {@link android.app.appsearch.AppSearchManager} and relevant APIs in ShortcutManager.
|
||||||
@@ -37,26 +28,6 @@ import java.util.Random;
|
|||||||
*/
|
*/
|
||||||
public class ShortcutManagerTest12 extends BaseShortcutManagerTest {
|
public class ShortcutManagerTest12 extends BaseShortcutManagerTest {
|
||||||
|
|
||||||
public void testUpdateShortcutVisibility_updatesShortcutSchema() {
|
|
||||||
if (!DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI,
|
|
||||||
SystemUiDeviceConfigFlags.DARK_LAUNCH_REMOTE_PREDICTION_SERVICE_ENABLED,
|
|
||||||
false)) {
|
|
||||||
// no-op if app-search integration is disabled.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final byte[] cert = new byte[20];
|
|
||||||
new Random().nextBytes(cert);
|
|
||||||
|
|
||||||
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
|
|
||||||
mManager.updateShortcutVisibility(CALLING_PACKAGE_2, cert, true);
|
|
||||||
assertTrue(mMockAppSearchManager.mSchemasPackageAccessible.containsKey(
|
|
||||||
AppSearchShortcutInfo.SCHEMA_TYPE));
|
|
||||||
assertTrue(mMockAppSearchManager.mSchemasPackageAccessible.get(
|
|
||||||
AppSearchShortcutInfo.SCHEMA_TYPE).get(0).equals(
|
|
||||||
new PackageIdentifier(CALLING_PACKAGE_2, cert)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetShortcutIntents_ReturnsMutablePendingIntents() throws RemoteException {
|
public void testGetShortcutIntents_ReturnsMutablePendingIntents() throws RemoteException {
|
||||||
setDefaultLauncher(USER_0, LAUNCHER_1);
|
setDefaultLauncher(USER_0, LAUNCHER_1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user