Merge "Add user selectable Default Browser feature - part 6" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e2f43948d1
@@ -668,29 +668,37 @@ public class ResolverActivity extends Activity {
|
||||
if (r.match > bestMatch) bestMatch = r.match;
|
||||
}
|
||||
if (alwaysCheck) {
|
||||
PackageManager pm = getPackageManager();
|
||||
final int userId = getUserId();
|
||||
final PackageManager pm = getPackageManager();
|
||||
|
||||
// Set the preferred Activity
|
||||
pm.addPreferredActivity(filter, bestMatch, set, intent.getComponent());
|
||||
|
||||
// Update Domain Verification status
|
||||
int userId = getUserId();
|
||||
ComponentName cn = intent.getComponent();
|
||||
String packageName = cn.getPackageName();
|
||||
String dataScheme = (data != null) ? data.getScheme() : null;
|
||||
if (ri.handleAllWebDataURI) {
|
||||
// Set default Browser if needed
|
||||
final String packageName = pm.getDefaultBrowserPackageName(userId);
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
pm.setDefaultBrowserPackageName(ri.activityInfo.packageName, userId);
|
||||
}
|
||||
} else {
|
||||
// Update Domain Verification status
|
||||
ComponentName cn = intent.getComponent();
|
||||
String packageName = cn.getPackageName();
|
||||
String dataScheme = (data != null) ? data.getScheme() : null;
|
||||
|
||||
boolean isHttpOrHttps = (dataScheme != null) &&
|
||||
(dataScheme.equals(IntentFilter.SCHEME_HTTP) ||
|
||||
dataScheme.equals(IntentFilter.SCHEME_HTTPS));
|
||||
boolean isHttpOrHttps = (dataScheme != null) &&
|
||||
(dataScheme.equals(IntentFilter.SCHEME_HTTP) ||
|
||||
dataScheme.equals(IntentFilter.SCHEME_HTTPS));
|
||||
|
||||
boolean isViewAction = (action != null) && action.equals(Intent.ACTION_VIEW);
|
||||
boolean hasCategoryBrowsable = (categories != null) &&
|
||||
categories.contains(Intent.CATEGORY_BROWSABLE);
|
||||
boolean isViewAction = (action != null) && action.equals(Intent.ACTION_VIEW);
|
||||
boolean hasCategoryBrowsable = (categories != null) &&
|
||||
categories.contains(Intent.CATEGORY_BROWSABLE);
|
||||
|
||||
if (isHttpOrHttps && isViewAction && hasCategoryBrowsable) {
|
||||
pm.updateIntentVerificationStatus(packageName,
|
||||
PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS,
|
||||
userId);
|
||||
if (isHttpOrHttps && isViewAction && hasCategoryBrowsable) {
|
||||
pm.updateIntentVerificationStatus(packageName,
|
||||
PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS,
|
||||
userId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -9217,7 +9217,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
synchronized (mPackages) {
|
||||
result = mSettings.updateIntentFilterVerificationStatusLPw(packageName, status, userId);
|
||||
}
|
||||
scheduleWritePackageRestrictionsLocked(userId);
|
||||
if (result) {
|
||||
scheduleWritePackageRestrictionsLocked(userId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9254,9 +9256,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
public boolean setDefaultBrowserPackageName(String packageName, int userId) {
|
||||
synchronized (mPackages) {
|
||||
boolean result = mSettings.setDefaultBrowserPackageNameLPr(packageName, userId);
|
||||
result |= updateIntentVerificationStatus(packageName,
|
||||
PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS,
|
||||
UserHandle.myUserId());
|
||||
if (packageName != null) {
|
||||
result |= updateIntentVerificationStatus(packageName,
|
||||
PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS,
|
||||
UserHandle.myUserId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -11970,6 +11974,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
if (deletedPs != null) {
|
||||
if ((flags&PackageManager.DELETE_KEEP_DATA) == 0) {
|
||||
clearIntentFilterVerificationsLPw(deletedPs.name, UserHandle.USER_ALL);
|
||||
clearDefaultBrowserIfNeeded(packageName);
|
||||
if (outInfo != null) {
|
||||
mSettings.mKeySetManagerService.removeAppKeySetDataLPw(packageName);
|
||||
outInfo.removedAppId = mSettings.removePackageLPw(packageName);
|
||||
@@ -12504,7 +12509,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
succeded = deleteApplicationCacheFilesLI(packageName, userId);
|
||||
}
|
||||
clearExternalStorageDataSync(packageName, userId, false);
|
||||
if(observer != null) {
|
||||
if (observer != null) {
|
||||
try {
|
||||
observer.onRemoveCompleted(packageName, succeded);
|
||||
} catch (RemoteException e) {
|
||||
@@ -12873,6 +12878,17 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clearDefaultBrowserIfNeeded(String packageName) {
|
||||
for (int oneUserId : sUserManager.getUserIds()) {
|
||||
String defaultBrowserPackageName = getDefaultBrowserPackageName(oneUserId);
|
||||
if (TextUtils.isEmpty(defaultBrowserPackageName)) continue;
|
||||
if (packageName.equals(defaultBrowserPackageName)) {
|
||||
setDefaultBrowserPackageName(null, oneUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPreferredActivities(int userId) {
|
||||
/* TODO: Actually use userId. Why is it being passed in? */
|
||||
|
||||
Reference in New Issue
Block a user