- 图库
frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
修改
public void grantDefaultPermissions(int userId) {DelayingPackageManagerCache pm = new DelayingPackageManagerCache();grantPermissionsToSysComponentsAndPrivApps(pm, userId);grantDefaultSystemHandlerPermissions(pm, userId);grantSignatureAppsNotificationPermissions(pm, userId);grantDefaultPermissionExceptions(pm, userId);// 给图库默认允许动态权限phone,locationgrantPermissionsToSystemPackage(NO_PM_CACHE, "com.android.gallery3d", userId,PHONE_PERMISSIONS, ALWAYS_LOCATION_PERMISSIONS);// Apply delayed statepm.apply();
}//默认声明的权限private static final Set<String> PHONE_PERMISSIONS = new ArraySet<>();static {PHONE_PERMISSIONS.add(Manifest.permission.READ_PHONE_STATE);PHONE_PERMISSIONS.add(Manifest.permission.CALL_PHONE);PHONE_PERMISSIONS.add(Manifest.permission.READ_CALL_LOG);PHONE_PERMISSIONS.add(Manifest.permission.WRITE_CALL_LOG);PHONE_PERMISSIONS.add(Manifest.permission.ADD_VOICEMAIL);PHONE_PERMISSIONS.add(Manifest.permission.USE_SIP);PHONE_PERMISSIONS.add(Manifest.permission.PROCESS_OUTGOING_CALLS);
}private static final Set<String> CONTACTS_PERMISSIONS = new ArraySet<>();
static {CONTACTS_PERMISSIONS.add(Manifest.permission.READ_CONTACTS);CONTACTS_PERMISSIONS.add(Manifest.permission.WRITE_CONTACTS);CONTACTS_PERMISSIONS.add(Manifest.permission.GET_ACCOUNTS);
}private static final Set<String> ALWAYS_LOCATION_PERMISSIONS = new ArraySet<>();
static {ALWAYS_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_FINE_LOCATION);ALWAYS_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_COARSE_LOCATION);ALWAYS_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
}private static final Set<String> FOREGROUND_LOCATION_PERMISSIONS = new ArraySet<>();
static {FOREGROUND_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_FINE_LOCATION);FOREGROUND_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}private static final Set<String> COARSE_BACKGROUND_LOCATION_PERMISSIONS = new ArraySet<>();
static {COARSE_BACKGROUND_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_COARSE_LOCATION);COARSE_BACKGROUND_LOCATION_PERMISSIONS.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
}private static final Set<String> ACTIVITY_RECOGNITION_PERMISSIONS = new ArraySet<>();
static {ACTIVITY_RECOGNITION_PERMISSIONS.add(Manifest.permission.ACTIVITY_RECOGNITION);
}private static final Set<String> CALENDAR_PERMISSIONS = new ArraySet<>();
static {CALENDAR_PERMISSIONS.add(Manifest.permission.READ_CALENDAR);CALENDAR_PERMISSIONS.add(Manifest.permission.WRITE_CALENDAR);
}private static final Set<String> SMS_PERMISSIONS = new ArraySet<>();
static {SMS_PERMISSIONS.add(Manifest.permission.SEND_SMS);SMS_PERMISSIONS.add(Manifest.permission.RECEIVE_SMS);SMS_PERMISSIONS.add(Manifest.permission.READ_SMS);SMS_PERMISSIONS.add(Manifest.permission.RECEIVE_WAP_PUSH);SMS_PERMISSIONS.add(Manifest.permission.RECEIVE_MMS);SMS_PERMISSIONS.add(Manifest.permission.READ_CELL_BROADCASTS);
}private static final Set<String> MICROPHONE_PERMISSIONS = new ArraySet<>();
static {MICROPHONE_PERMISSIONS.add(Manifest.permission.RECORD_AUDIO);
}private static final Set<String> CAMERA_PERMISSIONS = new ArraySet<>();
static {CAMERA_PERMISSIONS.add(Manifest.permission.CAMERA);
}private static final Set<String> SENSORS_PERMISSIONS = new ArraySet<>();
static {SENSORS_PERMISSIONS.add(Manifest.permission.BODY_SENSORS);SENSORS_PERMISSIONS.add(Manifest.permission.BODY_SENSORS_BACKGROUND);
}private static final Set<String> STORAGE_PERMISSIONS = new ArraySet<>();
static {STORAGE_PERMISSIONS.add(Manifest.permission.READ_EXTERNAL_STORAGE);STORAGE_PERMISSIONS.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);STORAGE_PERMISSIONS.add(Manifest.permission.ACCESS_MEDIA_LOCATION);STORAGE_PERMISSIONS.add(Manifest.permission.READ_MEDIA_AUDIO);STORAGE_PERMISSIONS.add(Manifest.permission.READ_MEDIA_VIDEO);STORAGE_PERMISSIONS.add(Manifest.permission.READ_MEDIA_IMAGES);
}private static final Set<String> NEARBY_DEVICES_PERMISSIONS = new ArraySet<>();
static {NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_ADVERTISE);NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_CONNECT);NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_SCAN);NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.UWB_RANGING);NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.NEARBY_WIFI_DEVICES);
}private static final Set<String> NOTIFICATION_PERMISSIONS = new ArraySet<>();
static {NOTIFICATION_PERMISSIONS.add(Manifest.permission.POST_NOTIFICATIONS);
}