Launch app details for correct profile.
Support showing app details for apps in other profiles. Bug: 16371359 Change-Id: I1cabcd9f74f2a6ea6c4202a7d58af3ff3b458fd2
This commit is contained in:
parent
e755d469d4
commit
f07af7b77d
|
@ -26,6 +26,8 @@ import android.util.AttributeSet;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.compat.UserHandleCompat;
|
||||
|
||||
public class InfoDropTarget extends ButtonDropTarget {
|
||||
|
||||
private ColorStateList mOriginalTextColor;
|
||||
|
@ -82,8 +84,15 @@ public class InfoDropTarget extends ButtonDropTarget {
|
|||
} else if (d.dragInfo instanceof PendingAddItemInfo) {
|
||||
componentName = ((PendingAddItemInfo) d.dragInfo).componentName;
|
||||
}
|
||||
final UserHandleCompat user;
|
||||
if (d.dragInfo instanceof ItemInfo) {
|
||||
user = ((ItemInfo) d.dragInfo).user;
|
||||
} else {
|
||||
user = UserHandleCompat.myUserHandle();
|
||||
}
|
||||
|
||||
if (componentName != null) {
|
||||
mLauncher.startApplicationDetailsActivity(componentName);
|
||||
mLauncher.startApplicationDetailsActivity(componentName, user);
|
||||
}
|
||||
|
||||
// There is no post-drop animation, so clean up the DragView now
|
||||
|
|
|
@ -2726,13 +2726,19 @@ public class Launcher extends Activity
|
|||
*/
|
||||
protected void onInteractionBegin() {}
|
||||
|
||||
void startApplicationDetailsActivity(ComponentName componentName) {
|
||||
void startApplicationDetailsActivity(ComponentName componentName, UserHandleCompat user) {
|
||||
String packageName = componentName.getPackageName();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", packageName, null));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK |
|
||||
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
startActivitySafely(null, intent, "startApplicationDetailsActivity");
|
||||
try {
|
||||
LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
|
||||
UserManagerCompat userManager = UserManagerCompat.getInstance(this);
|
||||
launcherApps.showAppDetailsForProfile(componentName, user);
|
||||
} catch (SecurityException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Launcher does not have permission to launch settings");
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Unable to launch settings");
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if the activity was started
|
||||
|
|
|
@ -66,6 +66,7 @@ public abstract class LauncherAppsCompat {
|
|||
UserHandleCompat user);
|
||||
public abstract void startActivityForProfile(ComponentName component, UserHandleCompat user,
|
||||
Rect sourceBounds, Bundle opts);
|
||||
public abstract void showAppDetailsForProfile(ComponentName component, UserHandleCompat user);
|
||||
public abstract void addOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
|
||||
public abstract void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat listener);
|
||||
public abstract boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user);
|
||||
|
|
|
@ -27,14 +27,21 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Version of {@link LauncherAppsCompat} for devices with API level 16.
|
||||
* Devices Pre-L don't support multiple profiles in one launcher so
|
||||
* user parameters are ignored and all methods operate on the current user.
|
||||
*/
|
||||
public class LauncherAppsCompatV16 extends LauncherAppsCompat {
|
||||
|
||||
private PackageManager mPm;
|
||||
|
@ -81,6 +88,15 @@ public class LauncherAppsCompatV16 extends LauncherAppsCompat {
|
|||
mContext.startActivity(launchIntent, opts);
|
||||
}
|
||||
|
||||
public void showAppDetailsForProfile(ComponentName component, UserHandleCompat user) {
|
||||
String packageName = component.getPackageName();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", packageName, null));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK |
|
||||
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
mContext.startActivity(intent, null);
|
||||
}
|
||||
|
||||
public synchronized void addOnAppsChangedCallback(OnAppsChangedCallbackCompat callback) {
|
||||
if (callback != null && !mCallbacks.contains(callback)) {
|
||||
mCallbacks.add(callback);
|
||||
|
|
|
@ -73,6 +73,10 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat {
|
|||
mLauncherApps.startActivityForProfile(component, user.getUser(), sourceBounds, opts);
|
||||
}
|
||||
|
||||
public void showAppDetailsForProfile(ComponentName component, UserHandleCompat user) {
|
||||
mLauncherApps.showAppDetailsForProfile(component, user.getUser(), null, null);
|
||||
}
|
||||
|
||||
public void addOnAppsChangedCallback(LauncherAppsCompat.OnAppsChangedCallbackCompat callback) {
|
||||
WrappedCallback wrappedCallback = new WrappedCallback(callback);
|
||||
synchronized (mCallbacks) {
|
||||
|
|
Loading…
Reference in New Issue