OSDN Git Service

Remove/fix broken test due to change to DUMP permission check.
authorMakoto Onuki <omakoto@google.com>
Mon, 3 Apr 2017 18:24:25 +0000 (11:24 -0700)
committerMakoto Onuki <omakoto@google.com>
Mon, 3 Apr 2017 20:00:39 +0000 (13:00 -0700)
Bug 36854321
Test: adb shell am instrument -e class 'com.android.server.pm.ShortcutManagerTest2' -w com.android.frameworks.servicestests

Change-Id: I80f2a326b70f8d0598246732510e3725a0c58871

services/core/java/com/android/server/pm/ShortcutService.java
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java

index 9bf6895..dfc547e 100644 (file)
@@ -3449,6 +3449,11 @@ public class ShortcutService extends IShortcutService.Stub {
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw)) return;
+        dumpNoCheck(fd, pw, args);
+    }
+
+    @VisibleForTesting
+    void dumpNoCheck(FileDescriptor fd, PrintWriter pw, String[] args) {
         boolean checkin = false;
         boolean clear = false;
         if (args != null) {
index 0f51c49..4b91138 100644 (file)
@@ -1276,7 +1276,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
         try {
             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             final PrintWriter pw = new PrintWriter(out);
-            mService.dump(/* fd */ null, pw, args);
+            mService.dumpNoCheck(/* fd */ null, pw, args);
             pw.close();
 
             return out.toString();
index 7c5eb07..33d15d4 100644 (file)
@@ -2096,16 +2096,6 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
         assertEquals(expected, dumpCheckin());
     }
 
-    public void testDumpsysNoPermission() {
-        assertExpectException(SecurityException.class, "android.permission.DUMP",
-                () -> mService.dump(null, new PrintWriter(new StringWriter()), null));
-
-        // System can call it without the permission.
-        runWithSystemUid(() -> {
-            mService.dump(null, new PrintWriter(new StringWriter()), null);
-        });
-    }
-
     /**
      * Make sure the legacy file format that only supported a single intent per shortcut
      * can still be read.