Merge "AudioFlinger does not need libmedia any more"
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 0563846..af722a8 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -33,14 +33,17 @@
import android.os.Bundle;
import android.os.PatternMatcher;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.LayoutInflater;
+import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.TextView;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -122,6 +125,11 @@
}
setupAlert();
+
+ ListView lv = mAlert.getListView();
+ if (lv != null) {
+ lv.setOnItemLongClickListener(new ItemLongClickListener());
+ }
}
@Override
@@ -489,5 +497,18 @@
mClearDefaultHint.setVisibility(View.GONE);
}
}
+
+ class ItemLongClickListener implements AdapterView.OnItemLongClickListener {
+
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ ResolveInfo ri = mAdapter.resolveInfoForPosition(position);
+ Intent in = new Intent().setAction("android.settings.APPLICATION_DETAILS_SETTINGS")
+ .setData(Uri.fromParts("package", ri.activityInfo.packageName, null));
+ startActivity(in);
+ return true;
+ }
+
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
index a243e4d..88ee867 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkPolicyManagerServiceTest.java
@@ -53,6 +53,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
+import android.content.pm.UserInfo;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.INetworkManagementEventObserver;
@@ -69,6 +70,7 @@
import android.os.INetworkManagementService;
import android.os.IPowerManager;
import android.os.MessageQueue.IdleHandler;
+import android.os.UserId;
import android.test.AndroidTestCase;
import android.test.mock.MockPackageManager;
import android.test.suitebuilder.annotation.LargeTest;
@@ -84,7 +86,9 @@
import org.easymock.IAnswer;
import java.io.File;
+import java.util.ArrayList;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -126,8 +130,16 @@
private long mStartTime;
private long mElapsedRealtime;
- private static final int UID_A = android.os.Process.FIRST_APPLICATION_UID + 800;
- private static final int UID_B = android.os.Process.FIRST_APPLICATION_UID + 801;
+ private static final int USER_ID = 0;
+ private static final int USER_ID_GUEST = 1;
+
+ private static final int APP_ID_A = android.os.Process.FIRST_APPLICATION_UID + 800;
+ private static final int APP_ID_B = android.os.Process.FIRST_APPLICATION_UID + 801;
+
+ private static final int UID_A = UserId.getUid(USER_ID, APP_ID_A);
+ private static final int UID_B = UserId.getUid(USER_ID, APP_ID_B);
+ private static final int UID_A_GUEST = UserId.getUid(USER_ID_GUEST, APP_ID_A);
+ private static final int UID_B_GUEST = UserId.getUid(USER_ID_GUEST, APP_ID_B);
private static final int PID_1 = 400;
private static final int PID_2 = 401;
@@ -161,6 +173,14 @@
info.signatures = new Signature[] { signature };
return info;
}
+
+ @Override
+ public List<UserInfo> getUsers() {
+ final ArrayList<UserInfo> users = new ArrayList<UserInfo>();
+ users.add(new UserInfo(USER_ID, "Primary", UserInfo.FLAG_PRIMARY));
+ users.add(new UserInfo(USER_ID_GUEST, "Guest", 0));
+ return users;
+ }
};
}
@@ -242,13 +262,13 @@
@Suppress
public void testPolicyChangeTriggersBroadcast() throws Exception {
- mService.setAppPolicy(UID_A, POLICY_NONE);
+ mService.setAppPolicy(APP_ID_A, POLICY_NONE);
// change background policy and expect broadcast
final Future<Intent> backgroundChanged = mServiceContext.nextBroadcastIntent(
ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
- mService.setAppPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
+ mService.setAppPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
backgroundChanged.get();
}
@@ -302,6 +322,7 @@
public void testScreenChangesRules() throws Exception {
Future<Void> future;
+ Future<Void> futureGuest;
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, true);
@@ -314,10 +335,14 @@
// push strict policy for foreground uid, verify ALLOW rule
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, true);
+ expectSetUidNetworkRules(UID_A_GUEST, true);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_REJECT_METERED);
replay();
- mService.setAppPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
+ mService.setAppPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
future.get();
+ futureGuest.get();
verifyAndReset();
// now turn screen off and verify REJECT rule
@@ -343,6 +368,7 @@
public void testPolicyNone() throws Exception {
Future<Void> future;
+ Future<Void> futureGuest;
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, true);
@@ -355,10 +381,14 @@
// POLICY_NONE should RULE_ALLOW in foreground
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, true);
+ expectSetUidNetworkRules(UID_A_GUEST, false);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_ALLOW_ALL);
replay();
- mService.setAppPolicy(UID_A, POLICY_NONE);
+ mService.setAppPolicy(APP_ID_A, POLICY_NONE);
future.get();
+ futureGuest.get();
verifyAndReset();
// POLICY_NONE should RULE_ALLOW in background
@@ -373,14 +403,19 @@
public void testPolicyReject() throws Exception {
Future<Void> future;
+ Future<Void> futureGuest;
// POLICY_REJECT should RULE_ALLOW in background
expectSetUidNetworkRules(UID_A, true);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, true);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_REJECT_METERED);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_REJECT_METERED);
replay();
- mService.setAppPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
+ mService.setAppPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
future.get();
+ futureGuest.get();
verifyAndReset();
// POLICY_REJECT should RULE_ALLOW in foreground
@@ -404,33 +439,46 @@
public void testPolicyRejectAddRemove() throws Exception {
Future<Void> future;
+ Future<Void> futureGuest;
// POLICY_NONE should have RULE_ALLOW in background
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, false);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_ALLOW_ALL);
replay();
mProcessObserver.onForegroundActivitiesChanged(PID_1, UID_A, false);
- mService.setAppPolicy(UID_A, POLICY_NONE);
+ mService.setAppPolicy(APP_ID_A, POLICY_NONE);
future.get();
+ futureGuest.get();
verifyAndReset();
// adding POLICY_REJECT should cause RULE_REJECT
expectSetUidNetworkRules(UID_A, true);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, true);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_REJECT_METERED);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_REJECT_METERED);
replay();
- mService.setAppPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
+ mService.setAppPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
future.get();
+ futureGuest.get();
verifyAndReset();
// removing POLICY_REJECT should return us to RULE_ALLOW
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, false);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_ALLOW_ALL);
replay();
- mService.setAppPolicy(UID_A, POLICY_NONE);
+ mService.setAppPolicy(APP_ID_A, POLICY_NONE);
future.get();
+ futureGuest.get();
verifyAndReset();
}
@@ -599,25 +647,34 @@
public void testUidRemovedPolicyCleared() throws Exception {
Future<Void> future;
+ Future<Void> futureGuest;
// POLICY_REJECT should RULE_REJECT in background
expectSetUidNetworkRules(UID_A, true);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, true);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_REJECT_METERED);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_REJECT_METERED);
replay();
- mService.setAppPolicy(UID_A, POLICY_REJECT_METERED_BACKGROUND);
+ mService.setAppPolicy(APP_ID_A, POLICY_REJECT_METERED_BACKGROUND);
future.get();
+ futureGuest.get();
verifyAndReset();
// uninstall should clear RULE_REJECT
expectSetUidNetworkRules(UID_A, false);
expectSetUidForeground(UID_A, false);
+ expectSetUidNetworkRules(UID_A_GUEST, false);
+ expectSetUidForeground(UID_A_GUEST, false);
future = expectRulesChanged(UID_A, RULE_ALLOW_ALL);
+ futureGuest = expectRulesChanged(UID_A_GUEST, RULE_ALLOW_ALL);
replay();
final Intent intent = new Intent(ACTION_UID_REMOVED);
intent.putExtra(EXTRA_UID, UID_A);
mServiceContext.sendBroadcast(intent);
future.get();
+ futureGuest.get();
verifyAndReset();
}