From 3521f368d2166c3a9e8f6fc6855d92fd48985500 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 19 Jan 2014 12:27:20 +0100 Subject: [PATCH] Replace meta.xml by Meta class --- assets/meta.xml | 238 ------------------ src/biz/bokhorst/xprivacy/ActivityMain.java | 7 +- src/biz/bokhorst/xprivacy/Meta.java | 221 ++++++++++++++++ src/biz/bokhorst/xprivacy/PackageChange.java | 4 - src/biz/bokhorst/xprivacy/PrivacyManager.java | 159 +++--------- 5 files changed, 258 insertions(+), 371 deletions(-) delete mode 100644 assets/meta.xml create mode 100644 src/biz/bokhorst/xprivacy/Meta.java diff --git a/assets/meta.xml b/assets/meta.xml deleted file mode 100644 index fb5925c41..000000000 --- a/assets/meta.xml +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index 030d9158f..334543928 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -131,13 +131,8 @@ public void onReceive(Context context, Intent intent) { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - // Update meta data - PrivacyManager.writeMetaData(this); - PrivacyManager.readMetaData(); - // Check privacy service client - if (!Util.isXposedEnabled() || !PrivacyManager.hasMetaData() || PrivacyService.getClient() == null) { + if (!Util.isXposedEnabled() || PrivacyService.getClient() == null) { setContentView(R.layout.reboot); Requirements.check(this); mPackageChangeReceiver = null; diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java new file mode 100644 index 000000000..a210c94d7 --- /dev/null +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -0,0 +1,221 @@ +package biz.bokhorst.xprivacy; + +import java.util.ArrayList; +import java.util.List; + +public class Meta { + public static List get() { + List listHook = new ArrayList(); + // @formatter:off + listHook.add(new PrivacyManager.Hook("accounts", "addOnAccountsUpdatedListener", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "blockingGetAuthToken", false, false, "USE_CREDENTIALS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAccounts", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAccountsByType", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAccountsByTypeAndFeatures", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAuthToken", false, false, "USE_CREDENTIALS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAuthTokenByFeatures", false, false, "MANAGE_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "hasFeatures", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "removeOnAccountsUpdatedListener", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getAccountsByTypeForPackage", false, false, "GET_ACCOUNTS", 18, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getTokenGoogle", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("accounts", "getTokenWithNotificationGoogle", false, false, "GET_ACCOUNTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("browser", "BrowserProvider", false, false, "READ_HISTORY_BOOKMARKS,GLOBAL_SEARCH", 10, null, null)); + listHook.add(new PrivacyManager.Hook("browser", "BrowserProvider2", false, false, "READ_HISTORY_BOOKMARKS,GLOBAL_SEARCH", 14, null, null)); + listHook.add(new PrivacyManager.Hook("calendar", "CalendarProvider2", false, false, "READ_CALENDAR", 10, null, null)); + listHook.add(new PrivacyManager.Hook("calling", "sendDataMessage", false, false, "SEND_SMS", 4, null, null)); + listHook.add(new PrivacyManager.Hook("calling", "sendMultipartTextMessage", false, false, "SEND_SMS", 4, null, null)); + listHook.add(new PrivacyManager.Hook("calling", "sendTextMessage", false, false, "SEND_SMS", 4, null, null)); + listHook.add(new PrivacyManager.Hook("calling", "android.intent.action.RESPOND_VIA_MESSAGE", false, false, "SEND_RESPOND_VIA_MESSAGE", 18, null, null)); + listHook.add(new PrivacyManager.Hook("calling", "android.intent.action.CALL", false, false, "CALL_PHONE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "addPrimaryClipChangedListener", false, false, "", 11, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "getPrimaryClip", false, false, "", 11, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "getPrimaryClipDescription", false, false, "", 11, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "getText", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "hasPrimaryClip", false, false, "", 11, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "hasText", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("clipboard", "removePrimaryClipChangedListener", false, false, "", 11, null, null)); + listHook.add(new PrivacyManager.Hook("contacts", "contacts/contacts", false, false, "READ_CONTACTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("contacts", "contacts/data", false, false, "READ_CONTACTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("contacts", "contacts/raw_contacts", false, false, "READ_CONTACTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("contacts", "contacts/phone_lookup", false, false, "READ_CONTACTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("contacts", "contacts/profile", false, false, "READ_CONTACTS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("dictionary", "UserDictionary", false, false, "READ_USER_DICTIONARY", 10, null, null)); + listHook.add(new PrivacyManager.Hook("email", "EMailProvider", false, false, "com.android.email.permission.ACCESS_PROVIDER", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "%hostname", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "%imei", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "%macaddr", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "%serialno", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "%cid", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "/proc", true, false, "", 10, "1.7", null)); + listHook.add(new PrivacyManager.Hook("identification", "/system/build.prop", true, false, "", 10, "1.9.9", null)); + listHook.add(new PrivacyManager.Hook("identification", "/sys/block/.../cid", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "/sys/class/.../cid", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "AdvertisingId", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "getString", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "getDescriptor", false, false, "", 16, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "GservicesProvider", true, false, "READ_GSERVICES", 10, null, null)); + listHook.add(new PrivacyManager.Hook("identification", "SERIAL", false, true, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getAllByName", false, false, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getByAddress", false, false, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getByName", false, false, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getByInetAddress", false, false, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getNetworkInterfaces", false, false, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "inet", true, true, "INTERNET", 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getActiveNetworkInfo", true, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getAllNetworkInfo", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getNetworkInfo", true, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getDetailedState", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getState", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "isConnected", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "isConnectedOrConnecting", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("internet", "getConnectionInfo", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.accounts.IAccountManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.app.IActivityManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.content.IClipboard", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.net.IConnectivityManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.location.ILocationManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "com.android.internal.telephony.ITelephonyRegistry", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.content.pm.IPackageManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "com.android.internal.telephony.IPhoneSubInfo", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.view.IWindowManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("ipc", "android.net.wifi.IWifiManager", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("location", "addNmeaListener", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "addProximityAlert", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getLastKnownLocation", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getProviders", true, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "isProviderEnabled", true, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "removeUpdates", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "requestLocationUpdates", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "requestSingleUpdate", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "sendExtraCommand", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "addGeofence", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 17, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getLastLocation", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 17, null, null)); + listHook.add(new PrivacyManager.Hook("location", "disableLocationUpdates", false, false, "CONTROL_LOCATION_UPDATES", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "enableLocationUpdates", false, false, "CONTROL_LOCATION_UPDATES", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getCellLocation", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getNeighboringCellInfo", false, false, "ACCESS_COARSE_UPDATES", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getAllCellInfo", false, false, "ACCESS_COARSE_UPDATES", 17, null, null)); + listHook.add(new PrivacyManager.Hook("location", "getScanResults", true, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "listen", false, false, "ACCESS_COARSE_LOCATION", 10, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.addGeofences", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.connect", true, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.getLastLocation", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.removeGeofences", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.removeLocationUpdates", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("location", "GMS.requestLocationUpdates", false, false, "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 0, null, null)); + listHook.add(new PrivacyManager.Hook("media", "startRecording", false, false, "RECORD_AUDIO", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "setPreviewCallback", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "setPreviewCallbackWithBuffer", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "setOneShotPreviewCallback", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "takePicture", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "setOutputFile", false, false, "RECORD_AUDIO,RECORD_VIDEO", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "android.media.action.IMAGE_CAPTURE", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("media", "android.media.action.IMAGE_CAPTURE_SECURE", false, false, "CAMERA", 17, null, null)); + listHook.add(new PrivacyManager.Hook("media", "android.media.action.VIDEO_CAPTURE", false, false, "CAMERA", 10, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "getAllMessagesFromIcc", false, false, "RECEIVE_SMS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "SmsProvider", false, false, "READ_SMS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "MmsProvider", false, false, "READ_SMS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "MmsSmsProvider", false, false, "READ_SMS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "VoicemailContentProvider", false, false, "READ_WRITE_ALL_VOICEMAIL", 14, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "android.intent.action.DATA_SMS_RECEIVED", false, false, "RECEIVE_SMS", 19, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "android.provider.Telephony.SMS_RECEIVED", false, false, "RECEIVE_SMS", 19, null, null)); + listHook.add(new PrivacyManager.Hook("messages", "android.provider.Telephony.WAP_PUSH_RECEIVED", false, false, "RECEIVE_WAP_PUSH", 19, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getAddress", false, false, "BLUETOOTH", 5, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getBondedDevices", false, false, "BLUETOOTH", 5, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getHardwareAddress", false, false, "ACCESS_NETWORK_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getInetAddresses", false, false, "ACCESS_NETWORK_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getInterfaceAddresses", false, false, "ACCESS_NETWORK_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getConfiguredNetworks", false, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getConnectionInfo", false, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getDhcpInfo", false, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getScanResults", false, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("network", "getWifiApConfiguration", false, false, "ACCESS_WIFI_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "getNfcAdapter", false, false, "NFC", 14, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "getDefaultAdapter", false, false, "NFC", 10, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "android.nfc.action.ADAPTER_STATE_CHANGED", false, false, "NFC", 18, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "android.nfc.action.NDEF_DISCOVERED", false, false, "NFC", 10, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "android.nfc.action.TAG_DISCOVERED", false, false, "NFC", 10, null, null)); + listHook.add(new PrivacyManager.Hook("nfc", "android.nfc.action.TECH_DISCOVERED", false, false, "NFC", 10, null, null)); + listHook.add(new PrivacyManager.Hook("notifications", "android.service.notification.NotificationListenerService", false, false, "BIND_NOTIFICATION_LISTENER_SERVICE", 18, null, null)); + listHook.add(new PrivacyManager.Hook("notifications", "com.google.android.c2dm.intent.REGISTRATION", true, false, "com.google.android.c2dm.permission.RECEIVE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("notifications", "com.google.android.c2dm.intent.RECEIVE", true, false, "com.google.android.c2dm.permission.RECEIVE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("overlay", "addView", false, false, "SYSTEM_ALERT_WINDOW", 1, null, null)); + listHook.add(new PrivacyManager.Hook("overlay", "removeView", false, false, "SYSTEM_ALERT_WINDOW", 1, null, null)); + listHook.add(new PrivacyManager.Hook("overlay", "updateViewLayout", false, false, "SYSTEM_ALERT_WINDOW", 1, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getDeviceId", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getIsimDomain", false, false, "READ_PRIVILEGED_PHONE_STATE", 14, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getIsimImpi", false, false, "READ_PRIVILEGED_PHONE_STATE", 14, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getIsimImpu", false, false, "READ_PRIVILEGED_PHONE_STATE", 14, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getLine1AlphaTag", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getLine1Number", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getMsisdn", false, false, "READ_PHONE_STATE", 14, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getSimSerialNumber", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getSubscriberId", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getVoiceMailAlphaTag", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getVoiceMailNumber", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "listen", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getNetworkType", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getPhoneType", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "getGroupIdLevel1", false, false, "READ_PHONE_STATE", 18, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "android.intent.action.NEW_OUTGOING_CALL", false, false, "PROCESS_OUTGOING_CALLS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "android.intent.action.PHONE_STATE", false, false, "READ_PHONE_STATE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "TelephonyProvider", false, false, "WRITE_APN_SETTINGS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "CallLogProvider", false, false, "READ_CALL_LOG", 10, null, null)); + listHook.add(new PrivacyManager.Hook("phone", "gsm.operator.iso-country", false, false, "", 10, "1.99.1", "getNetworkCountryIso")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.operator.numeric", false, false, "", 10, "1.99.1", "getNetworkOperator")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.operator.alpha", false, false, "", 10, "1.99.1", "getNetworkOperatorName")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.current.phone-type", false, false, "", 10, "1.99.1", "")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.sim.operator.iso-country", false, false, "", 10, "1.99.1", "getSimCountryIso")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.sim.operator.numeric", false, false, "", 10, "1.99.1", "getSimOperator")); + listHook.add(new PrivacyManager.Hook("phone", "gsm.sim.operator.alpha", false, false, "", 10, "1.99.1", "getSimOperatorName")); + listHook.add(new PrivacyManager.Hook("sensors", "getDefaultSensor", false, false, "", 3, null, null)); + listHook.add(new PrivacyManager.Hook("sensors", "getSensorList", false, false, "", 3, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "sh", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "su", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "exec", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "load", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "loadLibrary", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("shell", "start", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("storage", "media", true, true, "WRITE_MEDIA_STORAGE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("storage", "sdcard", true, true, "READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE", 10, null, null)); + listHook.add(new PrivacyManager.Hook("storage", "getExternalStorageState", false, false, null, 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getInstalledApplications", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getInstalledPackages", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getPackagesHoldingPermissions", true, false, "", 1, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("system", "getPreferredPackages", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "queryBroadcastReceivers", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "queryContentProviders", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "queryIntentActivities", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "queryIntentActivityOptions", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "queryIntentContentProviders", true, false, "", 19, "1.99.1", null)); + listHook.add(new PrivacyManager.Hook("system", "queryIntentServices", true, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getInstalledProviders", true, false, "", 3, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getRecentTasks", true, false, "GET_TASKS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getRunningAppProcesses", true, false, "GET_TASKS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getRunningServices", true, false, "GET_TASKS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "getRunningTasks", true, false, "GET_TASKS", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_ADDED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_REPLACED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_RESTARTED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_REMOVED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_CHANGED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_DATA_CLEARED", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_FIRST_LAUNCH", true, false, "", 12, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_FULLY_REMOVED", true, false, "", 14, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_NEEDS_VERIFICATION", true, false, "", 14, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.PACKAGE_VERIFIED", true, false, "", 17, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE", true, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("system", "ApplicationsProvider", false, false, "", 10, null, null)); + listHook.add(new PrivacyManager.Hook("view", "loadUrl", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "WebView", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "getDefaultUserAgent", false, false, "", 17, null, null)); + listHook.add(new PrivacyManager.Hook("view", "getUserAgent", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "getUserAgentString", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "setUserAgent", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "setUserAgentString", false, false, "", 1, null, null)); + listHook.add(new PrivacyManager.Hook("view", "android.intent.action.VIEW", false, false, "", 10, null, null)); + // @formatter:on + return listHook; + } +} \ No newline at end of file diff --git a/src/biz/bokhorst/xprivacy/PackageChange.java b/src/biz/bokhorst/xprivacy/PackageChange.java index 3fb8acae7..fcc16f70d 100644 --- a/src/biz/bokhorst/xprivacy/PackageChange.java +++ b/src/biz/bokhorst/xprivacy/PackageChange.java @@ -122,10 +122,6 @@ public void onReceive(final Context context, Intent intent) { // Notify reboot required String packageName = inputUri.getSchemeSpecificPart(); if (packageName.equals(context.getPackageName())) { - // Update meta data - PrivacyManager.writeMetaData(context); - PrivacyManager.readMetaData(); - // Build notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context); notificationBuilder.setSmallIcon(R.drawable.ic_launcher); diff --git a/src/biz/bokhorst/xprivacy/PrivacyManager.java b/src/biz/bokhorst/xprivacy/PrivacyManager.java index 9a01dc568..685c3f40c 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyManager.java +++ b/src/biz/bokhorst/xprivacy/PrivacyManager.java @@ -1,10 +1,5 @@ package biz.bokhorst.xprivacy; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; import java.lang.reflect.Field; import java.net.Inet4Address; import java.net.InetAddress; @@ -22,14 +17,6 @@ import java.util.TreeMap; import java.util.UUID; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageInfo; @@ -134,119 +121,45 @@ public class PrivacyManager { public final static int cUseProviderAfterMs = 3 * 60 * 1000; // Static data - private static boolean mMetaData = false; - private static Map> mMethod; - private static Map> mPermission; + private static Map> mMethod = new LinkedHashMap>(); + private static Map> mPermission = new LinkedHashMap>(); private static Map mSettingsCache = new HashMap(); private static Map mRestrictionCache = new HashMap(); - static { - readMetaData(); - } - - public static void writeMetaData(Context context) { - // Write meta data - // TODO: find a way to get the meta data without context - try { - File out = new File(Util.getUserDataDirectory(Process.myUid()) + File.separator + "meta.xml"); - Util.log(null, Log.WARN, "Writing meta=" + out.getAbsolutePath()); - InputStream is = context.getAssets().open("meta.xml"); - OutputStream os = new FileOutputStream(out.getAbsolutePath()); - byte[] buffer = new byte[1024]; - int read; - while ((read = is.read(buffer)) != -1) - os.write(buffer, 0, read); - is.close(); - os.flush(); - os.close(); - out.setReadable(true, false); - } catch (Throwable ex) { - Util.bug(null, ex); - } - } - - public static void readMetaData() { - // Reset meta data - mMethod = new LinkedHashMap>(); - mPermission = new LinkedHashMap>(); - - // Read meta data - try { - File in = new File(Util.getUserDataDirectory(Process.myUid()) + File.separator + "meta.xml"); - if (in.exists()) { - Util.log(null, Log.INFO, "Reading meta=" + in.getAbsolutePath()); - FileInputStream fis = null; - try { - fis = new FileInputStream(in); - XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); - MetaHandler metaHandler = new MetaHandler(); - xmlReader.setContentHandler(metaHandler); - xmlReader.parse(new InputSource(fis)); - mMetaData = true; - } finally { - if (fis != null) - fis.close(); - } - } else - Util.log(null, Log.WARN, "Not found meta=" + in.getAbsolutePath()); - } catch (Throwable ex) { - Util.bug(null, ex); - } - } - - public static boolean hasMetaData() { - return mMetaData; - } + // Meta data - private static class MetaHandler extends DefaultHandler { - @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if (qName.equals("Meta")) - ; - else if (qName.equals("Hook")) { - // Get meta data - String restrictionName = attributes.getValue("restriction"); - String methodName = attributes.getValue("method"); - String dangerous = attributes.getValue("dangerous"); - String restart = attributes.getValue("restart"); - String permissions = attributes.getValue("permissions"); - int sdk = (attributes.getValue("sdk") == null ? 0 : Integer.parseInt(attributes.getValue("sdk"))); - String from = attributes.getValue("from"); - String replaces = attributes.getValue("replaces"); - - // Add meta data - if (Build.VERSION.SDK_INT >= sdk) { - boolean danger = (dangerous == null ? false : Boolean.parseBoolean(dangerous)); - boolean restartRequired = (restart == null ? false : Boolean.parseBoolean(restart)); - String[] permission = (permissions == null ? null : permissions.split(",")); - Hook md = new Hook(restrictionName, methodName, danger, restartRequired, permission, sdk, - from == null ? null : new Version(from), replaces); - - if (!mMethod.containsKey(restrictionName)) - mMethod.put(restrictionName, new ArrayList()); - - if (!mMethod.get(restrictionName).contains(methodName)) - mMethod.get(restrictionName).add(md); - - if (permission != null) - for (String perm : permission) - if (!perm.equals("")) { - String aPermission = (perm.contains(".") ? perm : "android.permission." + perm); - if (!mPermission.containsKey(aPermission)) - mPermission.put(aPermission, new ArrayList()); - if (!mPermission.get(aPermission).contains(md)) - mPermission.get(aPermission).add(md); - } - } - } else - Util.log(null, Log.WARN, "Unknown element=" + qName); - } + static { + List listRestriction = getRestrictions(); + + for (Hook hook : Meta.get()) + if (Build.VERSION.SDK_INT >= hook.getSdk()) { + String restrictionName = hook.getRestrictionName(); + + // Check restriction + if (!listRestriction.contains(restrictionName)) + Util.log(null, Log.WARN, "Not found restriction=" + restrictionName); + + // Enlist method + if (!mMethod.containsKey(restrictionName)) + mMethod.put(restrictionName, new ArrayList()); + mMethod.get(restrictionName).add(hook); + + // Enlist permissions + String[] permissions = hook.getPermissions(); + if (permissions != null) + for (String perm : permissions) + if (!perm.equals("")) { + String aPermission = (perm.contains(".") ? perm : "android.permission." + perm); + if (!mPermission.containsKey(aPermission)) + mPermission.put(aPermission, new ArrayList()); + if (!mPermission.get(aPermission).contains(hook)) + mPermission.get(aPermission).add(hook); + } + } } - // Meta data - public static void registerMethod(String restrictionName, String methodName, int sdk) { - if (hasMetaData() && restrictionName != null && methodName != null && Build.VERSION.SDK_INT >= sdk) { + if (restrictionName != null && methodName != null && Build.VERSION.SDK_INT >= sdk) { if (!mMethod.containsKey(restrictionName) || !mMethod.get(restrictionName).contains(new Hook(restrictionName, methodName))) Util.log(null, Log.WARN, "Missing method " + methodName); @@ -1070,15 +983,15 @@ public Hook(String restrictionName, String methodName) { mMethodName = methodName; } - public Hook(String restrictionName, String methodName, boolean dangerous, boolean restart, - String[] permissions, int sdk, Version from, String replaces) { + public Hook(String restrictionName, String methodName, boolean dangerous, boolean restart, String permissions, + int sdk, String from, String replaces) { mRestrictionName = restrictionName; mMethodName = methodName; mDangerous = dangerous; mRestart = restart; - mPermissions = permissions; + mPermissions = (permissions == null ? null : permissions.split(",")); mSdk = sdk; - mFrom = from; + mFrom = (from == null ? null : new Version(from)); mReplaces = replaces; }