Add admin-set default apps to Enterprise Privacy Settings page

This CL adds information about the number of default handlers for
common intents (e.g. browser, e-mail, calendar) set by the admin.

Bug: 32692748
Test: make RunSettingsRoboTests

Change-Id: I569d9ddabeee2b2aa9a892b28066abb8bf920fcf
This commit is contained in:
Bartosz Fabianowski
2017-01-19 17:20:03 +01:00
parent b62f4f75c9
commit 482908f226
15 changed files with 520 additions and 20 deletions

View File

@@ -17,8 +17,11 @@
package com.android.settings.applications;
import android.app.Fragment;
import android.content.Intent;
import android.view.View;
import java.util.Set;
public interface ApplicationFeatureProvider {
/**
@@ -54,10 +57,48 @@ public interface ApplicationFeatureProvider {
void calculateNumberOfAppsWithAdminGrantedPermissions(String[] permissions,
NumberOfAppsCallback callback);
/**
* Return the persistent preferred activities configured by the admin for the current user and
* all its managed profiles. A persistent preferred activity is an activity that the admin
* configured to always handle a given intent (e.g. open browser), even if the user has other
* apps installed that would also be able to handle the intent.
*
* @param intent The intents for which to find persistent preferred activities
*
* @return the persistent preferred activites for the given intent
*/
Set<PersistentPreferredActivityInfo> findPersistentPreferredActivities(Intent[] intents);
/**
* Callback that receives the number of packages installed on the device.
*/
interface NumberOfAppsCallback {
void onNumberOfAppsResult(int num);
}
public static class PersistentPreferredActivityInfo {
public final String packageName;
public final int userId;
public PersistentPreferredActivityInfo(String packageName, int userId) {
this.packageName = packageName;
this.userId = userId;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof PersistentPreferredActivityInfo)) {
return false;
}
final PersistentPreferredActivityInfo otherActivityInfo
= (PersistentPreferredActivityInfo) other;
return otherActivityInfo.packageName.equals(packageName)
&& otherActivityInfo.userId == userId;
}
@Override
public int hashCode() {
return packageName.hashCode() ^ userId;
}
}
}