1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.permission.cts; 18 19 import android.content.pm.ApplicationInfo; 20 import android.content.pm.PackageManager; 21 import android.test.AndroidTestCase; 22 23 import java.util.HashSet; 24 import java.util.List; 25 import java.util.Set; 26 27 /** 28 * Verify that pre-installed packages don't have the debuggable 29 * flag set. The debuggable flag allows should only be used during 30 * development, and never for shipping devices. 31 */ 32 public class DebuggableTest extends AndroidTestCase { 33 34 public void testNoDebuggable() { 35 Set<String> debuggableApps = new HashSet<String>(); 36 List<ApplicationInfo> apps = getContext() 37 .getPackageManager() 38 .getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); 39 for (ApplicationInfo app : apps) { 40 String appName = app.packageName; 41 if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE) { 42 debuggableApps.add(appName); 43 } 44 } 45 assertTrue("Packages marked debuggable: " + debuggableApps, debuggableApps.isEmpty()); 46 } 47 } 48