Merge "Setting Session commited broadcast when an existing apk is enabled for a different user" into oc-dev
This commit is contained in:
@@ -1696,15 +1696,27 @@ public class ApplicationPackageManager extends PackageManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int installExistingPackage(String packageName) throws NameNotFoundException {
|
public int installExistingPackage(String packageName) throws NameNotFoundException {
|
||||||
return installExistingPackageAsUser(packageName, mContext.getUserId());
|
return installExistingPackage(packageName, PackageManager.INSTALL_REASON_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int installExistingPackage(String packageName, int installReason)
|
||||||
|
throws NameNotFoundException {
|
||||||
|
return installExistingPackageAsUser(packageName, installReason, mContext.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int installExistingPackageAsUser(String packageName, int userId)
|
public int installExistingPackageAsUser(String packageName, int userId)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
|
return installExistingPackageAsUser(packageName, PackageManager.INSTALL_REASON_UNKNOWN,
|
||||||
|
userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int installExistingPackageAsUser(String packageName, int installReason, int userId)
|
||||||
|
throws NameNotFoundException {
|
||||||
try {
|
try {
|
||||||
int res = mPM.installExistingPackageAsUser(packageName, userId, 0 /*installFlags*/,
|
int res = mPM.installExistingPackageAsUser(packageName, userId, 0 /*installFlags*/,
|
||||||
PackageManager.INSTALL_REASON_UNKNOWN);
|
installReason);
|
||||||
if (res == INSTALL_FAILED_INVALID_URI) {
|
if (res == INSTALL_FAILED_INVALID_URI) {
|
||||||
throw new NameNotFoundException("Package " + packageName + " doesn't exist");
|
throw new NameNotFoundException("Package " + packageName + " doesn't exist");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4628,6 +4628,14 @@ public abstract class PackageManager {
|
|||||||
*/
|
*/
|
||||||
public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
|
public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there is already an application with the given package name installed
|
||||||
|
* on the system for other users, also install it for the calling user.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public abstract int installExistingPackage(String packageName, @InstallReason int installReason)
|
||||||
|
throws NameNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is already an application with the given package name installed
|
* If there is already an application with the given package name installed
|
||||||
* on the system for other users, also install it for the specified user.
|
* on the system for other users, also install it for the specified user.
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import static com.android.server.pm.PackageInstallerService.prepareExternalStage
|
|||||||
import static com.android.server.pm.PackageInstallerService.prepareStageDir;
|
import static com.android.server.pm.PackageInstallerService.prepareStageDir;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
@@ -46,7 +45,6 @@ import android.content.pm.PackageParser.ApkLite;
|
|||||||
import android.content.pm.PackageParser.PackageLite;
|
import android.content.pm.PackageParser.PackageLite;
|
||||||
import android.content.pm.PackageParser.PackageParserException;
|
import android.content.pm.PackageParser.PackageParserException;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
import android.content.pm.UserInfo;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.FileBridge;
|
import android.os.FileBridge;
|
||||||
@@ -56,7 +54,6 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.ProxyFileDescriptorCallback;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.RevocableFileDescriptor;
|
import android.os.RevocableFileDescriptor;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -1168,19 +1165,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
// Send broadcast to default launcher only if it's a new install
|
// Send broadcast to default launcher only if it's a new install
|
||||||
final boolean isNewInstall = extras == null || !extras.getBoolean(Intent.EXTRA_REPLACING);
|
final boolean isNewInstall = extras == null || !extras.getBoolean(Intent.EXTRA_REPLACING);
|
||||||
if (success && isNewInstall) {
|
if (success && isNewInstall) {
|
||||||
UserManagerService ums = UserManagerService.getInstance();
|
mPm.sendSessionCommitBroadcast(generateInfo(), userId);
|
||||||
if (ums != null) {
|
|
||||||
final UserInfo parent = ums.getProfileParent(userId);
|
|
||||||
final int launcherUid = (parent != null) ? parent.id : userId;
|
|
||||||
final ComponentName launcherComponent = mPm.getDefaultHomeActivity(launcherUid);
|
|
||||||
if (launcherComponent != null) {
|
|
||||||
Intent launcherIntent = new Intent(PackageInstaller.ACTION_SESSION_COMMITTED)
|
|
||||||
.putExtra(PackageInstaller.EXTRA_SESSION, generateInfo())
|
|
||||||
.putExtra(Intent.EXTRA_USER, UserHandle.of(userId))
|
|
||||||
.setPackage(launcherComponent.getPackageName());
|
|
||||||
mContext.sendBroadcastAsUser(launcherIntent, UserHandle.of(launcherUid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallback.onSessionFinished(this, success);
|
mCallback.onSessionFinished(this, success);
|
||||||
|
|||||||
@@ -13627,6 +13627,12 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
int userId) {
|
int userId) {
|
||||||
final boolean isSystem = isSystemApp(pkgSetting) || isUpdatedSystemApp(pkgSetting);
|
final boolean isSystem = isSystemApp(pkgSetting) || isUpdatedSystemApp(pkgSetting);
|
||||||
sendPackageAddedForNewUsers(packageName, isSystem, pkgSetting.appId, userId);
|
sendPackageAddedForNewUsers(packageName, isSystem, pkgSetting.appId, userId);
|
||||||
|
|
||||||
|
// Send a session commit broadcast
|
||||||
|
final PackageInstaller.SessionInfo info = new PackageInstaller.SessionInfo();
|
||||||
|
info.installReason = pkgSetting.getInstallReason(userId);
|
||||||
|
info.appPackageName = packageName;
|
||||||
|
sendSessionCommitBroadcast(info, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPackageAddedForNewUsers(String packageName, boolean isSystem, int appId, int... userIds) {
|
public void sendPackageAddedForNewUsers(String packageName, boolean isSystem, int appId, int... userIds) {
|
||||||
@@ -20142,11 +20148,27 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
|||||||
return getHomeActivitiesAsUser(allHomeCandidates, UserHandle.getCallingUserId());
|
return getHomeActivitiesAsUser(allHomeCandidates, UserHandle.getCallingUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendSessionCommitBroadcast(PackageInstaller.SessionInfo sessionInfo, int userId) {
|
||||||
|
UserManagerService ums = UserManagerService.getInstance();
|
||||||
|
if (ums != null) {
|
||||||
|
final UserInfo parent = ums.getProfileParent(userId);
|
||||||
|
final int launcherUid = (parent != null) ? parent.id : userId;
|
||||||
|
final ComponentName launcherComponent = getDefaultHomeActivity(launcherUid);
|
||||||
|
if (launcherComponent != null) {
|
||||||
|
Intent launcherIntent = new Intent(PackageInstaller.ACTION_SESSION_COMMITTED)
|
||||||
|
.putExtra(PackageInstaller.EXTRA_SESSION, sessionInfo)
|
||||||
|
.putExtra(Intent.EXTRA_USER, UserHandle.of(userId))
|
||||||
|
.setPackage(launcherComponent.getPackageName());
|
||||||
|
mContext.sendBroadcastAsUser(launcherIntent, UserHandle.of(launcherUid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report the 'Home' activity which is currently set as "always use this one". If non is set
|
* Report the 'Home' activity which is currently set as "always use this one". If non is set
|
||||||
* then reports the most likely home activity or null if there are more than one.
|
* then reports the most likely home activity or null if there are more than one.
|
||||||
*/
|
*/
|
||||||
public ComponentName getDefaultHomeActivity(int userId) {
|
private ComponentName getDefaultHomeActivity(int userId) {
|
||||||
List<ResolveInfo> allHomeCandidates = new ArrayList<>();
|
List<ResolveInfo> allHomeCandidates = new ArrayList<>();
|
||||||
ComponentName cn = getHomeActivitiesAsUser(allHomeCandidates, userId);
|
ComponentName cn = getHomeActivitiesAsUser(allHomeCandidates, userId);
|
||||||
if (cn != null) {
|
if (cn != null) {
|
||||||
|
|||||||
@@ -982,6 +982,15 @@ public class MockPackageManager extends PackageManager {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int installExistingPackage(String packageName, int installReason)
|
||||||
|
throws NameNotFoundException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -620,6 +620,12 @@ public class BridgePackageManager extends PackageManager {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int installExistingPackage(String packageName, int installReason)
|
||||||
|
throws NameNotFoundException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int installExistingPackageAsUser(String packageName, int userId)
|
public int installExistingPackageAsUser(String packageName, int userId)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
|
|||||||
Reference in New Issue
Block a user