Merge "Non-system camera PPA set by DPC" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9a1619cc6d
@@ -5264,15 +5264,17 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
int updateFlagsForResolve(int flags, int userId, int callingUid, boolean wantInstantApps,
|
int updateFlagsForResolve(int flags, int userId, int callingUid, boolean wantInstantApps,
|
||||||
boolean matchSystemOnly) {
|
boolean isImplicitImageCaptureIntentAndNotSetByDpc) {
|
||||||
return updateFlagsForResolve(flags, userId, callingUid,
|
return updateFlagsForResolve(flags, userId, callingUid,
|
||||||
wantInstantApps, matchSystemOnly, false /*onlyExposedExplicitly*/);
|
wantInstantApps, false /*onlyExposedExplicitly*/,
|
||||||
|
isImplicitImageCaptureIntentAndNotSetByDpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int updateFlagsForResolve(int flags, int userId, int callingUid,
|
int updateFlagsForResolve(int flags, int userId, int callingUid,
|
||||||
boolean wantInstantApps, boolean onlyExposedExplicitly, boolean matchSystemOnly) {
|
boolean wantInstantApps, boolean onlyExposedExplicitly,
|
||||||
|
boolean isImplicitImageCaptureIntentAndNotSetByDpc) {
|
||||||
// Safe mode means we shouldn't match any third-party components
|
// Safe mode means we shouldn't match any third-party components
|
||||||
if (mSafeMode || matchSystemOnly) {
|
if (mSafeMode || isImplicitImageCaptureIntentAndNotSetByDpc) {
|
||||||
flags |= PackageManager.MATCH_SYSTEM_ONLY;
|
flags |= PackageManager.MATCH_SYSTEM_ONLY;
|
||||||
}
|
}
|
||||||
if (getInstantAppPackageName(callingUid) != null) {
|
if (getInstantAppPackageName(callingUid) != null) {
|
||||||
@@ -6400,7 +6402,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
if (!mUserManager.exists(userId)) return null;
|
if (!mUserManager.exists(userId)) return null;
|
||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
flags = updateFlagsForResolve(flags, userId, filterCallingUid, resolveForStart,
|
flags = updateFlagsForResolve(flags, userId, filterCallingUid, resolveForStart,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType,
|
||||||
|
flags));
|
||||||
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
|
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
|
||||||
false /*requireFullPermission*/, false /*checkShell*/, "resolve intent");
|
false /*requireFullPermission*/, false /*checkShell*/, "resolve intent");
|
||||||
|
|
||||||
@@ -6438,7 +6441,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
final String resolvedType = intent.resolveTypeIfNeeded(mContext.getContentResolver());
|
final String resolvedType = intent.resolveTypeIfNeeded(mContext.getContentResolver());
|
||||||
final int flags = updateFlagsForResolve(
|
final int flags = updateFlagsForResolve(
|
||||||
0, userId, callingUid, false /*includeInstantApps*/,
|
0, userId, callingUid, false /*includeInstantApps*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType, 0));
|
||||||
final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags,
|
final List<ResolveInfo> query = queryIntentActivitiesInternal(intent, resolvedType, flags,
|
||||||
userId);
|
userId);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@@ -6684,6 +6687,40 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From Android R, camera intents have to match system apps. The only exception to this is if
|
||||||
|
* the DPC has set the camera persistent preferred activity. This case was introduced
|
||||||
|
* because it is important that the DPC has the ability to set both system and non-system
|
||||||
|
* camera persistent preferred activities.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the intent is a camera intent and the persistent preferred
|
||||||
|
* activity was not set by the DPC.
|
||||||
|
*/
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private boolean isImplicitImageCaptureIntentAndNotSetByDpcLocked(Intent intent, int userId,
|
||||||
|
String resolvedType, int flags) {
|
||||||
|
return intent.isImplicitImageCaptureIntent() && !isPersistentPreferredActivitySetByDpm(
|
||||||
|
intent, userId, resolvedType, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPersistentPreferredActivitySetByDpm(Intent intent, int userId,
|
||||||
|
String resolvedType, int flags) {
|
||||||
|
PersistentPreferredIntentResolver ppir = mSettings.mPersistentPreferredActivities
|
||||||
|
.get(userId);
|
||||||
|
//TODO(b/158003772): Remove double query
|
||||||
|
List<PersistentPreferredActivity> pprefs = ppir != null
|
||||||
|
? ppir.queryIntent(intent, resolvedType,
|
||||||
|
(flags & PackageManager.MATCH_DEFAULT_ONLY) != 0,
|
||||||
|
userId)
|
||||||
|
: new ArrayList<>();
|
||||||
|
for (PersistentPreferredActivity ppa : pprefs) {
|
||||||
|
if (ppa.mIsSetByDpm) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private ResolveInfo findPersistentPreferredActivityLP(Intent intent, String resolvedType,
|
private ResolveInfo findPersistentPreferredActivityLP(Intent intent, String resolvedType,
|
||||||
int flags, List<ResolveInfo> query, boolean debug, int userId) {
|
int flags, List<ResolveInfo> query, boolean debug, int userId) {
|
||||||
@@ -6767,7 +6804,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1;
|
android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1;
|
||||||
flags = updateFlagsForResolve(
|
flags = updateFlagsForResolve(
|
||||||
flags, userId, callingUid, false /*includeInstantApps*/,
|
flags, userId, callingUid, false /*includeInstantApps*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType,
|
||||||
|
flags));
|
||||||
intent = updateIntentForResolve(intent);
|
intent = updateIntentForResolve(intent);
|
||||||
// writer
|
// writer
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@@ -6980,7 +7018,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
int flags = updateFlagsForResolve(0, parent.id, callingUid,
|
int flags = updateFlagsForResolve(0, parent.id, callingUid,
|
||||||
false /*includeInstantApps*/,
|
false /*includeInstantApps*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, parent.id,
|
||||||
|
resolvedType, 0));
|
||||||
CrossProfileDomainInfo xpDomainInfo = getCrossProfileDomainPreferredLpr(
|
CrossProfileDomainInfo xpDomainInfo = getCrossProfileDomainPreferredLpr(
|
||||||
intent, resolvedType, flags, sourceUserId, parent.id);
|
intent, resolvedType, flags, sourceUserId, parent.id);
|
||||||
return xpDomainInfo != null;
|
return xpDomainInfo != null;
|
||||||
@@ -7067,7 +7106,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
|
|
||||||
flags = updateFlagsForResolve(flags, userId, filterCallingUid, resolveForStart,
|
flags = updateFlagsForResolve(flags, userId, filterCallingUid, resolveForStart,
|
||||||
comp != null || pkgName != null /*onlyExposedExplicitly*/,
|
comp != null || pkgName != null /*onlyExposedExplicitly*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType,
|
||||||
|
flags));
|
||||||
if (comp != null) {
|
if (comp != null) {
|
||||||
final List<ResolveInfo> list = new ArrayList<>(1);
|
final List<ResolveInfo> list = new ArrayList<>(1);
|
||||||
final ActivityInfo ai = getActivityInfo(comp, flags, userId);
|
final ActivityInfo ai = getActivityInfo(comp, flags, userId);
|
||||||
@@ -7856,7 +7896,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
if (!mUserManager.exists(userId)) return Collections.emptyList();
|
if (!mUserManager.exists(userId)) return Collections.emptyList();
|
||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType,
|
||||||
|
flags));
|
||||||
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
|
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
|
||||||
false /*requireFullPermission*/, false /*checkShell*/,
|
false /*requireFullPermission*/, false /*checkShell*/,
|
||||||
"query intent activity options");
|
"query intent activity options");
|
||||||
@@ -8043,7 +8084,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
"query intent receivers");
|
"query intent receivers");
|
||||||
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
||||||
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
||||||
intent.isImplicitImageCaptureIntent() /*matchSystemOnly*/);
|
isImplicitImageCaptureIntentAndNotSetByDpcLocked(intent, userId, resolvedType,
|
||||||
|
flags));
|
||||||
ComponentName comp = intent.getComponent();
|
ComponentName comp = intent.getComponent();
|
||||||
if (comp == null) {
|
if (comp == null) {
|
||||||
if (intent.getSelector() != null) {
|
if (intent.getSelector() != null) {
|
||||||
@@ -8134,7 +8176,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
int userId, int callingUid) {
|
int userId, int callingUid) {
|
||||||
if (!mUserManager.exists(userId)) return null;
|
if (!mUserManager.exists(userId)) return null;
|
||||||
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
||||||
false /* matchSystemOnly */);
|
false /* isImplicitImageCaptureIntentAndNotSetByDpc */);
|
||||||
List<ResolveInfo> query = queryIntentServicesInternal(
|
List<ResolveInfo> query = queryIntentServicesInternal(
|
||||||
intent, resolvedType, flags, userId, callingUid, false /*includeInstantApps*/);
|
intent, resolvedType, flags, userId, callingUid, false /*includeInstantApps*/);
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
@@ -8166,7 +8208,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
"query intent receivers");
|
"query intent receivers");
|
||||||
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
||||||
flags = updateFlagsForResolve(flags, userId, callingUid, includeInstantApps,
|
flags = updateFlagsForResolve(flags, userId, callingUid, includeInstantApps,
|
||||||
false /* matchSystemOnly */);
|
false /* isImplicitImageCaptureIntentAndNotSetByDpc */);
|
||||||
ComponentName comp = intent.getComponent();
|
ComponentName comp = intent.getComponent();
|
||||||
if (comp == null) {
|
if (comp == null) {
|
||||||
if (intent.getSelector() != null) {
|
if (intent.getSelector() != null) {
|
||||||
@@ -8304,7 +8346,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
final String instantAppPkgName = getInstantAppPackageName(callingUid);
|
||||||
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
flags = updateFlagsForResolve(flags, userId, callingUid, false /*includeInstantApps*/,
|
||||||
false /* matchSystemOnly */);
|
false /* isImplicitImageCaptureIntentAndNotSetByDpc */);
|
||||||
ComponentName comp = intent.getComponent();
|
ComponentName comp = intent.getComponent();
|
||||||
if (comp == null) {
|
if (comp == null) {
|
||||||
if (intent.getSelector() != null) {
|
if (intent.getSelector() != null) {
|
||||||
@@ -19840,7 +19882,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
}
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mSettings.editPersistentPreferredActivitiesLPw(userId).addFilter(
|
mSettings.editPersistentPreferredActivitiesLPw(userId).addFilter(
|
||||||
new PersistentPreferredActivity(filter, activity));
|
new PersistentPreferredActivity(filter, activity, true));
|
||||||
scheduleWritePackageRestrictionsLocked(userId);
|
scheduleWritePackageRestrictionsLocked(userId);
|
||||||
}
|
}
|
||||||
updateDefaultHomeNotLocked(userId);
|
updateDefaultHomeNotLocked(userId);
|
||||||
|
|||||||
@@ -16,31 +16,34 @@
|
|||||||
|
|
||||||
package com.android.server.pm;
|
package com.android.server.pm;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.util.XmlUtils;
|
import com.android.internal.util.XmlUtils;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class PersistentPreferredActivity extends IntentFilter {
|
class PersistentPreferredActivity extends IntentFilter {
|
||||||
private static final String ATTR_NAME = "name"; // component name
|
private static final String ATTR_NAME = "name"; // component name
|
||||||
private static final String ATTR_FILTER = "filter"; // filter
|
private static final String ATTR_FILTER = "filter"; // filter
|
||||||
|
private static final String ATTR_SET_BY_DPM = "set-by-dpm"; // set by DPM
|
||||||
|
|
||||||
private static final String TAG = "PersistentPreferredActivity";
|
private static final String TAG = "PersistentPreferredActivity";
|
||||||
|
|
||||||
private static final boolean DEBUG_FILTERS = false;
|
private static final boolean DEBUG_FILTERS = false;
|
||||||
|
|
||||||
final ComponentName mComponent;
|
final ComponentName mComponent;
|
||||||
|
final boolean mIsSetByDpm;
|
||||||
|
|
||||||
PersistentPreferredActivity(IntentFilter filter, ComponentName activity) {
|
PersistentPreferredActivity(IntentFilter filter, ComponentName activity, boolean isSetByDpm) {
|
||||||
super(filter);
|
super(filter);
|
||||||
mComponent = activity;
|
mComponent = activity;
|
||||||
|
mIsSetByDpm = isSetByDpm;
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistentPreferredActivity(XmlPullParser parser) throws XmlPullParserException, IOException {
|
PersistentPreferredActivity(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
@@ -52,6 +55,8 @@ class PersistentPreferredActivity extends IntentFilter {
|
|||||||
"Bad activity name " + shortComponent +
|
"Bad activity name " + shortComponent +
|
||||||
" at " + parser.getPositionDescription());
|
" at " + parser.getPositionDescription());
|
||||||
}
|
}
|
||||||
|
mIsSetByDpm = Boolean.parseBoolean(parser.getAttributeValue(null, ATTR_SET_BY_DPM));
|
||||||
|
|
||||||
int outerDepth = parser.getDepth();
|
int outerDepth = parser.getDepth();
|
||||||
String tagName = parser.getName();
|
String tagName = parser.getName();
|
||||||
int type;
|
int type;
|
||||||
@@ -83,6 +88,7 @@ class PersistentPreferredActivity extends IntentFilter {
|
|||||||
|
|
||||||
public void writeToXml(XmlSerializer serializer) throws IOException {
|
public void writeToXml(XmlSerializer serializer) throws IOException {
|
||||||
serializer.attribute(null, ATTR_NAME, mComponent.flattenToShortString());
|
serializer.attribute(null, ATTR_NAME, mComponent.flattenToShortString());
|
||||||
|
serializer.attribute(null, ATTR_SET_BY_DPM, Boolean.toString(mIsSetByDpm));
|
||||||
serializer.startTag(null, ATTR_FILTER);
|
serializer.startTag(null, ATTR_FILTER);
|
||||||
super.writeToXml(serializer);
|
super.writeToXml(serializer);
|
||||||
serializer.endTag(null, ATTR_FILTER);
|
serializer.endTag(null, ATTR_FILTER);
|
||||||
@@ -91,6 +97,7 @@ class PersistentPreferredActivity extends IntentFilter {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PersistentPreferredActivity{0x" + Integer.toHexString(System.identityHashCode(this))
|
return "PersistentPreferredActivity{0x" + Integer.toHexString(System.identityHashCode(this))
|
||||||
+ " " + mComponent.flattenToShortString() + "}";
|
+ " " + mComponent.flattenToShortString()
|
||||||
|
+ ", mIsSetByDpm=" + mIsSetByDpm + "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user