file_name stringlengths 6 86 | file_path stringlengths 45 249 | content stringlengths 47 6.26M | file_size int64 47 6.26M | language stringclasses 1 value | extension stringclasses 1 value | repo_name stringclasses 767 values | repo_stars int64 8 14.4k | repo_forks int64 0 1.17k | repo_open_issues int64 0 788 | repo_created_at stringclasses 767 values | repo_pushed_at stringclasses 767 values |
|---|---|---|---|---|---|---|---|---|---|---|---|
BusinessRespBuffer.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/BusinessRespBuffer.java | package com.tencent.mobileqq.profilecard.entity;
import android.util.SparseArray;
import com.tencent.mobileqq.profilecard.SummaryCardBusiEntry;
import java.util.ArrayList;
public class BusinessRespBuffer {
public byte[] buffer;
public SummaryCardBusiEntry.comm comm;
public BusinessRespBuffer(SummaryCardBusiEntry.comm comm, byte[] bArr) {
this.comm = comm;
this.buffer = bArr;
}
public static SparseArray<BusinessRespBuffer> parseBusinessRespBuffer(ArrayList<byte[]> arrayList) {
SparseArray<BusinessRespBuffer> sparseArray = new SparseArray<>();
return sparseArray;
}
} | 633 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileGroupLabel.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/ProfileGroupLabel.java | package com.tencent.mobileqq.profilecard.entity;
public class ProfileGroupLabel {
public String strWording = "";
public ProfileColor textColor = null;
public long type = 0;
public long attr = 0;
public ProfileColor edgingColor = null;
} | 257 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileColor.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/ProfileColor.java | package com.tencent.mobileqq.profilecard.entity;
public class ProfileColor {
public long red = 0;
public long green = 0;
public long blue = 0;
} | 157 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileSummaryHobbiesItem.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/ProfileSummaryHobbiesItem.java | package com.tencent.mobileqq.profilecard.entity;
import java.util.ArrayList;
public class ProfileSummaryHobbiesItem {
public static final int SERVICE_TYPE_TROOP = 5;
public long groupCode;
public ArrayList<ProfileGroupLabel> labels;
public int service;
public int serviceType;
public String strCoverUrl;
public String strDesc;
public String strJmpUrl;
public String strSubInfo;
public String strTitle;
public String strTitleIconUrl;
} | 480 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
BusinessReqBuffer.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/BusinessReqBuffer.java | package com.tencent.mobileqq.profilecard.entity;
import android.os.Parcel;
import android.os.Parcelable;
public class BusinessReqBuffer implements Parcelable {
public static final Parcelable.Creator<BusinessReqBuffer> CREATOR = new Parcelable.Creator<BusinessReqBuffer>() { // from class: com.tencent.mobileqq.profilecard.entity.BusinessReqBuffer.1
@Override
public BusinessReqBuffer createFromParcel(Parcel parcel) {
return new BusinessReqBuffer(parcel);
}
@Override //
public BusinessReqBuffer[] newArray(int i2) {
return new BusinessReqBuffer[i2];
}
};
private byte[] buffer;
private int businessType;
public BusinessReqBuffer(int i2, byte[] bArr) {
this.businessType = i2;
this.buffer = bArr;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public byte[] getBuffer() {
return this.buffer;
}
public int getBusinessType() {
return this.businessType;
}
public void setBuffer(byte[] bArr) {
this.buffer = bArr;
}
public void setBusinessType(int i2) {
this.businessType = i2;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i2) {
parcel.writeInt(this.businessType);
parcel.writeByteArray(this.buffer);
}
protected BusinessReqBuffer(Parcel parcel) {
this.businessType = parcel.readInt();
parcel.readByteArray(this.buffer);
}
} | 1,550 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileSummaryHobbiesEntry.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/entity/ProfileSummaryHobbiesEntry.java | package com.tencent.mobileqq.profilecard.entity;
import java.util.ArrayList;
public class ProfileSummaryHobbiesEntry {
public ArrayList<ProfileSummaryHobbiesItem> sProfileSummaryHobbiesItem;
public int serviceType;
public String strName;
public String strServiceType;
public String strServiceUrl;
} | 320 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IProfileProtocolService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/api/IProfileProtocolService.java | package com.tencent.mobileqq.profilecard.api;
import android.os.Bundle;
import com.tencent.mobileqq.profilecard.processor.AbsProfileBusinessProcessor;
import java.util.List;
import mqq.app.api.IRuntimeService;
public interface IProfileProtocolService extends IRuntimeService, IProfileProtocolConst {
<T extends AbsProfileBusinessProcessor> T getBusinessProcessor(Class<? extends AbsProfileBusinessProcessor> cls);
void getProfileDetail(String str, List<Short> list, int i2, Bundle bundle);
void getProfileDetailForEdit();
void getProfileDetailForLogin();
void requestProfileCard(Bundle bundle);
void requestProfileCard(String uin, String target, int i2, long j2, byte b2, long j3, long j4, byte[] bArr, String str3, long j5, int i3, byte[] bArr2, byte b3);
void setProfileDetail(Bundle bundle);
}
| 836 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IProfileProtocolConst.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/api/IProfileProtocolConst.java | package com.tencent.mobileqq.profilecard.api;
public interface IProfileProtocolConst {
public static final String CMD_GET_PROFILE_DETAIL = "OidbSvc.0x480_9_IMCore";
public static final String CMD_SET_PROFILE_DETAIL = "OidbSvc.0x4ff_9_IMCore";
public static final String KET_INTERESTS = "interests";
public static final String KEY_AGE = "age";
public static final String KEY_BIRTHDAY = "birthday";
public static final String KEY_COLLEGE = "college";
public static final String KEY_COMPANY = "company";
public static final String KEY_CONSTELLATION = "key_constellation";
public static final String KEY_EMAIL = "email";
public static final String KEY_HOMETOWN = "hometown";
public static final String KEY_HOMETOWN_DESC = "hometown_desc";
public static final String KEY_LOCATION = "location";
public static final String KEY_LOCATION_DESC = "location_desc";
public static final String KEY_LOCATION_NAME = "location_name";
public static final String KEY_NICK = "nick";
public static final String KEY_PARSE_PROFILE_LOCATION = "parse_profile_location";
public static final String KEY_PERSONAL_NOTE = "personalNote";
public static final String KEY_PROFESSION = "profession";
public static final String KEY_SEX = "sex";
public static final String PARAM_ADD_FRIEND_SOURCE = "addFriendSource";
public static final String PARAM_COME_FROM_TYPE = "comeFromType";
public static final String PARAM_GET_CONTROL = "getControl";
public static final String PARAM_IS_FRIEND = "isFriend";
public static final String PARAM_LOGIN_SIG = "loginSig";
public static final String PARAM_QZONE_FEED_TIMESTAMP = "qZoneFeedTimeStamp";
public static final String PARAM_QZONE_SEED = "qZoneSeed";
public static final String PARAM_REQ_0X5EB = "req0x5ebList";
public static final String PARAM_REQ_EXTEND = "reqExtendFriend";
public static final String PARAM_REQ_MEDAL = "reqMedalWall";
public static final String PARAM_REQ_SERVICES = "reqServiceList";
public static final String PARAM_REQ_TEMPLATE = "reqTemplate";
public static final String PARAM_SEARCH_NAME = "searchName";
public static final String PARAM_SECURE_SIG = "secureSig";
public static final String PARAM_SELF_UIN = "selfUin";
public static final String PARAM_TARGET_UIN = "targetUin";
public static final String PARAM_TROOP_CODE = "troopCode";
public static final String PARAM_TROOP_UIN = "troopUin";
} | 2,476 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IProfileDataService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/api/IProfileDataService.java | package com.tencent.mobileqq.profilecard.api;
import com.tencent.mobileqq.data.Card;
import com.tencent.mobileqq.data.ContactCard;
import mqq.app.api.IRuntimeService;
public interface IProfileDataService extends IRuntimeService {
ContactCard getContactCardByMobileNo(String uin, boolean isNoSimple);
Card getProfileCard(String uin, boolean isNoSimple);
Card getProfileCardFromCache(String str);
boolean saveContactCard(ContactCard contactCard);
boolean saveProfileCard(Card card);
} | 509 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IProfileCardBlacklistApi.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/api/IProfileCardBlacklistApi.java | package com.tencent.mobileqq.profilecard.api;
import com.tencent.mobileqq.profilecard.listener.CheckBlacklistListener;
import com.tencent.mobileqq.qroute.QRouteApi;
public interface IProfileCardBlacklistApi extends QRouteApi {
String getBlacklistTipMsg(String str);
int getProfileCardBlacklistReportType(String str);
boolean isBlackOrBlackedUin(String uin, CheckBlacklistListener checkBlacklistListener);
} | 422 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileCardObserver.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/observer/ProfileCardObserver.java | package com.tencent.mobileqq.profilecard.observer;
import com.tencent.mobileqq.app.BusinessObserver;
import com.tencent.mobileqq.data.Card;
public class ProfileCardObserver implements BusinessObserver {
@Override
public void onUpdate(int result, boolean success, Object obj) {
}
protected void onGetProfileCard(boolean z, Object obj) {
}
public void onGetProfileDetail(boolean z, String str, Card card) {
}
protected void onSetCardTemplateReturn(boolean z, Object obj) {
}
protected void onSetProfileDetail(boolean z, int i2, Card card) {
}
}
| 594 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IRequestProfileCardCallback.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/processor/IRequestProfileCardCallback.java | package com.tencent.mobileqq.profilecard.processor;
import android.os.Bundle;
import android.util.SparseArray;
import com.tencent.mobileqq.data.Card;
import com.tencent.mobileqq.profilecard.entity.BusinessReqBuffer;
import com.tencent.mobileqq.profilecard.entity.BusinessRespBuffer;
import java.util.ArrayList;
import SummaryCard.RespHead;
import SummaryCard.RespSummaryCard;
import tencent.im.oidb.cmd0x5eb.oidb_0x5eb;
public interface IRequestProfileCardCallback {
void onProcessProfile0x5eb(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard, oidb_0x5eb.UdcUinData oidb_0x5eb_udcuindata);
void onProcessProfileCard(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard);
void onProcessProfileService(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard, SparseArray<BusinessRespBuffer> sparseArray);
void onRequestProfileCard(Bundle bundle, ArrayList<BusinessReqBuffer> arrayList, ArrayList<Integer> arrayList2);
void onResponseProfileCard(boolean z, Bundle bundle, RespHead respHead, RespSummaryCard respSummaryCard);
}
| 1,126 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
AbsProfileBusinessProcessor.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/processor/AbsProfileBusinessProcessor.java | package com.tencent.mobileqq.profilecard.processor;
import android.os.Bundle;
import android.util.SparseArray;
import com.tencent.mobileqq.data.Card;
import com.tencent.mobileqq.profilecard.entity.BusinessReqBuffer;
import com.tencent.mobileqq.profilecard.entity.BusinessRespBuffer;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import SummaryCard.RespHead;
import SummaryCard.RespSummaryCard;
import mqq.app.AppRuntime;
import tencent.im.oidb.cmd0x5eb.oidb_0x5eb;
public abstract class AbsProfileBusinessProcessor implements IRequestProfileCardCallback, IGetProfileDetailCallback {
public AbsProfileBusinessProcessor(AppRuntime appRuntime) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailRequestForLogin(List<Short> list) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailResponseBegin(Bundle bundle) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailResponseEnd(Bundle bundle, boolean z, Card card) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailTLV(Bundle bundle, long j2, Card card, short s, short s2, ByteBuffer byteBuffer) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailTLVBegin(Bundle bundle, long j2, Card card) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void onGetProfileDetailTLVEnd(Bundle bundle, long j2, Card card) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IRequestProfileCardCallback
public void onProcessProfile0x5eb(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard, oidb_0x5eb.UdcUinData oidb_0x5eb_udcuindata) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IRequestProfileCardCallback
public void onProcessProfileCard(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IRequestProfileCardCallback
public void onProcessProfileService(Bundle bundle, Card card, RespHead respHead, RespSummaryCard respSummaryCard, SparseArray<BusinessRespBuffer> sparseArray) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IRequestProfileCardCallback
public void onRequestProfileCard(Bundle bundle, ArrayList<BusinessReqBuffer> arrayList, ArrayList<Integer> arrayList2) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IRequestProfileCardCallback
public void onResponseProfileCard(boolean z, Bundle bundle, RespHead respHead, RespSummaryCard respSummaryCard) {
}
@Override // com.tencent.mobileqq.profilecard.processor.IGetProfileDetailCallback
public void requestParseProfileLocation(Card card) {
}
}
| 3,061 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGetProfileDetailCallback.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/processor/IGetProfileDetailCallback.java | package com.tencent.mobileqq.profilecard.processor;
import android.os.Bundle;
import com.tencent.mobileqq.data.Card;
import java.nio.ByteBuffer;
import java.util.List;
public interface IGetProfileDetailCallback {
void onGetProfileDetailRequestForLogin(List<Short> list);
void onGetProfileDetailResponseBegin(Bundle bundle);
void onGetProfileDetailResponseEnd(Bundle bundle, boolean z, Card card);
void onGetProfileDetailTLV(Bundle bundle, long j2, Card card, short s, short s2, ByteBuffer byteBuffer);
void onGetProfileDetailTLVBegin(Bundle bundle, long j2, Card card);
void onGetProfileDetailTLVEnd(Bundle bundle, long j2, Card card);
void requestParseProfileLocation(Card card);
}
| 721 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ProfileBusinessProcessorFactory.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/profilecard/processor/ProfileBusinessProcessorFactory.java | package com.tencent.mobileqq.profilecard.processor;
import java.util.ArrayList;
import mqq.app.AppRuntime;
public class ProfileBusinessProcessorFactory {
public static ArrayList<Class<? extends AbsProfileBusinessProcessor>> sInjectProcessorClasses;
private void initBusinessProcessors(AppRuntime appRuntime) {
}
}
| 330 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
MsfCommand.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/msf/sdk/MsfCommand.java | package com.tencent.mobileqq.msf.sdk;
public enum MsfCommand {
unknown,
registerMsfService,
unRegisterMsfService,
loginAuth,
verifyPasswd,
verifyPasswdImage,
verifyPasswdRefreshImage,
changeUinLogin,
delLoginedAccount,
submitVerifyCode,
refreVerifyCode,
refreshTickets,
getServerTime,
registerPush,
unRegisterPush,
registerCmdCallback,
resetCmdCallback,
reportMsg,
getServerConfig,
onConnOpened,
onReceFirstResp,
onOepnConnAllFailed,
onConnClosed,
onConnWeakNet,
onConnWeakNetNew,
onNetNeedSignon,
onInvalidSign,
onTokenExpired,
onTicketChanged,
onProxyIpChanged,
onOverloadPushNotify,
onPCActive,
onGrayCheckFailed,
onRecvConfigPush,
onRecvVerifyCode,
onRecvPushMsg,
onRecvNotifyMsg,
onOnlineStatusChanged,
_msf_RegPush,
_msf_UnRegPush,
_msf_queryPush,
_msf_hello,
_msf_refreToken,
_msf_kickedAndCleanTokenResp,
_msf_getConfig,
_msf_HeartbeatAlive,
_msf_NetException,
SEND_WIRELESS_PSWREQ,
SEND_WIRELESS_MEIBAOREQ,
_setMsfSuspend,
_setMsfResunmed,
msfGetWeakNet,
getPluginConfig,
regUin_queryMobile,
regUin_commitMobile,
regUin_querySmsStat,
regUin_reSendSms,
regUin_commitSmsCode,
regUin_commitPass,
quick_register_checkAccount,
quick_register_getAccount,
checkRole,
changeToken,
proxyRegisterPush,
proxyUnRegisterPush,
appDataIncerment,
getAppDataCount,
accountTokenSyncCheckSign,
appReportLog,
getMsfDebugInfo,
reportRdm,
reportSocket,
pushSetConfig,
getKey,
getAlterTickets,
openConn,
getGatewayIp,
setMsfConnStatus,
keepProcessAlive,
sendVideoAck,
wt_loginAuth,
wt_exchange,
wt_name2uin,
wt_other,
_msf_QualityTest,
wt_GetStWithPasswd,
wt_GetStWithoutPasswd,
wt_CheckPictureAndGetSt,
wt_RefreshPictureData,
wt_VerifyCode,
wt_CloseCode,
wt_CancelCode,
wt_GetA1WithA1,
wt_GetOpenKeyWithoutPasswd,
wt_QuickLoginByGateway,
wt_GetStViaGatewayLogin,
wt_getUIDWithoutPasswd,
wt_GetSaltUinList,
wt_GetStViaPhonePwdLogin,
wt_CheckDevLockStatus,
wt_AskDevLockSms,
wt_CheckDevLockSms,
wt_CloseDevLock,
wt_RefreshSMSData,
wt_CheckSMSAndGetSt,
wt_CheckSMSAndGetStExt,
wt_setRegDevLockFlag,
wt_SetDevlockMobileType,
wt_RegGetSMSVerifyLoginAccount,
wt_CheckSMSVerifyLoginAccount,
wt_RefreshSMSVerifyLoginCode,
wt_VerifySMSVerifyLoginCode,
wt_GetStViaSMSVerifyLogin,
loginByWx,
wt_getStViaWxLogin,
gm_GuardEvent,
qqwifi_notifyAvail,
submitPuzzleVerifyCodeTicket,
startPCActivePolling,
stopPCActivePolling,
openPCActive,
_msf_QuickHeartBeat,
msf_ssoping,
msf_msgsignal,
check_msf_conErro,
msf_refreshDA2,
msf_oshello,
msf_step_counter,
msf_pbSyncMsg,
msf_send_wtpkg,
msf_save_geoginfo,
msf_manual_set_log_level,
msf_update_battery,
msf_update_locale_id,
msfUpdateManagerConfig,
msfUpdateToggle,
wt_refreshMemorySig,
msf_FEKit,
msf_sec_dispatch_event,
msf_active_log_report,
msf_after_fetch_config_log_report,
msf_update_weakNet_config,
msf_update_common_config,
msf_push_register_switch,
msf_weak_net_switch,
msf_update_complex_connect_config,
msf_update_mmkv_config,
msf_listen_msg_sync_end,
msf_before_msg_sync_config
}
| 3,508 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
MsfCore.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/msf/core/MsfCore.java | package com.tencent.mobileqq.msf.core;
public class MsfCore {
public static synchronized int getNextSeq() {
return 0;
}
}
| 139 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QQSecuritySign.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/sign/QQSecuritySign.java | package com.tencent.mobileqq.sign;
public class QQSecuritySign {
public static class SignResult {
public byte[] extra;
public byte[] sign;
public byte[] token;
}
}
| 197 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
mobileqq_mp.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/mp/mobileqq_mp.java | package com.tencent.mobileqq.mp;
import com.tencent.mobileqq.pb.MessageMicro;
import com.tencent.mobileqq.pb.PBField;
import com.tencent.mobileqq.pb.PBStringField;
import com.tencent.mobileqq.pb.PBUInt32Field;
public class mobileqq_mp {
public static class RetInfo extends MessageMicro<RetInfo> {
public final PBUInt32Field ret_code = PBField.initUInt32(0);
public final PBStringField err_info = PBField.initString("");
}
}
| 450 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PhotoSendParams.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/activity/photo/PhotoSendParams.java | package com.tencent.mobileqq.activity.photo;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.Serializable;
public class PhotoSendParams implements Parcelable, Serializable {
public static final Creator<PhotoSendParams> CREATOR = new Creator<PhotoSendParams>() {
@Override
public PhotoSendParams createFromParcel(Parcel parcel) {
return new PhotoSendParams(parcel);
}
@Override
public PhotoSendParams[] newArray(int i) {
return new PhotoSendParams[i];
}
};
public static final int SEND_PIC_NORMAL = 0;
public static final int SEND_PIC_QZONE = 1;
public long fileSize;
public int picType;
public String rawDownloadUrl;
public int rawHeight;
public String rawMd5;
public String rawPicPath;
public int rawWidth;
public String thumbPath;
public PhotoSendParams(String str, String str2, String str3, long j2, int i2, int i3, String str4, int i4) {
this.picType = 0;
this.thumbPath = str;
this.rawMd5 = str2;
this.rawPicPath = str3;
this.fileSize = j2;
this.rawHeight = i2;
this.rawWidth = i3;
this.rawDownloadUrl = str4;
this.picType = i4;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public String toString() {
return "PhotoSendParams:&thumbPath:" + this.thumbPath + " &rawMd5:" + this.rawMd5 + " &rawPicPath:" + this.rawPicPath + " &rawHeight:" + this.rawHeight + " &rawWidth:" + this.rawWidth + " &rawDownloadUrl:" + this.rawDownloadUrl + " &picType:" + this.picType;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i2) {
parcel.writeString(this.thumbPath);
parcel.writeString(this.rawMd5);
parcel.writeString(this.rawPicPath);
parcel.writeLong(this.fileSize);
parcel.writeInt(this.rawHeight);
parcel.writeInt(this.rawWidth);
parcel.writeString(this.rawDownloadUrl);
parcel.writeInt(this.picType);
}
public PhotoSendParams(Parcel parcel) {
this.picType = 0;
this.thumbPath = parcel.readString();
this.rawMd5 = parcel.readString();
this.rawPicPath = parcel.readString();
this.fileSize = parcel.readLong();
this.rawHeight = parcel.readInt();
this.rawWidth = parcel.readInt();
this.rawDownloadUrl = parcel.readString();
this.picType = parcel.readInt();
}
}
| 2,546 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
FEKit.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/fe/FEKit.java | package com.tencent.mobileqq.fe;
import android.content.Context;
import com.tencent.mobileqq.sign.QQSecuritySign;
import java.util.List;
public class FEKit {
public static FEKit getInstance() {
return null;
}
public void init(final Context context, String uin, String guid, String o3did, String q36, String qua) {
}
public QQSecuritySign.SignResult getSign(String cmd, byte[] buffer, int seq, String uin) {
return null;
}
public List<String> getCmdWhiteList() {
return null;
}
}
| 542 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QQSysFaceUtil.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/emoticon/QQSysFaceUtil.java | package com.tencent.mobileqq.emoticon;
import android.text.TextUtils;
public class QQSysFaceUtil {
public static int convertToServer(int localId) {
return 0;
}
public static boolean isValidFaceId(int locslId) {
return locslId != 255 && locslId != 511 && locslId != 250 && locslId >= 0 && locslId <= 65535;
}
public static int convertToLocal(int serverId) {
return 0;
}
public static String getFaceDescription(int localId) {
return "";
}
}
| 509 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IQRCodeApi.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qrscan/api/IQRCodeApi.java | package com.tencent.mobileqq.qrscan.api;
import com.tencent.mobileqq.qroute.QRouteApi;
public interface IQRCodeApi extends QRouteApi {
int getOneResult(StringBuilder sb, StringBuilder sb2);
int getOneResultForCamera(StringBuilder sb, StringBuilder sb2);
//ArrayList<QBarResult> getResult();
//ArrayList<QBarResult> getResultForCamera();
String getVersion();
int init(int i2, String str, String str2);
int initForCamera(int i2, String str, String str2);
boolean isValidScanImageSize(int i2, int i3);
boolean isWxCodeSupported();
int release();
int releaseForCamera();
int scanImage(byte[] bArr, int i2, int i3);
int scanImageForCamera(byte[] bArr, int i2, int i3);
//int setReaders(k.a aVar);
// int setReadersForCamera(k.a aVar);
}
| 807 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
SilkCodecWrapper.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/utils/SilkCodecWrapper.java | package com.tencent.mobileqq.utils;
import android.content.Context;
public class SilkCodecWrapper {
public SilkCodecWrapper(Context context, boolean isEncoder) {
}
public native long SilkDecoderNew(int sampleRate, int bitRate);
public native long SilkEncoderNew(int sampleRate, int bitRate);
public native int decode(long j2, byte[] bArr, byte[] bArr2, int i2, int i3);
public native void deleteCodec(long j2);
public native int encode(long j2, byte[] bArr, byte[] bArr2, int i2);
public void release() {
}
}
| 553 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IHttpCommunicatorListener.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/utils/httputils/IHttpCommunicatorListener.java | package com.tencent.mobileqq.utils.httputils;
public interface IHttpCommunicatorListener {
//void decode(HttpMsg httpMsg, HttpMsg httpMsg2);
//void handleError(HttpMsg httpMsg, HttpMsg httpMsg2);
//void handleRedirect(String str);
//boolean statusChanged(HttpMsg httpMsg, HttpMsg httpMsg2, int i2);
} | 320 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProGuildInfo.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/IGProGuildInfo.java | package com.tencent.mobileqq.qqguildsdk.data;
import com.tencent.mobileqq.qqguildsdk.data.genc.IGProMedalInfo;
import com.tencent.mobileqq.qqguildsdk.data.genc.IGProNavigationInfo;
import java.io.Serializable;
import java.util.ArrayList;
public interface IGProGuildInfo extends Serializable {
public static final long serialVersionUID = 1;
boolean getAllowSearch();
String getAvatarUrl(int i2);
long getBannedTimeLimit();
long getChangeNameInterval();
boolean getChannelListChange();
String getClientId();
int getCoverFontColorId();
String getCoverUrl(int i2, int i3);
long getCreateTime();
String getCreatorId();
String getErrMsg();
long getGroupId();
boolean getGuildCanShare();
String getGuildID();
String getGuildName();
long getGuildNameChangeTime();
String getGuildNumber();
int getGuildType();
boolean getIsBanned();
boolean getIsFrozen();
boolean getIsValid();
long getJoinTime();
long getJumpChannelId();
boolean getJumpChannelSwitch();
ArrayList<IGProMedalInfo> getMedalInfoList();
int getMedalLevel();
int getMessageNotifyType();
long getMyShutUpExpireTime();
ArrayList<IGProNavigationInfo> getNavigationInfoList();
String getProfile();
int getQRCodePeriod();
int getQRCodeSwitch();
int getResult();
String getSearchJoinSig();
String getShowNumber();
long getShutUpExpireTime();
//eu getSpeakThreshold();
String getTagDesc();
long getTagId();
boolean getTopicSquareSwitch();
long getU64guildSeq();
String getUIData(String str);
int getUserNum();
int getUserType();
int getVisibleChannelMaxNum();
int getWeakNotifyDisplay();
boolean isGroupGuild();
boolean isInteractiveForVisitor();
boolean isMember();
boolean isNeedRealNameForVisitor();
boolean isTop();
boolean isVisibleForVisitor();
void setQRCodeSwitch(int i2);
void setUIData(String str, String str2);
}
| 2,048 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProOfficialMedalInfoExt.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/IGProOfficialMedalInfoExt.java | package com.tencent.mobileqq.qqguildsdk.data;
import java.io.Serializable;
public interface IGProOfficialMedalInfoExt extends Serializable {
String getIconUrl();
boolean getIsOffical();
String toString();
}
| 223 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProClientIdentity.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProClientIdentity.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import java.io.Serializable;
public interface IGProClientIdentity extends Serializable {
int getClientId();
String getDesc();
IGProClientIdentityBytes getIdentityBytes();
String toString();
} | 263 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProMedalInfo.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProMedalInfo.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import com.tencent.mobileqq.qqguildsdk.data.IGProOfficialMedalInfoExt;
import java.io.Serializable;
public interface IGProMedalInfo extends Serializable {
long getExpireTime();
String getIconUrl();
String getName();
IGProOfficialMedalInfoExt getOfficialMedalInfoExt();
String toString();
} | 367 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProMedal.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProMedal.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import java.io.Serializable;
public interface IGProMedal extends Serializable {
String getDesc();
long getEndTime();
long getStartTime();
String getUrl();
String toString();
} | 252 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProSimpleProfile.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProSimpleProfile.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import java.io.Serializable;
import java.util.ArrayList;
public interface IGProSimpleProfile extends Serializable {
String getAvatarMeta();
String getAvatarPendant();
ArrayList<Long> getCategoryIds();
IGProClientIdentity getClientIdentityBytes();
String getDisplayName();
long getGuildId();
long getLevelRoleId();
String getMemberName();
String getNickName();
IGProMedal getPersonalMedal();
long getRoleId();
long getTinyId();
String toString();
}
| 565 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProNavigationInfo.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProNavigationInfo.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import java.io.Serializable;
public interface IGProNavigationInfo extends Serializable {
String getBubbleDesc();
String getIconUrl();
String getJumpUrl();
int getJumpUrlType();
boolean getShowBubble();
String getTitle();
String toString();
}
| 329 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGProClientIdentityBytes.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/data/genc/IGProClientIdentityBytes.java | package com.tencent.mobileqq.qqguildsdk.data.genc;
import java.io.Serializable;
import java.util.ArrayList;
public interface IGProClientIdentityBytes extends Serializable {
int getClientId();
ArrayList<Object> getIdentityList();
String toString();
} | 265 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IGPSService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qqguildsdk/api/IGPSService.java | package com.tencent.mobileqq.qqguildsdk.api;
import com.tencent.mobileqq.qqguildsdk.data.IGProGuildInfo;
import com.tencent.mobileqq.qqguildsdk.data.genc.IGProSimpleProfile;
import java.util.List;
import mqq.app.api.IRuntimeService;
public interface IGPSService extends IRuntimeService {
List<IGProGuildInfo> getGroupGuildList();
IGProGuildInfo getGuildInfo(String str);
List<IGProGuildInfo> getGuildList();
String getGuildMemberName(String str, String str2);
String getGuildName(String str);
String getSelfTinyId();
/* synthetic */ IGProSimpleProfile getSimpleProfile(String str, String str2, int i2);
/* synthetic */ boolean isGProSDKInitCompleted();
}
| 698 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ITroopManagerService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/troop/api/ITroopManagerService.java | package com.tencent.mobileqq.troop.api;
import mqq.app.api.IRuntimeService;
public interface ITroopManagerService extends IRuntimeService {
void getTroopsMemberList(); // 会发送请求
} | 194 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ITroopInfoService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/troop/api/ITroopInfoService.java | package com.tencent.mobileqq.troop.api;
import com.tencent.mobileqq.data.troop.TroopInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import mqq.app.api.IRuntimeService;
public interface ITroopInfoService extends IRuntimeService {
// 从数据库里面获取群聊信息
// void asyncGetTroopInfo(String str, com.tencent.mobileqq.data.troop.a aVar);
void deleteTroopList(List<String> groupList);
void deleteTroopWithoutDB(String str, TroopInfo troopInfo);
TroopInfo findTroopInfo(String uin);
TroopInfo findTroopInfo(String str, boolean z);
TroopInfo findTroopInfo(String str, boolean z, boolean z2);
List<TroopInfo> getAllTroopList();
long getInsertJoinTroopMsgTime(String str);
long getSharedMsgSeq(String str);
String getTroopCodeByTroopUin(String str);
//void getTroopCodeByTroopUinAsync(String str, a aVar);
TroopInfo getTroopInfo(String uin);
TroopInfo getTroopInfoFromCache(String uin);
ArrayList<String> getTroopMemberForTroopHead(String str);
String getTroopNameByID(String uin);
String getTroopUin(String str);
String getTroopUinByTroopCode(String code);
List<Long> getUinList();
boolean hasNoTroop();
boolean isCommonlyUsedTroop(String str);
boolean isHomeworkTroop(String str);
boolean isQidianPrivateTroop(String str);
boolean isTroopCacheInited();
void refreshCommonlyUsedTroop();
boolean removeCommonlyUsedTroop(String str);
void saveTroopInfo(TroopInfo troopInfo);
void saveTroopInfoOnlyCacheAndDB(TroopInfo troopInfo);
TroopInfo saveTroopName(String str, String str2);
void saveTroops(ArrayList<TroopInfo> arrayList);
void saveTroops(ArrayList<TroopInfo> arrayList, long j2);
void setInsertJoinTroopMsgTime(String str, long j2);
void setSharedMsgSeq(String str, long j2);
}
| 1,887 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ITroopMemberInfoService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/troop/api/ITroopMemberInfoService.java | package com.tencent.mobileqq.troop.api;
import com.tencent.mobileqq.data.troop.TroopMemberInfo;
import java.util.List;
import mqq.app.api.IRuntimeService;
public interface ITroopMemberInfoService extends IRuntimeService {
List<TroopMemberInfo> getAllTroopMembers(String groupUin);
boolean deleteTroopMembers(String groupUin);
TroopMemberInfo getTroopMember(String groupUin, String memberUin);
void getTroopsMemberList();
boolean deleteTroopMember(String groupUin, String memberUin);
boolean isMemberInCache(String groupUin, String memberUin);
} | 577 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QSecConfig.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qsec/qsecurity/QSecConfig.java | package com.tencent.mobileqq.qsec.qsecurity;
import android.content.Context;
public class QSecConfig {
public static byte[] CONFIG_KEY_BUF = null;
public static int CONFIG_KEY_ID = 0;
public static int CONFIG_TIME_GAP = 5000;
public static final int CONST_CONFIG_TASK_ID = 1;
public static final int CONST_HEARTBEAT_TASK_ID = 0;
public static final int CONST_KEYEXCHANGE_TASK_ID = 2;
public static final int CONST_LUA_TASK_ID = 3;
public static final int CONST_REPORT_TASK_ID = 4;
public static final int DO_TYPE_DELE = 4;
public static final int DO_TYPE_INIT = 3;
public static final int DO_TYPE_START = 1;
public static final int DO_TYPE_STOP = 2;
public static int HEART_BEAT_SEQ_NUM = 0;
public static String business_guid = "";
public static String business_o3did = null;
public static int business_os = 1;
public static String business_q36 = "";
public static String business_qua = "";
public static String business_seed;
public static String business_uin;
public static Context sContext;
public static int sign_strategy;
public static void setupBusinessInfo(Context context, String str, String str2, String str3, String str4, String str5, String str6) {
sContext = context;
business_qua = str6;
business_uin = str;
business_guid = str2;
business_seed = str3;
business_o3did = str4;
business_q36 = str5;
}
}
| 1,469 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QSec.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qsec/qsecurity/QSec.java | package com.tencent.mobileqq.qsec.qsecurity;
import android.content.Context;
public class QSec {
public static QSec getInstance() {
return null;
}
public byte[] getFeKitAttach(Context context, String uin, String dataStart, String dataEnd) {
return null;
}
}
| 293 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
Dandelion.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qsec/qsecdandelionsdk/Dandelion.java | package com.tencent.mobileqq.qsec.qsecdandelionsdk;
public class Dandelion {
public static Dandelion getInstance() {
return null;
}
public byte[] fly(String str, byte[] bArr) {
return "".getBytes();
}
}
| 237 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QRoute.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qroute/QRoute.java | package com.tencent.mobileqq.qroute;
import androidx.annotation.NonNull;
public class QRoute {
@NonNull
public static <T extends QRouteApi> T api(Class<T> cls) {
return null;
}
public static <T extends QRouteApi> T apiFromPlugin(Class<T> cls) {
return null;
}
}
| 301 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IFriendDataService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/friend/api/IFriendDataService.java | package com.tencent.mobileqq.friend.api;
import com.tencent.mobileqq.data.Friends;
import com.tencent.mobileqq.data.Groups;
import java.util.List;
import mqq.app.api.IRuntimeService;
public interface IFriendDataService extends IRuntimeService {
//List<Groups> asyncGetGroupList(a aVar);
Friends deleteFriend(String uin);
List<Friends> getAllFriends();
List<Friends> getAllFriends(boolean ignoreGirl);
//void getFriend(String str, b<Friends> bVar);
int getFriendCount();
Friends getFriendFromMemoryCache(String str);
List<Friends> getFriendList(int i2);
Groups getGroup(int i2);
Groups getGroup(int i2, boolean z);
List<Groups> getGroupList();
void initFriendCache();
// void initFriendCache(c cVar);
void initGroupCache();
boolean isFriend(String str);
boolean isFriend(String str, boolean z);
boolean isInitFinished();
void moveFriendToNewGroup(String str, int i2);
void moveGroup(int i2, int i3);
List<Friends> preloadPartFriendCache(List<String> list);
boolean saveFriend(Friends friends);
void saveFriendCache(Friends friends);
boolean saveFriendList(List<Friends> list);
boolean saveFriendList(List<Friends> list, boolean z, long j2);
boolean saveGroup(Groups groups);
boolean saveGroupList(List<Groups> list);
void setNtRequestFriendListSeq(int i2);
void updateGroupSortIds(byte[] bArr, byte[] bArr2);
}
| 1,452 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IFriendNameService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/friend/api/IFriendNameService.java | package com.tencent.mobileqq.friend.api;
import mqq.app.api.IRuntimeService;
public interface IFriendNameService extends IRuntimeService {
String getBuddyName(String str, boolean z);
String getFriendAlias(String str);
String getFriendName(String str);
String getFriendName(String str, boolean z);
String getFriendNick(String str);
String getFriendRemark(String str);
String getPhoneContactName(String str);
} | 444 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IFriendHandlerService.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/friend/api/IFriendHandlerService.java | package com.tencent.mobileqq.friend.api;
import android.os.Bundle;
import com.tencent.mobileqq.app.AddBatchPhoneFriendResult;
import com.tencent.mobileqq.data.PhoneContact;
import java.util.ArrayList;
import java.util.List;
import mqq.app.api.IRuntimeService;
public interface IFriendHandlerService extends IRuntimeService {
void addFriendGroup(byte id, String name);
void cacheToken(String str, int i2, int i3, byte[] bArr);
void deleteFriendGroup(byte b2);
void getOnlyChatPermissionBatchByPage(int i2);
void getPermissionSelectFriend(List<String> list, int i2, int i3);
void getSingleFriendPermission(String str);
boolean isRequestingFriendList();
void renameFriendGroup(byte b2, String str);
void requestAddBatchPhoneFriend(ArrayList<PhoneContact> arrayList, String str, int i2, int i3, ArrayList<AddBatchPhoneFriendResult> arrayList2);
void requestAddFriend(String str, String str2, int i2, byte b2, String str3, int i3, int i4, boolean z, byte[] bArr, boolean z2, String str4, String str5);
void requestAddFriend(String str, String str2, int i2, byte b2, String str3, int i3, int i4, boolean z, byte[] bArr, boolean z2, String str4, String str5, Bundle bundle, boolean z3);
void requestAddFriendWithMyCard(String str, String str2, int i2, byte b2, String str3, int i3, int i4, boolean z, byte[] bArr, boolean z2, String str4, String str5, byte b3, String str6, Bundle bundle, boolean z3);
void requestAddFriendWithMyCard(String str, String str2, int i2, byte b2, String str3, int i3, int i4, byte[] bArr, boolean z, byte[] bArr2, boolean z2, String str4, String str5, byte b3, String str6, Bundle bundle, boolean z3);
void requestAutoInfo(String str, int i2, int i3);
void requestFriendInfo(String str);
void requestFriendList(boolean pullRefresh);
void requestFriendList(boolean pullRefresh, int ntFriendListSeq);
void requestInfoWithOpenId(String str, String str2);
void requestUinSafetyFlag(long j2);
void requestUserAddFriendSetting(String str, int i2, int i3, String str2);
void requestUserAddFriendSetting(String str, int i2, int i3, String str2, int i4);
void resortFriendGroup(byte[] bArr, byte[] bArr2);
void setBatchFriendPermission(List<String> list, int i2);
void setFriendPermission(String str, int i2);
}
| 2,349 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
MobileQQServiceBase.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/service/MobileQQServiceBase.java | package com.tencent.mobileqq.service;
import com.tencent.common.app.AppInterface;
import com.tencent.mobileqq.app.BusinessHandler;
import com.tencent.qphone.base.remote.FromServiceMsg;
import com.tencent.qphone.base.remote.ToServiceMsg;
import java.util.Set;
public abstract class MobileQQServiceBase {
public void dispatchToHandler(ToServiceMsg toServiceMsg, FromServiceMsg fromServiceMsg, Object obj) {
}
}
| 421 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
OpenApiProvider.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/openapi/OpenApiProvider.java | package com.tencent.mobileqq.openapi;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
public class OpenApiProvider extends ContentProvider {
@Override
public boolean onCreate() {
return false;
}
@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
return null;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues contentValues) {
return null;
}
@Override
public int delete(Uri uri, String s, String[] strings) {
return 0;
}
@Override
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
return 0;
}
}
| 852 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
FEBound.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/dt/model/FEBound.java | package com.tencent.mobileqq.dt.model;
public class FEBound {
private static byte[][] mConfigEnCode = null;
private static byte[][] mConfigDeCode = null;
}
| 165 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
BusinessHandler.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/BusinessHandler.java | package com.tencent.mobileqq.app;
import com.tencent.common.app.AppInterface;
import java.util.Set;
public abstract class BusinessHandler extends BaseBusinessHandler {
public BusinessHandler(AppInterface appInterface) {
}
@Override
public Set<String> getCommandList() {
return null;
}
@Override
public Set<String> getPushCommandList() {
return null;
}
@Override
public Set<String> getPushPBCommandList() {
return null;
}
}
| 497 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
BusinessObserver.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/BusinessObserver.java | package com.tencent.mobileqq.app;
public interface BusinessObserver {
void onUpdate(int result, boolean success, Object obj);
} | 132 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
OidbWrapper.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/OidbWrapper.java | package com.tencent.mobileqq.app;
import com.tencent.qphone.base.remote.ToServiceMsg;
public abstract class OidbWrapper {
public abstract ToServiceMsg createToServiceMsg(String str);
}
| 191 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
StatictisInfo.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/StatictisInfo.java | package com.tencent.mobileqq.app;
public class StatictisInfo {
public static final long DETAIL_REASON_DECODE_FAIL = 2139062143;
public static final long DETAIL_REASON_UNKNOWN = 2139062142;
public static final long NO_DETAIL_REASON = Long.MAX_VALUE;
public static final int REPORT_AS_SUCC_FLAG = 1;
public int appSeq = 0;
public int errCode = 1000;
public int retryCount = 0;
public long detailErrorReason = Long.MAX_VALUE;
public String timeoutReason = null;
public int reportSucc = -1;
}
| 530 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
AddBatchPhoneFriendResult.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/AddBatchPhoneFriendResult.java | package com.tencent.mobileqq.app;
import java.io.Serializable;
public class AddBatchPhoneFriendResult implements Serializable {
public static final int ALLOW_TYPE_NEED_ANSWER = 2;
public static final int ALLOW_TYPE_REFUSE_ADD = 1;
public static final int ALLOW_TYPE_SEND_ADD_REQ = 3;
public static final int SEND_ADD_UP_LIMIT = 32;
public static final int SEND_ADD_UP_LIMIT_OTHER = 33;
public static final int SEND_REQ_ALREAY = 1;
public static final int SEND_REQ_NO = 2;
public static final int SEND_REQ_UNKNOWN = 0;
public static final int SEND_SECURITY_FORCED_FAILED = 37;
public static final int SEND_SUCCESS = 0;
public int allowType;
public String mobile;
public String remark;
public int sendReqFlag;
public int sendResult;
} | 794 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
BaseBusinessHandler.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/BaseBusinessHandler.java | package com.tencent.mobileqq.app;
import com.qq.jce.wup.UniPacket;
import com.tencent.qphone.base.remote.FromServiceMsg;
import com.tencent.qphone.base.remote.ToServiceMsg;
import java.util.Set;
public abstract class BaseBusinessHandler extends OidbWrapper {
@Override
public ToServiceMsg createToServiceMsg(String cmd) {
return null;
}
public final <T> T decodePacket(byte[] data, String name, T obj) {
UniPacket uniPacket = new UniPacket(true);
try {
uniPacket.setEncodeName("utf-8");
uniPacket.decode(data);
return (T) uniPacket.getByClass(name, obj);
} catch (Exception unused) {
return null;
}
}
protected abstract Set<String> getCommandList();
protected abstract Set<String> getPushCommandList();
protected abstract Set<String> getPushPBCommandList();
public abstract void onReceive(ToServiceMsg toServiceMsg, FromServiceMsg fromServiceMsg, Object obj);
public void send(ToServiceMsg toServiceMsg) {
}
public void sendPbReq(ToServiceMsg toServiceMsg) {
}
public String getCurrentAccountUin() {
return "";
}
}
| 1,183 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
BusinessHandlerFactory.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/BusinessHandlerFactory.java | package com.tencent.mobileqq.app;
public class BusinessHandlerFactory {
public static String TROOP_MEMBER_CARD_HANDLER = null;
public static String TROOP_LIST_HANDLER = null;
public static String TROOP_MEMBER_LIST_HANDLER = null;
public static final String TROOP_MODIFY_HANDLER = null;
}
| 305 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
QQAppInterface.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/app/QQAppInterface.java | package com.tencent.mobileqq.app;
import com.tencent.common.app.business.BaseQQAppInterface;
import mqq.manager.Manager;
public class QQAppInterface extends BaseQQAppInterface {
public static final int ACCOUNT_MANAGER = 0;
public static final int WTLOGIN_MANAGER = 1;
public static final int TICKET_MANAGER = 2;
@Override
public String getCurrentAccountUin() {
return null;
}
public void execute(Runnable runnable) {
}
@Override
public String getCurrentNickname() {
return null;
}
public void syncOnlineFriend() {
}
public MessageHandler getMsgHandler() {
return null;
}
public Manager getManager(int id) {
return null;
}
}
| 733 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ApplicationDelegate.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/qfix/ApplicationDelegate.java | package com.tencent.mobileqq.qfix;
import android.app.Application;
public class ApplicationDelegate extends Application {
}
| 126 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBEnumField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBEnumField.java | package com.tencent.mobileqq.pb;
public class PBEnumField extends PBPrimitiveField<Integer>{
public PBEnumField(int i2, boolean z) {
}
public int get() {
return 0;
}
public void set(int i2) {
}
}
| 232 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBInt32Field.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBInt32Field.java | package com.tencent.mobileqq.pb;
public class PBInt32Field extends PBPrimitiveField<Integer> {
public PBInt32Field(int i2, boolean z) {
}
public int get() {
return 0;
}
public void set(int i2) {
}
}
| 234 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBUInt64Field.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBUInt64Field.java | package com.tencent.mobileqq.pb;
public class PBUInt64Field extends PBPrimitiveField<Long> {
public static PBField<Long> __repeatHelper__;
public PBUInt64Field(long i2, boolean z) {
}
public void set(long i2) {
}
public long get() {
return 0;
}
}
| 288 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBInt64Field.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBInt64Field.java | package com.tencent.mobileqq.pb;
public class PBInt64Field extends PBPrimitiveField<Long> {
public PBInt64Field(long i2, boolean z) {
}
public void set(long i2) {
}
public long get() {
return 0;
}
}
| 235 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ByteStringMicro.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/ByteStringMicro.java | package com.tencent.mobileqq.pb;
public class ByteStringMicro {
public static final ByteStringMicro EMPTY = null;
public static ByteStringMicro copyFrom(String str, String str2) {
return null;
}
public static ByteStringMicro copyFrom(byte[] bArr) {
return null;
}
public static ByteStringMicro copyFrom(byte[] bArr, int i2, int i3) {
return null;
}
public static ByteStringMicro copyFromUtf8(String str) {
return null;
}
public boolean isEmpty() {
return false;
}
public int size() {
return 0;
}
public byte[] toByteArray() {
return null;
}
public String toString(String str) {
return "";
}
public String toStringUtf8() {
return "";
}
}
| 795 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBRepeatField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBRepeatField.java | package com.tencent.mobileqq.pb;
import java.util.Collection;
import java.util.List;
public final class PBRepeatField<T> extends PBField<List<T>> {
public PBRepeatField(PBField<T> pBField) {
}
public void add(T t) {
get().add(t);
}
public void addAll(Collection<T> collection) {
get().addAll(collection);
}
public void clear(Object obj) {
}
public void copyFrom(PBField<List<T>> pBField) {
}
public T get(int index) {
return null;
}
public List<T> get() {
return null;
}
public boolean has() {
return !isEmpty();
}
public boolean isEmpty() {
return false;
}
public void remove(int index) {
}
public void set(int index, T t) {
}
public void set(List<T> list) {
}
public int size() {
return 0;
}
} | 869 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBBoolField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBBoolField.java | package com.tencent.mobileqq.pb;
public class PBBoolField extends PBPrimitiveField<Boolean> {
public PBBoolField(boolean z, boolean z2) {
}
public void set(boolean z) {
}
public boolean get() {
return false;
}
}
| 247 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBPrimitiveField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBPrimitiveField.java | package com.tencent.mobileqq.pb;
public abstract class PBPrimitiveField<T> extends PBField<T> {
public final boolean has() {
return false;
}
public final void setHasFlag(boolean z) {
}
}
| 213 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBUInt32Field.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBUInt32Field.java | package com.tencent.mobileqq.pb;
public class PBUInt32Field extends PBPrimitiveField<Integer> {
public static PBUInt32Field __repeatHelper__;
public PBUInt32Field(int i2, boolean z) {
}
public void set(int i2) {
}
public int get() {
return 0;
}
}
| 288 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBRepeatMessageField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBRepeatMessageField.java | package com.tencent.mobileqq.pb;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public final class PBRepeatMessageField<T extends MessageMicro<T>> extends PBField<List<T>> {
public PBRepeatMessageField(Class<T> cls) {
}
public void add(T t) {
}
public T get(int pos) {
return null;
}
public List<T> get() {
return null;
}
public boolean isEmpty() {
return false;
}
public void set(int i2, T t) {
}
public void set(List<T> list) {
}
public int size() {
return 0;
}
}
| 609 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
MessageMicro.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/MessageMicro.java | package com.tencent.mobileqq.pb;
public class MessageMicro<T extends MessageMicro<T>> {
public final T mergeFrom(byte[] bArr) {
return null;
}
public final byte[] toByteArray() {
return null;
}
public T get() {
return null;
}
public void set(T t) {
}
}
| 313 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBBytesField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBBytesField.java | package com.tencent.mobileqq.pb;
public class PBBytesField extends PBPrimitiveField<ByteStringMicro> {
public static PBField<ByteStringMicro> __repeatHelper__;
public PBBytesField(ByteStringMicro byteStringMicro, boolean z) {
}
public ByteStringMicro get() {
return null;
}
public void set(ByteStringMicro byteStringMicro) {
}
}
| 369 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBStringField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBStringField.java | package com.tencent.mobileqq.pb;
public class PBStringField extends PBPrimitiveField<String>{
public PBStringField(String str, boolean z) {
}
public void set(String str, boolean z) {
}
public void set(String str) {
}
public String get() {
return "";
}
}
| 298 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
PBField.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/pb/PBField.java | package com.tencent.mobileqq.pb;
public abstract class PBField<T> {
public static <T extends MessageMicro<T>> PBRepeatMessageField<T> initRepeatMessage(Class<T> cls) {
return new PBRepeatMessageField<>(cls);
}
public static <T> PBRepeatField<T> initRepeat(PBField<T> pBField) {
return new PBRepeatField<>(pBField);
}
public static PBUInt32Field initUInt32(int i2) {
return new PBUInt32Field(i2, false);
}
public static PBStringField initString(String str) {
return new PBStringField(str, false);
}
public static PBBytesField initBytes(ByteStringMicro byteStringMicro) {
return new PBBytesField(byteStringMicro, false);
}
public static PBBoolField initBool(boolean z) {
return new PBBoolField(z, false);
}
public static PBInt32Field initInt32(int i2) {
return new PBInt32Field(i2, false);
}
public static PBUInt64Field initUInt64(long j2) {
return new PBUInt64Field(j2, false);
}
public static PBInt64Field initInt64(long j2) {
return new PBInt64Field(j2, false);
}
public static PBEnumField initEnum(int i2) {
return new PBEnumField(i2, false);
}
}
| 1,219 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IQFileConfigManager.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/mobileqq/filemanager/api/IQFileConfigManager.java | package com.tencent.mobileqq.filemanager.api;
import mqq.app.api.IRuntimeService;
public interface IQFileConfigManager extends IRuntimeService {
boolean getC2CFileIPv6Switch();
//com.tencent.mobileqq.config.business.qfile.d getDatalineConfig();
boolean getDatalineFileIPv6Switch();
boolean getDiscFileIPv6Switch();
//com.tencent.mobileqq.config.business.qfile.e getExcitingC2CDownloadConfig();
//f getExcitingC2CUploadConfig();
//g getExcitingGroupDownloadConfig();
//h getExcitingGroupUploadConfig();
//b getFileAssistantTipsConfig();
//com.tencent.mobileqq.filemanager.data.c getFileAutoDownloadConfig(String str);
int getFileIPv6Strategy();
boolean getFileIPv6Switch();
//IQFileFileReaderConfigBean getFileReaderConfig();
boolean getGroupFileIPv6Switch();
String getHarcodeIP();
//com.tencent.mobileqq.config.business.qfile.a getQFileConfigManager();
boolean getTroopVideoFileSVIPSwitch();
boolean getTroopVideoFileSwitch();
boolean getTroopVideoFileYearSVIPSwitch();
//com.tencent.mobileqq.config.business.qfile.b getYYBPromoteConfig();
//com.tencent.mobileqq.config.business.qfile.c getYYBPromoteDialogConfig();
boolean isHarcodeIP();
boolean isMMApkFileCheckEnable();
boolean isMediaPlatformEnabled();
boolean isMediaPlatformLocalEnabled();
boolean isUseMediaPlatformLocalConfig();
boolean isWlanOnly();
void setDatalineConfig();
void setDebugDatalineSettingDevice(int i2);
void setDebugDatalineSettingUin(String str);
void setDebugTroopAIOVideoDownloadPlay(boolean z);
void setFileReaderConfig();
void setHarcodeIP(String str);
void setHarcodeIP(boolean z);
void setMMApkFileCheckEnable(boolean z);
void setMediaPlatformLocalEnabled(boolean z);
void setUseMediaPlatformLocalConfig(boolean z);
void setWlanOnly(boolean z);
}
| 1,916 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IAudioHelperApi.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/av/utils/api/IAudioHelperApi.java | package com.tencent.av.utils.api;
import com.tencent.mobileqq.qroute.QRouteApi;
public interface IAudioHelperApi extends QRouteApi {
long genDebugSeq();
} | 160 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
IAsyncQimeiListener.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/qimei/sdk/IAsyncQimeiListener.java | package com.tencent.qimei.sdk;
public interface IAsyncQimeiListener {
void onQimeiDispatch(Qimei qimei);
}
| 112 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
Qimei.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/tencent/qimei/sdk/Qimei.java | package com.tencent.qimei.sdk;
public class Qimei {
public String getQimei16() {
return null;
}
public String getQimei36() {
return null;
}
}
| 177 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
Gson.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/com/google/gson/Gson.java | package com.google.gson;
public class Gson {
public Gson() {
}
public String toJson(Object obj) {
return "";
}
}
| 139 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
GetCustomOnlineStatusReq.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/VIP/GetCustomOnlineStatusReq.java | package VIP;
import com.qq.jce.JceStruct;
public final class GetCustomOnlineStatusReq extends JceStruct {
public int iModelNum;
public long lUin;
public String sIMei;
}
| 183 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
GetCustomOnlineStatusRsp.java | /FileExtraction/Java_unseen/djkcyl_Shamrock/qqinterface/src/main/java/VIP/GetCustomOnlineStatusRsp.java | package VIP;
import com.qq.jce.JceStruct;
public final class GetCustomOnlineStatusRsp extends JceStruct {
public int iRet;
public String sBuffer;
public String sMsg;
public GetCustomOnlineStatusRsp() {
this.iRet = 0;
this.sMsg = "";
this.sBuffer = "";
}
}
| 303 | Java | .java | djkcyl/Shamrock | 106 | 66 | 1 | 2023-10-20T10:43:47Z | 2023-10-24T04:30:56Z |
ActivityMain.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/ActivityMain.java | package biz.bokhorst.xprivacy;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Process;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.Filter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SearchView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class ActivityMain extends ActivityBase implements OnItemSelectedListener {
private Spinner spRestriction = null;
private AppListAdapter mAppAdapter = null;
private String searchQuery = "";
private int mSortMode;
private boolean mSortInvert;
private int mProgressWidth = 0;
private int mProgress = 0;
private Handler mProHandler = new Handler();
private static final int SORT_BY_NAME = 0;
private static final int SORT_BY_UID = 1;
private static final int SORT_BY_INSTALL_TIME = 2;
private static final int SORT_BY_UPDATE_TIME = 3;
private static final int SORT_BY_MODIFY_TIME = 4;
private static final int SORT_BY_STATE = 5;
private static final int ACTIVITY_LICENSE = 0;
private static final int LICENSED = 0x0100;
private static final int NOT_LICENSED = 0x0231;
private static final int RETRY = 0x0123;
private static final int ERROR_CONTACTING_SERVER = 0x101;
private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;
private static final int ERROR_NON_MATCHING_UID = 0x103;
public static final String cAction = "Action";
public static final int cActionRefresh = 1;
public static final Uri cProUri = Uri.parse("http://www.xprivacy.eu/");
private static ExecutorService mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
new PriorityThreadFactory());
private static class PriorityThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setPriority(Thread.NORM_PRIORITY);
return t;
}
}
private Comparator<ApplicationInfoEx> mSorter = new Comparator<ApplicationInfoEx>() {
@Override
public int compare(ApplicationInfoEx appInfo0, ApplicationInfoEx appInfo1) {
int sortOrder = mSortInvert ? -1 : 1;
switch (mSortMode) {
case SORT_BY_NAME:
return sortOrder * appInfo0.compareTo(appInfo1);
case SORT_BY_UID:
// Default lowest first
return sortOrder * (appInfo0.getUid() - appInfo1.getUid());
case SORT_BY_INSTALL_TIME:
// Default newest first
Long iTime0 = appInfo0.getInstallTime(ActivityMain.this);
Long iTime1 = appInfo1.getInstallTime(ActivityMain.this);
return sortOrder * iTime1.compareTo(iTime0);
case SORT_BY_UPDATE_TIME:
// Default newest first
Long uTime0 = appInfo0.getUpdateTime(ActivityMain.this);
Long uTime1 = appInfo1.getUpdateTime(ActivityMain.this);
return sortOrder * uTime1.compareTo(uTime0);
case SORT_BY_MODIFY_TIME:
// Default newest first
Long mTime0 = appInfo0.getModificationTime(ActivityMain.this);
Long mTime1 = appInfo1.getModificationTime(ActivityMain.this);
return sortOrder * mTime1.compareTo(mTime0);
case SORT_BY_STATE:
Integer state0 = appInfo0.getState(ActivityMain.this);
Integer state1 = appInfo1.getState(ActivityMain.this);
if (state0.compareTo(state1) == 0)
return sortOrder * appInfo0.compareTo(appInfo1);
else
return sortOrder * state0.compareTo(state1);
}
return 0;
}
};
private boolean mPackageChangeReceiverRegistered = false;
private BroadcastReceiver mPackageChangeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
ActivityMain.this.recreate();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final int userId = Util.getUserId(Process.myUid());
// Check privacy service client
if (!PrivacyService.checkClient())
return;
// Import license file
if (Intent.ACTION_VIEW.equals(getIntent().getAction()))
if (Util.importProLicense(new File(getIntent().getData().getPath())) != null)
Toast.makeText(this, getString(R.string.menu_pro), Toast.LENGTH_LONG).show();
// Set layout
setContentView(R.layout.mainlist);
setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar));
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
// Set sub title
if (Util.hasProLicense(this) != null)
getSupportActionBar().setSubtitle(R.string.menu_pro);
// Annotate
Meta.annotate(this.getResources());
// Get localized restriction name
List<String> listRestrictionName = new ArrayList<String>(PrivacyManager.getRestrictions(this).navigableKeySet());
listRestrictionName.add(0, getString(R.string.menu_all));
// Build spinner adapter
SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spAdapter.addAll(listRestrictionName);
// Handle info
ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo);
imgInfo.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onClick(View view) {
int position = spRestriction.getSelectedItemPosition();
if (position != AdapterView.INVALID_POSITION) {
String query = (position == 0 ? "restrictions" : (String) PrivacyManager
.getRestrictions(ActivityMain.this).values().toArray()[position - 1]);
WebView webview = new WebView(ActivityMain.this);
webview.getSettings().setUserAgentString("Mozilla/5.0");
// needed for hashtag
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("https://github.com/M66B/XPrivacy#" + query);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
alertDialogBuilder.setTitle((String) spRestriction.getSelectedItem());
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setView(webview);
alertDialogBuilder.setCancelable(true);
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
});
// Setup category spinner
spRestriction = (Spinner) findViewById(R.id.spRestriction);
spRestriction.setAdapter(spAdapter);
spRestriction.setOnItemSelectedListener(this);
int pos = getSelectedCategory(userId);
spRestriction.setSelection(pos);
// Setup sort
mSortMode = Integer.parseInt(PrivacyManager.getSetting(userId, PrivacyManager.cSettingSortMode, "0"));
mSortInvert = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingSortInverted, false);
// Start task to get app list
AppListTask appListTask = new AppListTask();
appListTask.executeOnExecutor(mExecutor, (Object) null);
// Check environment
Requirements.check(this);
// Licensing
checkLicense();
// Listen for package add/remove
IntentFilter iff = new IntentFilter();
iff.addAction(Intent.ACTION_PACKAGE_ADDED);
iff.addAction(Intent.ACTION_PACKAGE_REMOVED);
iff.addDataScheme("package");
registerReceiver(mPackageChangeReceiver, iff);
mPackageChangeReceiverRegistered = true;
boolean showChangelog = true;
// First run
if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true)) {
showChangelog = false;
optionAbout();
}
// Tutorial
if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialMain, false)) {
showChangelog = false;
((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
}
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view) {
ViewParent parent = view.getParent();
while (!parent.getClass().equals(ScrollView.class))
parent = parent.getParent();
((View) parent).setVisibility(View.GONE);
PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.TRUE.toString());
}
};
((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener);
((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener);
// Legacy
if (!PrivacyManager.cVersion3) {
long now = new Date().getTime();
String legacy = PrivacyManager.getSetting(userId, PrivacyManager.cSettingLegacy, null);
if (legacy == null || now > Long.parseLong(legacy) + 7 * 24 * 60 * 60 * 1000L) {
showChangelog = false;
PrivacyManager.setSetting(userId, PrivacyManager.cSettingLegacy, Long.toString(now));
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.app_name);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setMessage(R.string.title_update_legacy);
alertDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Util.viewUri(ActivityMain.this,
Uri.parse("https://github.com/M66B/XPrivacy/blob/master/CHANGELOG.md#xprivacy3"));
}
});
alertDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
// Show changelog
if (showChangelog) {
String sVersion = PrivacyManager.getSetting(userId, PrivacyManager.cSettingChangelog, null);
Version changelogVersion = new Version(sVersion == null ? "0.0" : sVersion);
Version currentVersion = new Version(Util.getSelfVersionName(this));
if (sVersion == null || changelogVersion.compareTo(currentVersion) < 0)
optionChangelog();
}
}
@Override
protected void onResume() {
super.onResume();
// Update category selection
if (spRestriction != null) {
int userId = Util.getUserId(Process.myUid());
int pos = getSelectedCategory(userId);
spRestriction.setSelection(pos);
}
// Update list
if (mAppAdapter != null)
mAppAdapter.notifyDataSetChanged();
}
@Override
protected void onNewIntent(Intent intent) {
// Handle clear XPrivacy data (needs UI refresh)
Bundle extras = intent.getExtras();
if (extras != null && extras.containsKey(cAction) && extras.getInt(cAction) == cActionRefresh)
recreate();
else {
// Refresh application list
if (mAppAdapter != null)
mAppAdapter.notifyDataSetChanged();
// Import pro license
if (Intent.ACTION_VIEW.equals(intent.getAction()))
Util.importProLicense(new File(intent.getData().getPath()));
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mPackageChangeReceiverRegistered) {
unregisterReceiver(mPackageChangeReceiver);
mPackageChangeReceiverRegistered = false;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent dataIntent) {
super.onActivityResult(requestCode, resultCode, dataIntent);
if (requestCode == ACTIVITY_LICENSE) {
// License check
if (dataIntent != null) {
int code = dataIntent.getIntExtra("Code", -1);
int reason = dataIntent.getIntExtra("Reason", -1);
String sReason;
if (reason == LICENSED)
sReason = "LICENSED";
else if (reason == NOT_LICENSED)
sReason = "NOT_LICENSED";
else if (reason == RETRY)
sReason = "RETRY";
else if (reason == ERROR_CONTACTING_SERVER)
sReason = "ERROR_CONTACTING_SERVER";
else if (reason == ERROR_INVALID_PACKAGE_NAME)
sReason = "ERROR_INVALID_PACKAGE_NAME";
else if (reason == ERROR_NON_MATCHING_UID)
sReason = "ERROR_NON_MATCHING_UID";
else
sReason = Integer.toString(reason);
Util.log(null, Log.WARN, "Licensing: code=" + code + " reason=" + sReason);
if (code > 0) {
Util.setPro(true);
invalidateOptionsMenu();
Toast.makeText(this, getString(R.string.menu_pro), Toast.LENGTH_LONG).show();
} else if (reason == RETRY) {
Util.setPro(false);
mProHandler.postDelayed(new Runnable() {
@Override
public void run() {
checkLicense();
}
}, 30 * 1000);
}
}
}
}
// Filtering
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
selectRestriction(pos);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
selectRestriction(0);
}
private void selectRestriction(int pos) {
if (mAppAdapter != null) {
int userId = Util.getUserId(Process.myUid());
String restrictionName = (pos == 0 ? null : (String) PrivacyManager.getRestrictions(this).values()
.toArray()[pos - 1]);
mAppAdapter.setRestrictionName(restrictionName);
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSelectedCategory, restrictionName);
applyFilter();
}
}
private void applyFilter() {
if (mAppAdapter != null) {
ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter);
TextView tvStats = (TextView) findViewById(R.id.tvStats);
TextView tvState = (TextView) findViewById(R.id.tvState);
// Get settings
int userId = Util.getUserId(Process.myUid());
boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot,
false);
boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false);
boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
String filter = String.format("%s\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b", searchQuery, fUsed, fInternet,
fRestriction, fRestrictionNot, fPermission, fOnDemand, fOnDemandNot, fUser, fSystem);
pbFilter.setVisibility(ProgressBar.VISIBLE);
tvStats.setVisibility(TextView.GONE);
// Adjust progress state width
RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams();
tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.pbFilter);
mAppAdapter.getFilter().filter(filter);
}
}
private void applySort() {
if (mAppAdapter != null)
mAppAdapter.sort();
}
// Options
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
if (inflater != null && PrivacyService.checkClient()) {
// Inflate menu
inflater.inflate(R.menu.main, menu);
// Searchable
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
if (searchView != null) {
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
searchQuery = newText;
applyFilter();
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
searchQuery = query;
applyFilter();
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
searchQuery = "";
applyFilter();
return true;
}
});
}
return true;
} else
return false;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
int userId = Util.getUserId(Process.myUid());
boolean mounted = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
boolean updates = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingUpdates, false);
menu.findItem(R.id.menu_export).setEnabled(mounted);
menu.findItem(R.id.menu_import).setEnabled(mounted);
menu.findItem(R.id.menu_submit).setEnabled(Util.hasValidFingerPrint(this));
menu.findItem(R.id.menu_pro).setVisible(!Util.isProEnabled() && Util.hasProLicense(this) == null);
menu.findItem(R.id.menu_dump).setVisible(Util.isDebuggable(this));
menu.findItem(R.id.menu_update).setVisible(updates);
menu.findItem(R.id.menu_update).setEnabled(mounted);
// Update filter count
// Get settings
boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
// Count number of active filters
int numberOfFilters = 0;
if (fUsed)
numberOfFilters++;
if (fInternet)
numberOfFilters++;
if (fRestriction)
numberOfFilters++;
if (fPermission)
numberOfFilters++;
if (fOnDemand)
numberOfFilters++;
if (fUser)
numberOfFilters++;
if (fSystem)
numberOfFilters++;
if (numberOfFilters > 0) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_filter).copy(
Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setStyle(Style.FILL);
paint.setColor(Color.GRAY);
paint.setTextSize(bitmap.getWidth() / 3);
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
String text = Integer.toString(numberOfFilters);
Canvas canvas = new Canvas(bitmap);
canvas.drawText(text, bitmap.getWidth() - paint.measureText(text), bitmap.getHeight(), paint);
MenuItem fMenu = menu.findItem(R.id.menu_filter);
fMenu.setIcon(new BitmapDrawable(getResources(), bitmap));
}
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
try {
switch (item.getItemId()) {
case R.id.menu_sort:
optionSort();
return true;
case R.id.menu_filter:
optionFilter();
return true;
case R.id.menu_usage:
optionUsage();
return true;
case R.id.menu_template:
optionTemplate();
return true;
case R.id.menu_select_all:
optionSelectAll();
return true;
case R.id.menu_toggle:
optionToggle();
return true;
case R.id.menu_export:
optionExport();
return true;
case R.id.menu_import:
optionImport();
return true;
case R.id.menu_submit:
optionSubmit();
return true;
case R.id.menu_fetch:
optionFetch();
return true;
case R.id.menu_pro:
optionPro();
return true;
case R.id.menu_theme:
optionSwitchTheme();
return true;
case R.id.menu_settings:
optionSettings();
return true;
case R.id.menu_dump:
optionDump();
return true;
case R.id.menu_legend:
optionLegend();
return true;
case R.id.menu_tutorial:
optionTutorial();
return true;
case R.id.menu_changelog:
optionChangelog();
return true;
case R.id.menu_update:
optionUpdate();
return true;
case R.id.menu_report:
optionReportIssue();
return true;
case R.id.menu_about:
optionAbout();
return true;
default:
return super.onOptionsItemSelected(item);
}
} catch (Throwable ex) {
Util.bug(null, ex);
return true;
}
}
@SuppressLint("InflateParams")
private void optionSort() {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.sort, null);
final RadioGroup rgSMode = (RadioGroup) view.findViewById(R.id.rgSMode);
final CheckBox cbSInvert = (CheckBox) view.findViewById(R.id.cbSInvert);
// Initialise controls
switch (mSortMode) {
case SORT_BY_NAME:
rgSMode.check(R.id.rbSName);
break;
case SORT_BY_UID:
rgSMode.check(R.id.rbSUid);
break;
case SORT_BY_INSTALL_TIME:
rgSMode.check(R.id.rbSInstalled);
break;
case SORT_BY_UPDATE_TIME:
rgSMode.check(R.id.rbSUpdated);
break;
case SORT_BY_MODIFY_TIME:
rgSMode.check(R.id.rbSModified);
break;
case SORT_BY_STATE:
rgSMode.check(R.id.rbSState);
break;
}
cbSInvert.setChecked(mSortInvert);
// Build dialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
alertDialogBuilder.setTitle(R.string.menu_sort);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setView(view);
alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (rgSMode.getCheckedRadioButtonId()) {
case R.id.rbSName:
mSortMode = SORT_BY_NAME;
break;
case R.id.rbSUid:
mSortMode = SORT_BY_UID;
break;
case R.id.rbSInstalled:
mSortMode = SORT_BY_INSTALL_TIME;
break;
case R.id.rbSUpdated:
mSortMode = SORT_BY_UPDATE_TIME;
break;
case R.id.rbSModified:
mSortMode = SORT_BY_MODIFY_TIME;
break;
case R.id.rbSState:
mSortMode = SORT_BY_STATE;
break;
}
mSortInvert = cbSInvert.isChecked();
int userId = Util.getUserId(Process.myUid());
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortMode, Integer.toString(mSortMode));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSortInverted,
Boolean.toString(mSortInvert));
applySort();
}
});
alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
@SuppressLint("InflateParams")
private void optionFilter() {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.filters, null);
final CheckBox cbFUsed = (CheckBox) view.findViewById(R.id.cbFUsed);
final CheckBox cbFInternet = (CheckBox) view.findViewById(R.id.cbFInternet);
final CheckBox cbFPermission = (CheckBox) view.findViewById(R.id.cbFPermission);
final CheckBox cbFRestriction = (CheckBox) view.findViewById(R.id.cbFRestriction);
final CheckBox cbFRestrictionNot = (CheckBox) view.findViewById(R.id.cbFRestrictionNot);
final CheckBox cbFOnDemand = (CheckBox) view.findViewById(R.id.cbFOnDemand);
final CheckBox cbFOnDemandNot = (CheckBox) view.findViewById(R.id.cbFOnDemandNot);
final CheckBox cbFUser = (CheckBox) view.findViewById(R.id.cbFUser);
final CheckBox cbFSystem = (CheckBox) view.findViewById(R.id.cbFSystem);
final Button btnDefault = (Button) view.findViewById(R.id.btnDefault);
// Get settings
final int userId = Util.getUserId(Process.myUid());
boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false);
boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false);
boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true);
boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false);
boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false);
boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false);
boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false);
boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true);
boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false);
boolean ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
// Setup checkboxes
cbFUsed.setChecked(fUsed);
cbFInternet.setChecked(fInternet);
cbFPermission.setChecked(fPermission);
cbFRestriction.setChecked(fRestriction);
cbFRestrictionNot.setChecked(fRestrictionNot);
cbFOnDemand.setChecked(fOnDemand && ondemand);
cbFOnDemandNot.setChecked(fOnDemandNot && ondemand);
cbFUser.setChecked(fUser);
cbFSystem.setChecked(fSystem);
cbFRestrictionNot.setEnabled(fRestriction);
cbFOnDemand.setEnabled(ondemand);
cbFOnDemandNot.setEnabled(fOnDemand && ondemand);
// Manage user/system filter exclusivity
OnCheckedChangeListener checkListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == cbFUser) {
if (isChecked)
cbFSystem.setChecked(false);
} else if (buttonView == cbFSystem) {
if (isChecked)
cbFUser.setChecked(false);
} else if (buttonView == cbFRestriction)
cbFRestrictionNot.setEnabled(cbFRestriction.isChecked());
else if (buttonView == cbFOnDemand)
cbFOnDemandNot.setEnabled(cbFOnDemand.isChecked());
}
};
cbFUser.setOnCheckedChangeListener(checkListener);
cbFSystem.setOnCheckedChangeListener(checkListener);
cbFRestriction.setOnCheckedChangeListener(checkListener);
cbFOnDemand.setOnCheckedChangeListener(checkListener);
// Clear button
btnDefault.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
cbFUsed.setChecked(false);
cbFInternet.setChecked(false);
cbFPermission.setChecked(true);
cbFRestriction.setChecked(false);
cbFRestrictionNot.setChecked(false);
cbFOnDemand.setChecked(false);
cbFOnDemandNot.setChecked(false);
cbFUser.setChecked(true);
cbFSystem.setChecked(false);
}
});
// Build dialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
alertDialogBuilder.setTitle(R.string.menu_filter);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setView(view);
alertDialogBuilder.setPositiveButton(ActivityMain.this.getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUsed,
Boolean.toString(cbFUsed.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFInternet,
Boolean.toString(cbFInternet.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestriction,
Boolean.toString(cbFRestriction.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFRestrictionNot,
Boolean.toString(cbFRestrictionNot.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFPermission,
Boolean.toString(cbFPermission.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemand,
Boolean.toString(cbFOnDemand.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFOnDemandNot,
Boolean.toString(cbFOnDemandNot.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFUser,
Boolean.toString(cbFUser.isChecked()));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFSystem,
Boolean.toString(cbFSystem.isChecked()));
invalidateOptionsMenu();
applyFilter();
}
});
alertDialogBuilder.setNegativeButton(ActivityMain.this.getString(android.R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
private void optionUsage() {
Intent intent = new Intent(this, ActivityUsage.class);
if (mAppAdapter != null && mAppAdapter.getRestrictionName() != null)
intent.putExtra(ActivityUsage.cRestriction, mAppAdapter.getRestrictionName());
startActivity(intent);
}
@SuppressLint("InflateParams")
private void optionTemplate() {
final int userId = Util.getUserId(Process.myUid());
// Build view
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.template, null);
final Spinner spTemplate = (Spinner) view.findViewById(R.id.spTemplate);
Button btnRename = (Button) view.findViewById(R.id.btnRename);
ExpandableListView elvTemplate = (ExpandableListView) view.findViewById(R.id.elvTemplate);
// Template selector
final SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item);
spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0",
getString(R.string.title_default));
spAdapter.add(defaultName);
for (int i = 1; i <= 4; i++) {
String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i),
getString(R.string.title_alternate) + " " + i);
spAdapter.add(alternateName);
}
spTemplate.setAdapter(spAdapter);
// Template definition
final TemplateListAdapter templateAdapter = new TemplateListAdapter(this, view, R.layout.templateentry);
elvTemplate.setAdapter(templateAdapter);
elvTemplate.setGroupIndicator(null);
spTemplate.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
templateAdapter.notifyDataSetChanged();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
templateAdapter.notifyDataSetChanged();
}
});
btnRename.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Util.hasProLicense(ActivityMain.this) == null) {
// Redirect to pro page
Util.viewUri(ActivityMain.this, cProUri);
return;
}
final int templateId = spTemplate.getSelectedItemPosition();
if (templateId == AdapterView.INVALID_POSITION)
return;
AlertDialog.Builder dlgRename = new AlertDialog.Builder(spTemplate.getContext());
dlgRename.setTitle(R.string.title_rename);
final String original = (templateId == 0 ? getString(R.string.title_default)
: getString(R.string.title_alternate) + " " + templateId);
dlgRename.setMessage(original);
final EditText input = new EditText(spTemplate.getContext());
dlgRename.setView(input);
dlgRename.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String name = input.getText().toString();
if (TextUtils.isEmpty(name)) {
PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId),
null);
name = original;
} else {
PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId),
name);
}
spAdapter.remove(spAdapter.getItem(templateId));
spAdapter.insert(name, templateId);
spAdapter.notifyDataSetChanged();
}
});
dlgRename.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing
}
});
dlgRename.create().show();
}
});
// Build dialog
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.menu_template);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setView(view);
alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
});
// Show dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
private void optionSelectAll() {
// Select all visible apps
if (mAppAdapter != null)
mAppAdapter.selectAllVisible();
}
private void optionToggle() {
if (mAppAdapter != null) {
Intent intent = new Intent(ActivityShare.ACTION_TOGGLE);
intent.putExtra(ActivityShare.cInteractive, true);
intent.putExtra(ActivityShare.cUidList,
mAppAdapter == null ? new int[0] : mAppAdapter.getSelectedOrVisibleUid(0));
intent.putExtra(ActivityShare.cRestriction, mAppAdapter.getRestrictionName());
startActivity(intent);
}
}
private void optionExport() {
Intent intent = new Intent(ActivityShare.ACTION_EXPORT);
intent.putExtra(ActivityShare.cInteractive, true);
intent.putExtra(ActivityShare.cUidList,
mAppAdapter == null ? new int[0] : mAppAdapter.getSelectedOrVisibleUid(AppListAdapter.cSelectAppAll));
startActivity(intent);
}
private void optionImport() {
Intent intent = new Intent(ActivityShare.ACTION_IMPORT);
intent.putExtra(ActivityShare.cInteractive, true);
intent.putExtra(ActivityShare.cUidList,
mAppAdapter == null ? new int[0] : mAppAdapter.getSelectedOrVisibleUid(0));
startActivity(intent);
}
private void optionSubmit() {
if (ActivityShare.registerDevice(this)) {
int[] uid = (mAppAdapter == null ? new int[0] : mAppAdapter
.getSelectedOrVisibleUid(AppListAdapter.cSelectAppNone));
if (uid.length == 0) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.app_name);
alertDialogBuilder.setMessage(R.string.msg_select);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
} else if (uid.length <= ActivityShare.cSubmitLimit) {
if (mAppAdapter != null) {
Intent intent = new Intent(ActivityShare.ACTION_SUBMIT);
intent.putExtra(ActivityShare.cInteractive, true);
intent.putExtra(ActivityShare.cUidList, uid);
startActivity(intent);
}
} else {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.app_name);
alertDialogBuilder.setMessage(getString(R.string.msg_limit, ActivityShare.cSubmitLimit + 1));
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
}
private void optionFetch() {
if (Util.hasProLicense(this) == null) {
// Redirect to pro page
Util.viewUri(this, cProUri);
} else {
if (mAppAdapter != null) {
Intent intent = new Intent(ActivityShare.ACTION_FETCH);
intent.putExtra(ActivityShare.cInteractive, true);
intent.putExtra(ActivityShare.cUidList,
mAppAdapter == null ? new int[0] : mAppAdapter.getSelectedOrVisibleUid(0));
startActivity(intent);
}
}
}
private void optionPro() {
// Redirect to pro page
Util.viewUri(this, cProUri);
}
private void optionSwitchTheme() {
int userId = Util.getUserId(Process.myUid());
String themeName = PrivacyManager.getSetting(userId, PrivacyManager.cSettingTheme, "");
themeName = (themeName.equals("Dark") ? "Light" : "Dark");
PrivacyManager.setSetting(userId, PrivacyManager.cSettingTheme, themeName);
this.recreate();
}
private void optionSettings() {
Intent intent = new Intent(this, ActivitySettings.class);
startActivity(intent);
}
private void optionDump() {
try {
PrivacyService.getClient().dump(0);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
private void optionLegend() {
// Show help
Dialog dialog = new Dialog(ActivityMain.this);
dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog.setTitle(R.string.menu_legend);
dialog.setContentView(R.layout.legend);
dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());
for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "details"))
child.setVisibility(View.GONE);
((LinearLayout) dialog.findViewById(R.id.llUnsafe)).setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE
: View.GONE);
dialog.setCancelable(true);
dialog.show();
}
private void optionTutorial() {
((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
int userId = Util.getUserId(Process.myUid());
PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString());
Dialog dlgUsage = new Dialog(this);
dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dlgUsage.setTitle(R.string.title_usage_header);
dlgUsage.setContentView(R.layout.usage);
dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
dlgUsage.setCancelable(true);
dlgUsage.show();
}
private void optionChangelog() {
WebView webview = new WebView(this);
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
int userId = Util.getUserId(Process.myUid());
Version currentVersion = new Version(Util.getSelfVersionName(ActivityMain.this));
PrivacyManager.setSetting(userId, PrivacyManager.cSettingChangelog, currentVersion.toString());
}
});
webview.loadUrl("https://github.com/M66B/XPrivacy/blob/master/CHANGELOG.md");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle(R.string.menu_changelog);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setView(webview);
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
private void optionUpdate() {
if (Util.hasProLicense(this) == null)
Util.viewUri(this, ActivityMain.cProUri);
else
new ActivityShare.UpdateTask(this).executeOnExecutor(mExecutor);
}
private void optionReportIssue() {
// Report issue
Util.viewUri(this, Uri.parse("https://github.com/M66B/XPrivacy#support"));
}
@SuppressLint("DefaultLocale")
private void optionAbout() {
// About
Dialog dlgAbout = new Dialog(this);
dlgAbout.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dlgAbout.setTitle(R.string.menu_about);
dlgAbout.setContentView(R.layout.about);
dlgAbout.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
// Show version
try {
int userId = Util.getUserId(Process.myUid());
Version currentVersion = new Version(Util.getSelfVersionName(this));
Version storedVersion = new Version(
PrivacyManager.getSetting(userId, PrivacyManager.cSettingVersion, "0.0"));
boolean migrated = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingMigrated, false);
String versionName = currentVersion.toString();
if (currentVersion.compareTo(storedVersion) != 0)
versionName += "/" + storedVersion.toString();
if (!migrated)
versionName += "!";
int versionCode = Util.getSelfVersionCode(this);
TextView tvVersion = (TextView) dlgAbout.findViewById(R.id.tvVersion);
tvVersion.setText(String.format(getString(R.string.app_version), versionName, versionCode));
} catch (Throwable ex) {
Util.bug(null, ex);
}
if (!PrivacyManager.cVersion3 || Hook.isAOSP(19))
((TextView) dlgAbout.findViewById(R.id.tvCompatibility)).setVisibility(View.GONE);
// Show license
String licensed = Util.hasProLicense(this);
TextView tvLicensed1 = (TextView) dlgAbout.findViewById(R.id.tvLicensed);
TextView tvLicensed2 = (TextView) dlgAbout.findViewById(R.id.tvLicensedAlt);
if (licensed == null) {
tvLicensed1.setText(Environment.getExternalStorageDirectory().getAbsolutePath());
tvLicensed2.setText(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
.getAbsolutePath());
} else {
tvLicensed1.setText(String.format(getString(R.string.app_licensed), licensed));
tvLicensed2.setVisibility(View.GONE);
}
// Show some build properties
String android = String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT);
((TextView) dlgAbout.findViewById(R.id.tvAndroid)).setText(android);
((TextView) dlgAbout.findViewById(R.id.build_brand)).setText(Build.BRAND);
((TextView) dlgAbout.findViewById(R.id.build_manufacturer)).setText(Build.MANUFACTURER);
((TextView) dlgAbout.findViewById(R.id.build_model)).setText(Build.MODEL);
((TextView) dlgAbout.findViewById(R.id.build_product)).setText(Build.PRODUCT);
((TextView) dlgAbout.findViewById(R.id.build_device)).setText(Build.DEVICE);
((TextView) dlgAbout.findViewById(R.id.build_host)).setText(Build.HOST);
((TextView) dlgAbout.findViewById(R.id.build_display)).setText(Build.DISPLAY);
((TextView) dlgAbout.findViewById(R.id.build_id)).setText(Build.ID);
dlgAbout.setCancelable(true);
final int userId = Util.getUserId(Process.myUid());
if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true))
dlgAbout.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Dialog dlgUsage = new Dialog(ActivityMain.this);
dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dlgUsage.setTitle(R.string.app_name);
dlgUsage.setContentView(R.layout.usage);
dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));
dlgUsage.setCancelable(true);
dlgUsage.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
PrivacyManager.setSetting(userId, PrivacyManager.cSettingFirstRun, Boolean.FALSE.toString());
optionLegend();
}
});
dlgUsage.show();
}
});
dlgAbout.show();
}
// Tasks
private class AppListTask extends AsyncTask<Object, Integer, List<ApplicationInfoEx>> {
private String mRestrictionName;
private ProgressDialog mProgressDialog;
@Override
protected List<ApplicationInfoEx> doInBackground(Object... params) {
mRestrictionName = null;
// Delegate
return ApplicationInfoEx.getXApplicationList(ActivityMain.this, mProgressDialog);
}
@SuppressWarnings("deprecation")
@Override
protected void onPreExecute() {
super.onPreExecute();
TypedArray ta = getTheme().obtainStyledAttributes(new int[] { R.attr.progress_horizontal });
int progress_horizontal = ta.getResourceId(0, 0);
ta.recycle();
// Show progress dialog
mProgressDialog = new ProgressDialog(ActivityMain.this);
mProgressDialog.setMessage(getString(R.string.msg_loading));
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setProgressDrawable(getResources().getDrawable(progress_horizontal));
mProgressDialog.setProgressNumberFormat(null);
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
}
@Override
protected void onPostExecute(List<ApplicationInfoEx> listApp) {
if (!ActivityMain.this.isFinishing()) {
// Display app list
mAppAdapter = new AppListAdapter(ActivityMain.this, R.layout.mainentry, listApp, mRestrictionName);
ListView lvApp = (ListView) findViewById(R.id.lvApp);
lvApp.setAdapter(mAppAdapter);
// Dismiss progress dialog
if (mProgressDialog.isShowing())
try {
mProgressDialog.dismiss();
} catch (IllegalArgumentException ignored) {
}
// Restore state
ActivityMain.this.selectRestriction(spRestriction.getSelectedItemPosition());
}
super.onPostExecute(listApp);
}
}
// Adapters
private class SpinnerAdapter extends ArrayAdapter<String> {
public SpinnerAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
}
}
@SuppressLint("DefaultLocale")
private class TemplateListAdapter extends BaseExpandableListAdapter {
private View mView;
private Spinner mSpinner;
private List<String> listRestrictionName;
private List<String> listLocalizedTitle;
private boolean ondemand;
private Version version;
private LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
public TemplateListAdapter(Context context, View view, int resource) {
mView = view;
mSpinner = (Spinner) view.findViewById(R.id.spTemplate);
// Get restriction categories
TreeMap<String, String> tmRestriction = PrivacyManager.getRestrictions(context);
listRestrictionName = new ArrayList<String>(tmRestriction.values());
listLocalizedTitle = new ArrayList<String>(tmRestriction.navigableKeySet());
int userId = Util.getUserId(Process.myUid());
ondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
version = new Version(Util.getSelfVersionName(context));
}
private String getTemplate() {
if (mSpinner.getSelectedItemPosition() == 0)
return Meta.cTypeTemplate;
else
return Meta.cTypeTemplate + mSpinner.getSelectedItemPosition();
}
private class ViewHolder {
private View row;
public ImageView imgIndicator;
public ImageView imgInfo;
public TextView tvRestriction;
public ImageView imgUnsafe;
public ImageView imgCbRestrict;
public ImageView imgCbAsk;
public boolean restricted;
public boolean asked;
public ViewHolder(View theRow) {
row = theRow;
imgIndicator = (ImageView) row.findViewById(R.id.imgIndicator);
imgInfo = (ImageView) row.findViewById(R.id.imgInfo);
tvRestriction = (TextView) row.findViewById(R.id.tvRestriction);
imgUnsafe = (ImageView) row.findViewById(R.id.imgUnsafe);
imgCbRestrict = (ImageView) row.findViewById(R.id.imgCbRestrict);
imgCbAsk = (ImageView) row.findViewById(R.id.imgCbAsk);
}
}
@Override
public Object getGroup(int groupPosition) {
return listRestrictionName.get(groupPosition);
}
@Override
public int getGroupCount() {
return listRestrictionName.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
@SuppressLint("InflateParams")
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.templateentry, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
// Get entry
final String restrictionName = (String) getGroup(groupPosition);
// Get info
final int userId = Util.getUserId(Process.myUid());
String value = PrivacyManager.getSetting(userId, getTemplate(), restrictionName,
Boolean.toString(!ondemand) + "+ask");
holder.restricted = value.contains("true");
holder.asked = (!ondemand || value.contains("asked"));
boolean partialRestricted = false;
boolean partialAsked = false;
if (holder.restricted || !holder.asked)
for (Hook hook : PrivacyManager.getHooks(restrictionName, version)) {
String settingName = restrictionName + "." + hook.getName();
String childValue = PrivacyManager.getSetting(userId, getTemplate(), settingName, null);
if (childValue == null)
childValue = Boolean.toString(holder.restricted && !hook.isDangerous())
+ (holder.asked || (hook.isDangerous() && hook.whitelist() == null) ? "+asked" : "+ask");
if (!childValue.contains("true"))
partialRestricted = true;
if (childValue.contains("asked"))
partialAsked = true;
}
Bitmap bmRestricted = (holder.restricted ? partialRestricted ? getHalfCheckBox() : getFullCheckBox()
: getOffCheckBox());
Bitmap bmAsked = (holder.asked ? getOffCheckBox() : partialAsked ? getHalfCheckBox()
: getOnDemandCheckBox());
// Indicator state
holder.imgIndicator.setImageResource(getThemed(isExpanded ? R.attr.icon_expander_maximized
: R.attr.icon_expander_minimized));
holder.imgIndicator.setVisibility(View.VISIBLE);
holder.imgInfo.setVisibility(View.GONE);
holder.imgUnsafe.setVisibility(View.GONE);
// Set data
holder.tvRestriction.setTypeface(null, Typeface.BOLD);
holder.tvRestriction.setText(listLocalizedTitle.get(groupPosition));
holder.imgCbRestrict.setImageBitmap(bmRestricted);
holder.imgCbAsk.setImageBitmap(bmAsked);
holder.imgCbAsk.setVisibility(ondemand ? View.VISIBLE : View.GONE);
holder.imgCbRestrict.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Update setting
holder.restricted = !holder.restricted;
PrivacyManager.setSetting(userId, getTemplate(), restrictionName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
notifyDataSetChanged(); // update childs
}
});
holder.imgCbAsk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Update setting
holder.asked = (!ondemand || !holder.asked);
PrivacyManager.setSetting(userId, getTemplate(), restrictionName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
notifyDataSetChanged(); // update childs
}
});
return convertView;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return PrivacyManager.getHooks((String) getGroup(groupPosition), version).get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
return PrivacyManager.getHooks((String) getGroup(groupPosition), version).size();
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
@Override
@SuppressLint("InflateParams")
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.templateentry, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
// Get entry
final int userId = Util.getUserId(Process.myUid());
final String restrictionName = (String) getGroup(groupPosition);
final Hook hook = (Hook) getChild(groupPosition, childPosition);
final String settingName = restrictionName + "." + hook.getName();
// Get parent info
String parentValue = PrivacyManager.getSetting(userId, getTemplate(), restrictionName,
Boolean.toString(!ondemand) + "+ask");
boolean parentRestricted = parentValue.contains("true");
boolean parentAsked = (!ondemand || parentValue.contains("asked"));
// Get child info
String value = PrivacyManager.getSetting(userId, getTemplate(), settingName, null);
// This is to circumvent caching problems
// The child value depends on the parent value
if (value == null)
value = Boolean.toString(parentRestricted && !hook.isDangerous())
+ (parentAsked || (hook.isDangerous() && hook.whitelist() == null) ? "+asked" : "+ask");
holder.restricted = value.contains("true");
holder.asked = (!ondemand || value.contains("asked"));
Bitmap bmRestricted = (parentRestricted && holder.restricted ? getFullCheckBox() : getOffCheckBox());
Bitmap bmAsked = (parentAsked || holder.asked ? getOffCheckBox() : getOnDemandCheckBox());
// Set indicator
holder.imgIndicator.setVisibility(View.INVISIBLE);
// Function help
if (hook.getAnnotation() == null)
holder.imgInfo.setVisibility(View.GONE);
else {
holder.imgInfo.setVisibility(View.VISIBLE);
holder.imgInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityApp.showHelp(ActivityMain.this, mView, hook);
}
});
}
holder.imgUnsafe.setVisibility(hook.isUnsafe() ? View.VISIBLE : View.GONE);
// Set data
if (hook.isDangerous())
holder.row.setBackgroundColor(getResources().getColor(
getThemed(hook.isDangerousDefined() ? R.attr.color_dangerous : R.attr.color_dangerous_user)));
else
holder.row.setBackgroundColor(hook.isDangerousDefined() ? getResources().getColor(
getThemed(R.attr.color_dangerous_off)) : Color.TRANSPARENT);
holder.tvRestriction.setText(hook.getName());
holder.imgCbRestrict.setEnabled(parentRestricted);
holder.imgCbRestrict.setImageBitmap(bmRestricted);
holder.imgCbAsk.setEnabled(!parentAsked);
holder.imgCbAsk.setImageBitmap(bmAsked);
holder.imgCbAsk.setVisibility(ondemand ? View.VISIBLE : View.GONE);
// Listen for long press
if (Util.getUserId(Process.myUid()) == 0)
holder.tvRestriction.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
hook.toggleDangerous();
// Change background color
if (hook.isDangerous())
holder.row.setBackgroundColor(getResources().getColor(
getThemed(hook.isDangerousDefined() ? R.attr.color_dangerous
: R.attr.color_dangerous_user)));
else
holder.row.setBackgroundColor(hook.isDangerousDefined() ? getResources().getColor(
getThemed(R.attr.color_dangerous_off)) : Color.TRANSPARENT);
notifyDataSetChanged();
return true;
}
});
holder.imgCbRestrict.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Update setting
holder.restricted = !holder.restricted;
PrivacyManager.setSetting(userId, getTemplate(), settingName,
(holder.restricted ? "true" : "false") + "+" + (holder.asked ? "asked" : "ask"));
notifyDataSetChanged(); // update parent
}
});
holder.imgCbAsk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Update setting
holder.asked = !holder.asked;
PrivacyManager.setSetting(userId, getTemplate(), settingName,
(holder.restricted ? "true" : "false") + "+" + (holder.asked ? "asked" : "ask"));
notifyDataSetChanged(); // update parent
}
});
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
}
@SuppressLint("DefaultLocale")
private class AppListAdapter extends ArrayAdapter<ApplicationInfoEx> {
private Context mContext;
private boolean mSelecting = false;
private List<ApplicationInfoEx> mListAppAll;
private List<ApplicationInfoEx> mListAppSelected = new ArrayList<ApplicationInfoEx>();
private String mRestrictionName;
private Version mVersion;
private LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
private AtomicInteger mFiltersRunning = new AtomicInteger(0);
private int mHighlightColor;
public final static int cSelectAppAll = 1;
public final static int cSelectAppNone = 2;
public AppListAdapter(Context context, int resource, List<ApplicationInfoEx> objects,
String initialRestrictionName) {
super(context, resource, objects);
mContext = context;
mListAppAll = new ArrayList<ApplicationInfoEx>();
mListAppAll.addAll(objects);
mRestrictionName = initialRestrictionName;
mVersion = new Version(Util.getSelfVersionName(context));
TypedArray ta1 = context.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.colorPressedHighlight });
mHighlightColor = ta1.getColor(0, 0xFF00FF);
ta1.recycle();
}
public void setRestrictionName(String restrictionName) {
mRestrictionName = restrictionName;
}
public String getRestrictionName() {
return mRestrictionName;
}
public List<ApplicationInfoEx> getSelectedOrVisible(int flags) {
if (mListAppSelected.size() > 0)
return mListAppSelected;
else {
if (flags == cSelectAppAll)
return mListAppAll;
else {
List<ApplicationInfoEx> listApp = new ArrayList<ApplicationInfoEx>();
if (flags != cSelectAppNone)
for (int i = 0; i < this.getCount(); i++)
listApp.add(this.getItem(i));
return listApp;
}
}
}
public int[] getSelectedOrVisibleUid(int flags) {
List<ApplicationInfoEx> listAppInfo = getSelectedOrVisible(flags);
int[] uid = new int[listAppInfo.size()];
for (int pos = 0; pos < listAppInfo.size(); pos++)
uid[pos] = listAppInfo.get(pos).getUid();
return uid;
}
public void selectAllVisible() {
// Look through the visible apps to figure out what to do
mSelecting = false;
for (int i = 0; i < this.getCount(); i++) {
if (!mListAppSelected.contains(this.getItem(i))) {
mSelecting = true;
break;
}
}
if (mSelecting) {
// Add the visible apps not already selected
for (int i = 0; i < this.getCount(); i++)
if (!mListAppSelected.contains(this.getItem(i)))
mListAppSelected.add(this.getItem(i));
} else
mListAppSelected.clear();
this.showStats();
this.notifyDataSetChanged();
}
public void showStats() {
TextView tvStats = (TextView) findViewById(R.id.tvStats);
String stats = String.format("%d/%d", this.getCount(), mListAppAll.size());
if (mListAppSelected.size() > 0)
stats += String.format(" (%d)", mListAppSelected.size());
tvStats.setText(stats);
}
@Override
public Filter getFilter() {
return new AppFilter();
}
private class AppFilter extends Filter {
public AppFilter() {
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
int userId = Util.getUserId(Process.myUid());
int filtersRunning = mFiltersRunning.addAndGet(1);
FilterResults results = new FilterResults();
// Get arguments
String[] components = ((String) constraint).split("\\n");
String fName = components[0];
boolean fUsed = Boolean.parseBoolean(components[1]);
boolean fInternet = Boolean.parseBoolean(components[2]);
boolean fRestricted = Boolean.parseBoolean(components[3]);
boolean fRestrictedNot = Boolean.parseBoolean(components[4]);
boolean fPermission = Boolean.parseBoolean(components[5]);
boolean fOnDemand = Boolean.parseBoolean(components[6]);
boolean fOnDemandNot = Boolean.parseBoolean(components[7]);
boolean fUser = Boolean.parseBoolean(components[8]);
boolean fSystem = Boolean.parseBoolean(components[9]);
// Match applications
int current = 0;
int max = AppListAdapter.this.mListAppAll.size();
List<ApplicationInfoEx> lstApp = new ArrayList<ApplicationInfoEx>();
for (ApplicationInfoEx xAppInfo : AppListAdapter.this.mListAppAll) {
// Check if another filter has been started
if (filtersRunning != mFiltersRunning.get())
return null;
// Send progress info to main activity
current++;
if (current % 5 == 0) {
final int position = current;
final int maximum = max;
runOnUiThread(new Runnable() {
@Override
public void run() {
setProgress(getString(R.string.msg_applying), position, maximum);
}
});
}
// Get if name contains
boolean contains = false;
if (!fName.equals(""))
contains = (xAppInfo.toString().toLowerCase().contains(((String) fName).toLowerCase()));
// Get if used
boolean used = false;
if (fUsed)
used = (PrivacyManager.getUsage(xAppInfo.getUid(), mRestrictionName, null) != 0);
// Get if internet
boolean internet = false;
if (fInternet)
internet = xAppInfo.hasInternet(mContext);
// Get some restricted
boolean someRestricted = false;
if (fRestricted)
for (PRestriction restriction : PrivacyManager.getRestrictionList(xAppInfo.getUid(),
mRestrictionName))
if (restriction.restricted) {
someRestricted = true;
break;
}
// Get Android permission
boolean permission = false;
if (fPermission)
if (mRestrictionName == null)
permission = true;
else if (PrivacyManager.hasPermission(mContext, xAppInfo, mRestrictionName, mVersion)
|| PrivacyManager.getUsage(xAppInfo.getUid(), mRestrictionName, null) > 0)
permission = true;
// Get if onDemand
boolean onDemand = false;
boolean isApp = PrivacyManager.isApplication(xAppInfo.getUid());
boolean odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem,
false);
boolean gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
if (fOnDemand && (isApp || odSystem) && gondemand) {
onDemand = PrivacyManager.getSettingBool(-xAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
false);
if (onDemand && mRestrictionName != null)
onDemand = !PrivacyManager.getRestrictionEx(xAppInfo.getUid(), mRestrictionName, null).asked;
}
// Get if user
boolean user = false;
if (fUser)
user = !xAppInfo.isSystem();
// Get if system
boolean system = false;
if (fSystem)
system = xAppInfo.isSystem();
// Apply filters
if ((fName.equals("") ? true : contains) && (fUsed ? used : true) && (fInternet ? internet : true)
&& (fRestricted ? (fRestrictedNot ? !someRestricted : someRestricted) : true)
&& (fPermission ? permission : true)
&& (fOnDemand ? (fOnDemandNot ? !onDemand : onDemand) : true) && (fUser ? user : true)
&& (fSystem ? system : true))
lstApp.add(xAppInfo);
}
// Check again whether another filter has been started
if (filtersRunning != mFiltersRunning.get())
return null;
// Apply current sorting
Collections.sort(lstApp, mSorter);
// Last check whether another filter has been started
if (filtersRunning != mFiltersRunning.get())
return null;
synchronized (this) {
results.values = lstApp;
results.count = lstApp.size();
}
return results;
}
@Override
@SuppressWarnings("unchecked")
protected void publishResults(CharSequence constraint, FilterResults results) {
if (results != null) {
clear();
TextView tvStats = (TextView) findViewById(R.id.tvStats);
TextView tvState = (TextView) findViewById(R.id.tvState);
ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter);
pbFilter.setVisibility(ProgressBar.GONE);
tvStats.setVisibility(TextView.VISIBLE);
runOnUiThread(new Runnable() {
@Override
public void run() {
setProgress(getString(R.string.title_restrict), 0, 1);
}
});
// Adjust progress state width
RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams();
tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.tvStats);
if (results.values == null)
notifyDataSetInvalidated();
else {
addAll((ArrayList<ApplicationInfoEx>) results.values);
notifyDataSetChanged();
}
AppListAdapter.this.showStats();
}
}
}
public void sort() {
sort(mSorter);
}
private class ViewHolder {
private View row;
private int position;
public View vwState;
public LinearLayout llAppType;
public ImageView imgIcon;
public ImageView imgUsed;
public ImageView imgGranted;
public ImageView imgInternet;
public ImageView imgFrozen;
public ImageView imgSettings;
public LinearLayout llName;
public TextView tvName;
public ImageView imgCbRestricted;
public ProgressBar pbRunning;
public ImageView imgCbAsk;
public ViewHolder(View theRow, int thePosition) {
row = theRow;
position = thePosition;
vwState = (View) row.findViewById(R.id.vwState);
llAppType = (LinearLayout) row.findViewById(R.id.llAppType);
imgIcon = (ImageView) row.findViewById(R.id.imgIcon);
imgUsed = (ImageView) row.findViewById(R.id.imgUsed);
imgGranted = (ImageView) row.findViewById(R.id.imgGranted);
imgInternet = (ImageView) row.findViewById(R.id.imgInternet);
imgFrozen = (ImageView) row.findViewById(R.id.imgFrozen);
imgSettings = (ImageView) row.findViewById(R.id.imgSettings);
llName = (LinearLayout) row.findViewById(R.id.llName);
tvName = (TextView) row.findViewById(R.id.tvName);
imgCbRestricted = (ImageView) row.findViewById(R.id.imgCbRestricted);
pbRunning = (ProgressBar) row.findViewById(R.id.pbRunning);
imgCbAsk = (ImageView) row.findViewById(R.id.imgCbAsk);
}
}
private class HolderTask extends AsyncTask<Object, Object, Object> {
private int position;
private ViewHolder holder;
private ApplicationInfoEx xAppInfo = null;
private int state;
private Bitmap bicon;
private Drawable dicon;
private boolean used;
private boolean enabled;
private boolean granted;
private boolean settings;
private RState rstate;
private boolean gondemand;
private boolean ondemand;
private boolean can;
private boolean methodExpert;
public HolderTask(int thePosition, ViewHolder theHolder, ApplicationInfoEx theAppInfo) {
position = thePosition;
holder = theHolder;
xAppInfo = theAppInfo;
}
@Override
protected Object doInBackground(Object... params) {
if (xAppInfo != null) {
int userId = Util.getUserId(Process.myUid());
// Get state
state = xAppInfo.getState(ActivityMain.this);
// Get icon
bicon = xAppInfo.getIconBitmap(ActivityMain.this);
if (bicon == null)
dicon = xAppInfo.getIcon(ActivityMain.this);
// Get if used
used = (PrivacyManager.getUsage(xAppInfo.getUid(), mRestrictionName, null) != 0);
// Get if enabled
enabled = PrivacyManager.getSettingBool(xAppInfo.getUid(), PrivacyManager.cSettingRestricted, true);
// Get if on demand
gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true);
boolean isApp = PrivacyManager.isApplication(xAppInfo.getUid());
boolean odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem,
false);
ondemand = (isApp || odSystem);
if (ondemand && mRestrictionName != null)
ondemand = PrivacyManager.getSettingBool(-xAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
false);
// Get if granted
granted = true;
if (mRestrictionName != null)
if (!PrivacyManager.hasPermission(ActivityMain.this, xAppInfo, mRestrictionName, mVersion))
granted = false;
// Get if application settings
settings = PrivacyManager.hasSpecificSettings(xAppInfo.getUid());
// Get restriction/ask state
rstate = new RState(xAppInfo.getUid(), mRestrictionName, null, mVersion);
// Get can restrict
can = PrivacyManager.canRestrict(rstate.mUid, Process.myUid(), rstate.mRestrictionName,
rstate.mMethodName, true);
methodExpert = (mRestrictionName == null || PrivacyManager.getSettingBool(userId,
PrivacyManager.cSettingMethodExpert, false));
return holder;
}
return null;
}
@Override
protected void onPostExecute(Object result) {
if (holder.position == position && result != null) {
// Set background color
if (xAppInfo.isSystem())
holder.llAppType.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
else
holder.llAppType.setBackgroundColor(Color.TRANSPARENT);
// Display state
if (state == ApplicationInfoEx.STATE_ATTENTION)
holder.vwState.setBackgroundColor(getResources().getColor(
getThemed(R.attr.color_state_attention)));
else if (state == ApplicationInfoEx.STATE_SHARED)
holder.vwState
.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_state_shared)));
else
holder.vwState.setBackgroundColor(getResources().getColor(
getThemed(R.attr.color_state_restricted)));
// Display icon
if (bicon == null)
holder.imgIcon.setImageDrawable(dicon);
else
holder.imgIcon.setImageBitmap(bicon);
holder.imgIcon.setVisibility(View.VISIBLE);
// Display on demand
if (gondemand) {
if (ondemand) {
holder.imgCbAsk.setImageBitmap(getAskBoxImage(rstate, methodExpert));
holder.imgCbAsk.setVisibility(View.VISIBLE);
} else
holder.imgCbAsk.setVisibility(View.INVISIBLE);
} else
holder.imgCbAsk.setVisibility(View.GONE);
// Display usage
holder.tvName.setTypeface(null, used ? Typeface.BOLD_ITALIC : Typeface.NORMAL);
holder.imgUsed.setVisibility(used ? View.VISIBLE : View.INVISIBLE);
// Display if permissions
holder.imgGranted.setVisibility(granted ? View.VISIBLE : View.INVISIBLE);
// Display if internet access
holder.imgInternet.setVisibility(xAppInfo.hasInternet(ActivityMain.this) ? View.VISIBLE
: View.INVISIBLE);
// Display if frozen
holder.imgFrozen
.setVisibility(xAppInfo.isFrozen(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE);
// Display if settings
holder.imgSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
// Display restriction
holder.imgCbRestricted.setImageBitmap(getCheckBoxImage(rstate, methodExpert));
holder.imgCbRestricted.setVisibility(View.VISIBLE);
// Display enabled state
holder.tvName.setEnabled(enabled && can);
holder.imgCbRestricted.setEnabled(enabled && can);
holder.imgCbAsk.setEnabled(enabled && can);
// Display selection
if (mListAppSelected.contains(xAppInfo))
holder.row.setBackgroundColor(mHighlightColor);
else
holder.row.setBackgroundColor(Color.TRANSPARENT);
// Handle details click
holder.imgIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intentSettings = new Intent(ActivityMain.this, ActivityApp.class);
intentSettings.putExtra(ActivityApp.cUid, xAppInfo.getUid());
intentSettings.putExtra(ActivityApp.cRestrictionName, mRestrictionName);
ActivityMain.this.startActivity(intentSettings);
}
});
// Listen for restriction changes
holder.imgCbRestricted.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mRestrictionName == null && rstate.restricted != false) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this);
alertDialogBuilder.setTitle(R.string.menu_clear_all);
alertDialogBuilder.setMessage(R.string.msg_sure);
alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
alertDialogBuilder.setPositiveButton(getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteRestrictions();
}
});
alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
} else
toggleRestrictions();
}
});
// Listen for ask changes
if (gondemand && ondemand)
holder.imgCbAsk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
holder.imgCbAsk.setVisibility(View.GONE);
holder.pbRunning.setVisibility(View.VISIBLE);
new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... arg0) {
rstate.toggleAsked();
rstate = new RState(xAppInfo.getUid(), mRestrictionName, null, mVersion);
return null;
}
@Override
protected void onPostExecute(Object result) {
holder.imgCbAsk.setImageBitmap(getAskBoxImage(rstate, methodExpert));
holder.pbRunning.setVisibility(View.GONE);
holder.imgCbAsk.setVisibility(View.VISIBLE);
}
}.executeOnExecutor(mExecutor);
}
});
else
holder.imgCbAsk.setClickable(false);
}
}
private void deleteRestrictions() {
holder.imgCbRestricted.setVisibility(View.GONE);
holder.pbRunning.setVisibility(View.VISIBLE);
new AsyncTask<Object, Object, Object>() {
private List<Boolean> oldState;
@Override
protected Object doInBackground(Object... arg0) {
// Update restriction
oldState = PrivacyManager.getRestartStates(xAppInfo.getUid(), mRestrictionName);
PrivacyManager.deleteRestrictions(xAppInfo.getUid(), null, true);
PrivacyManager.setSetting(xAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
Boolean.toString(true));
return null;
}
@Override
protected void onPostExecute(Object result) {
// Update visible state
holder.vwState.setBackgroundColor(getResources().getColor(
getThemed(R.attr.color_state_attention)));
// Update stored state
rstate = new RState(xAppInfo.getUid(), mRestrictionName, null, mVersion);
holder.imgCbRestricted.setImageBitmap(getCheckBoxImage(rstate, methodExpert));
holder.imgCbAsk.setImageBitmap(getAskBoxImage(rstate, methodExpert));
// Notify restart
if (oldState.contains(true))
Toast.makeText(ActivityMain.this, getString(R.string.msg_restart), Toast.LENGTH_LONG)
.show();
// Display new state
showState();
holder.pbRunning.setVisibility(View.GONE);
holder.imgCbRestricted.setVisibility(View.VISIBLE);
}
}.executeOnExecutor(mExecutor);
}
private void toggleRestrictions() {
holder.imgCbRestricted.setVisibility(View.GONE);
holder.pbRunning.setVisibility(View.VISIBLE);
new AsyncTask<Object, Object, Object>() {
private List<Boolean> oldState;
private List<Boolean> newState;
@Override
protected Object doInBackground(Object... arg0) {
// Change restriction
oldState = PrivacyManager.getRestartStates(xAppInfo.getUid(), mRestrictionName);
rstate.toggleRestriction();
newState = PrivacyManager.getRestartStates(xAppInfo.getUid(), mRestrictionName);
return null;
}
@Override
protected void onPostExecute(Object result) {
// Update restriction display
rstate = new RState(xAppInfo.getUid(), mRestrictionName, null, mVersion);
holder.imgCbRestricted.setImageBitmap(getCheckBoxImage(rstate, methodExpert));
holder.imgCbAsk.setImageBitmap(getAskBoxImage(rstate, methodExpert));
// Notify restart
if (!newState.equals(oldState))
Toast.makeText(ActivityMain.this, getString(R.string.msg_restart), Toast.LENGTH_LONG)
.show();
// Display new state
showState();
holder.pbRunning.setVisibility(View.GONE);
holder.imgCbRestricted.setVisibility(View.VISIBLE);
}
}.executeOnExecutor(mExecutor);
}
private void showState() {
state = xAppInfo.getState(ActivityMain.this);
if (state == ApplicationInfoEx.STATE_ATTENTION)
holder.vwState.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_state_attention)));
else if (state == ApplicationInfoEx.STATE_SHARED)
holder.vwState.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_state_shared)));
else
holder.vwState
.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_state_restricted)));
}
}
@Override
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.mainentry, null);
holder = new ViewHolder(convertView, position);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
holder.position = position;
}
// Get info
final ApplicationInfoEx xAppInfo = getItem(holder.position);
// Set data
holder.row.setBackgroundColor(Color.TRANSPARENT);
holder.vwState.setBackgroundColor(Color.TRANSPARENT);
holder.llAppType.setBackgroundColor(Color.TRANSPARENT);
holder.imgIcon.setVisibility(View.INVISIBLE);
holder.tvName.setText(xAppInfo.toString());
holder.tvName.setTypeface(null, Typeface.NORMAL);
holder.imgUsed.setVisibility(View.INVISIBLE);
holder.imgGranted.setVisibility(View.INVISIBLE);
holder.imgInternet.setVisibility(View.INVISIBLE);
holder.imgFrozen.setVisibility(View.INVISIBLE);
holder.imgSettings.setVisibility(View.GONE);
holder.imgCbRestricted.setVisibility(View.INVISIBLE);
holder.imgCbAsk.setVisibility(View.INVISIBLE);
holder.tvName.setEnabled(false);
holder.imgCbRestricted.setEnabled(false);
holder.imgIcon.setClickable(false);
holder.imgCbRestricted.setClickable(false);
holder.imgCbAsk.setClickable(false);
// Listen for multiple select
holder.llName.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (mListAppSelected.contains(xAppInfo)) {
mSelecting = false;
mListAppSelected.clear();
mAppAdapter.notifyDataSetChanged();
} else {
mSelecting = true;
mListAppSelected.add(xAppInfo);
holder.row.setBackgroundColor(mHighlightColor);
}
showStats();
return true;
}
});
// Listen for application selection
holder.llName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
if (mSelecting) {
if (mListAppSelected.contains(xAppInfo)) {
mListAppSelected.remove(xAppInfo);
holder.row.setBackgroundColor(Color.TRANSPARENT);
if (mListAppSelected.size() == 0)
mSelecting = false;
} else {
mListAppSelected.add(xAppInfo);
holder.row.setBackgroundColor(mHighlightColor);
}
showStats();
} else {
Intent intentSettings = new Intent(ActivityMain.this, ActivityApp.class);
intentSettings.putExtra(ActivityApp.cUid, xAppInfo.getUid());
intentSettings.putExtra(ActivityApp.cRestrictionName, mRestrictionName);
ActivityMain.this.startActivity(intentSettings);
}
}
});
// Async update
new HolderTask(position, holder, xAppInfo).executeOnExecutor(mExecutor, (Object) null);
return convertView;
}
}
// Helper methods
private void setProgress(String text, int progress, int max) {
// Set up the progress bar
if (mProgressWidth == 0) {
final View vProgressEmpty = (View) findViewById(R.id.vProgressEmpty);
mProgressWidth = vProgressEmpty.getMeasuredWidth();
}
// Display stuff
TextView tvState = (TextView) findViewById(R.id.tvState);
if (text != null)
tvState.setText(text);
if (max == 0)
max = 1;
mProgress = (int) ((float) mProgressWidth) * progress / max;
View vProgressFull = (View) findViewById(R.id.vProgressFull);
vProgressFull.getLayoutParams().width = mProgress;
}
private int getSelectedCategory(final int userId) {
int pos = 0;
String restrictionName = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSelectedCategory, null);
if (restrictionName != null)
for (String restriction : PrivacyManager.getRestrictions(this).values()) {
pos++;
if (restrictionName.equals(restriction))
break;
}
return pos;
}
private void checkLicense() {
if (!Util.isProEnabled() && Util.hasProLicense(this) == null)
if (Util.isProEnablerInstalled(this))
try {
int uid = getPackageManager().getPackageInfo("biz.bokhorst.xprivacy.pro", 0).applicationInfo.uid;
PrivacyManager.deleteRestrictions(uid, null, true);
Util.log(null, Log.INFO, "Licensing: check");
startActivityForResult(new Intent("biz.bokhorst.xprivacy.pro.CHECK"), ACTIVITY_LICENSE);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
}
| 83,499 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
UpdateService.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/UpdateService.java | package biz.bokhorst.xprivacy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class UpdateService extends Service {
public static final String cAction = "Action";
public static final int cActionBoot = 1;
public static final int cActionUpdated = 2;
public static final String cFlush = "biz.bokhorst.xprivacy.action.FLUSH";
public static final String cUpdate = "biz.bokhorst.xprivacy.action.UPDATE";
private static Thread mWorkerThread;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Check if work
if (intent == null) {
stopSelf();
return 0;
}
// Flush
if (cFlush.equals(intent.getAction())) {
try {
PrivacyService.getClient().flush();
XApplication.manage(this, 0, XApplication.cActionFlush);
} catch (Throwable ex) {
Util.bug(null, ex);
}
stopSelf();
return 0;
}
// Update
if (cUpdate.equals(intent.getAction())) {
if (Util.hasProLicense(this) != null) {
int userId = Util.getUserId(Process.myUid());
boolean updates = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingUpdates, false);
if (updates)
new ActivityShare.UpdateTask(this).execute();
}
stopSelf();
return 0;
}
// Check action
Bundle extras = intent.getExtras();
if (extras.containsKey(cAction)) {
final int action = extras.getInt(cAction);
Util.log(null, Log.WARN, "Service received action=" + action + " flags=" + flags);
// Check service
if (PrivacyService.getClient() == null) {
Util.log(null, Log.ERROR, "Service not available");
stopSelf();
return 0;
}
// Start foreground service
NotificationCompat.Builder builder = new NotificationCompat.Builder(UpdateService.this);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle(getString(R.string.app_name));
builder.setContentText(getString(R.string.msg_service));
builder.setWhen(System.currentTimeMillis());
builder.setAutoCancel(false);
builder.setOngoing(true);
Notification notification = builder.build();
startForeground(Util.NOTIFY_SERVICE, notification);
// Start worker
mWorkerThread = new Thread(new Runnable() {
@Override
public void run() {
try {
// Check action
if (action == cActionBoot) {
// Boot received
migrate(UpdateService.this);
upgrade(UpdateService.this);
randomize(UpdateService.this);
} else if (action == cActionUpdated) {
// Self updated
upgrade(UpdateService.this);
} else
Util.log(null, Log.ERROR, "Unknown action=" + action);
// Done
stopForeground(true);
stopSelf();
} catch (Throwable ex) {
Util.bug(null, ex);
// Leave service running
}
}
});
mWorkerThread.start();
} else
Util.log(null, Log.ERROR, "Action missing");
return START_STICKY;
}
private static void migrate(Context context) throws IOException, RemoteException {
int first = 0;
String format = context.getString(R.string.msg_migrating);
List<ApplicationInfo> listApp = context.getPackageManager().getInstalledApplications(0);
// Start migrate
PrivacyProvider.migrateLegacy(context);
// Migrate global settings
PrivacyManager.setSettingList(PrivacyProvider.migrateSettings(context, 0));
PrivacyProvider.finishMigrateSettings(0);
// Migrate application settings/restrictions
for (int i = 1; i <= listApp.size(); i++) {
int uid = listApp.get(i - 1).uid;
// Settings
List<PSetting> listSetting = PrivacyProvider.migrateSettings(context, uid);
PrivacyManager.setSettingList(listSetting);
PrivacyProvider.finishMigrateSettings(uid);
// Restrictions
List<PRestriction> listRestriction = PrivacyProvider.migrateRestrictions(context, uid);
PrivacyManager.setRestrictionList(listRestriction);
PrivacyProvider.finishMigrateRestrictions(uid);
if (first == 0)
if (listSetting.size() > 0 || listRestriction.size() > 0)
first = i;
if (first > 0 && first < listApp.size())
notifyProgress(context, Util.NOTIFY_MIGRATE, format, 100 * (i - first) / (listApp.size() - first));
}
if (first == 0)
Util.log(null, Log.WARN, "Nothing to migrate");
// Complete migration
int userId = Util.getUserId(Process.myUid());
PrivacyService.getClient().setSetting(
new PSetting(userId, "", PrivacyManager.cSettingMigrated, Boolean.toString(true)));
}
private static void upgrade(Context context) throws NameNotFoundException {
// Get previous version number
int userId = Util.getUserId(Process.myUid());
Version currentVersion = new Version(Util.getSelfVersionName(context));
Version storedVersion = new Version(PrivacyManager.getSetting(userId, PrivacyManager.cSettingVersion, "0.0"));
boolean dangerous = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingDangerous, false);
// Check if upgrade needed
if (storedVersion.compareTo(new Version("0.0")) != 0 && currentVersion.compareTo(storedVersion) > 0) {
Util.log(null, Log.WARN, "Starting upgrade from version " + storedVersion + " to version " + currentVersion
+ " dangerous=" + dangerous);
// Upgrade packages
int first = 0;
String format = context.getString(R.string.msg_upgrading);
List<ApplicationInfo> listApp = context.getPackageManager().getInstalledApplications(0);
for (int i = 1; i <= listApp.size(); i++) {
int uid = listApp.get(i - 1).uid;
List<PRestriction> listRestriction = getUpgradeWork(storedVersion, uid, dangerous);
PrivacyManager.setRestrictionList(listRestriction);
// Reset on demand for system applications
if (new ApplicationInfoEx(context, listApp.get(i - 1).uid).isSystem())
if (storedVersion.compareTo(new Version("2.0.38")) < 0)
if (PrivacyManager.getSettingBool(listApp.get(i - 1).uid, PrivacyManager.cSettingOnDemand,
false)) {
Util.log(null, Log.WARN, "Disabling on demand for uid=" + listApp.get(i - 1).uid);
PrivacyManager.setSetting(listApp.get(i - 1).uid, PrivacyManager.cSettingOnDemand, null);
}
if (first == 0)
if (listRestriction.size() > 0)
first = i;
if (first > 0 && first < listApp.size())
notifyProgress(context, Util.NOTIFY_UPGRADE, format, 100 * (i - first) / (listApp.size() - first));
}
if (first == 0)
Util.log(null, Log.WARN, "Nothing to upgrade from version " + storedVersion + " to " + currentVersion);
// Remove legacy setting
if (dangerous)
PrivacyManager.setSetting(userId, PrivacyManager.cSettingDangerous, null);
// Resolve quirk
if (storedVersion.compareTo(new Version("2.99.28")) < 0)
if (!PrivacyManager.getSettingBool(0, PrivacyManager.cSettingNoResolve, false)) {
Util.log(null, Log.WARN, "Enabling quirk resolve");
PrivacyManager.setSetting(0, PrivacyManager.cSettingResolve, Boolean.toString(true));
}
// Wipe template
if (storedVersion.compareTo(new Version("2.0.34")) < 0)
for (PSetting setting : PrivacyManager.getSettingList(0, null))
if (Meta.cTypeTemplate.equals(setting.type)) {
Util.log(null, Log.WARN, "Deleting " + setting);
PrivacyManager.setSetting(setting.uid, setting.type, setting.name, null);
}
} else
Util.log(null, Log.WARN, "No upgrade from version " + storedVersion + " to " + currentVersion);
// Set new version number
if (currentVersion.compareTo(storedVersion) > 0)
PrivacyManager.setSetting(userId, PrivacyManager.cSettingVersion, currentVersion.toString());
// Cleanup
PrivacyManager.removeLegacySalt(userId);
}
private static void randomize(Context context) {
int first = 0;
String format = context.getString(R.string.msg_randomizing);
List<ApplicationInfo> listApp = context.getPackageManager().getInstalledApplications(0);
// Randomize global
int userId = Util.getUserId(Process.myUid());
PrivacyManager.setSettingList(getRandomizeWork(context, userId));
// Randomize applications
for (int i = 1; i <= listApp.size(); i++) {
int uid = listApp.get(i - 1).uid;
List<PSetting> listSetting = getRandomizeWork(context, uid);
PrivacyManager.setSettingList(listSetting);
if (first == 0)
if (listSetting.size() > 0)
first = i;
if (first > 0 && first < listApp.size())
notifyProgress(context, Util.NOTIFY_RANDOMIZE, format, 100 * (i - first) / (listApp.size() - first));
}
if (first == 0)
Util.log(null, Log.WARN, "Nothing to randomize");
}
private static List<PSetting> getRandomizeWork(Context context, int uid) {
List<PSetting> listWork = new ArrayList<PSetting>();
if (PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingRandom, false)) {
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingLatitude))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingLatitude, PrivacyManager.getRandomProp("LAT")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingLongitude))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingLongitude, PrivacyManager
.getRandomProp("LON")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingAltitude))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingAltitude, PrivacyManager.getRandomProp("ALT")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingSerial))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingSerial, PrivacyManager
.getRandomProp("SERIAL")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingMac))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingMac, PrivacyManager.getRandomProp("MAC")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingPhone))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingPhone, PrivacyManager.getRandomProp("PHONE")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingImei))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingImei, PrivacyManager.getRandomProp("IMEI")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingId))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingId, PrivacyManager
.getRandomProp("ANDROID_ID")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingGsfId))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingGsfId, PrivacyManager.getRandomProp("GSF_ID")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingAdId))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingAdId, PrivacyManager
.getRandomProp("AdvertisingId")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingCountry))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingCountry, PrivacyManager
.getRandomProp("ISO3166")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingSubscriber))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingSubscriber, PrivacyManager
.getRandomProp("SubscriberId")));
if (!hasRandomOnAccess(uid, PrivacyManager.cSettingSSID))
listWork.add(new PSetting(uid, "", PrivacyManager.cSettingSSID, PrivacyManager.getRandomProp("SSID")));
}
return listWork;
}
private static boolean hasRandomOnAccess(int uid, String setting) {
return PrivacyManager.cValueRandom.equals(PrivacyManager.getSetting(uid, setting, null));
}
private static List<PRestriction> getUpgradeWork(Version sVersion, int uid, boolean dangerous) {
List<PRestriction> listWork = new ArrayList<PRestriction>();
for (String restrictionName : PrivacyManager.getRestrictions()) {
boolean restricted = PrivacyManager.getRestrictionEx(uid, restrictionName, null).restricted;
for (Hook hook : PrivacyManager.getHooks(restrictionName, null)) {
// Disable new dangerous restrictions
if (hook.getFrom() != null) {
if (sVersion.compareTo(hook.getFrom()) < 0) {
if (hook.isDangerous()) {
Util.log(null, Log.WARN, "Upgrading dangerous " + hook + " from=" + hook.getFrom()
+ " uid=" + uid);
PRestriction restriction = new PRestriction(uid, hook.getRestrictionName(), hook.getName(),
false, true);
listWork.add(restriction);
}
// Restrict replaced methods
if (hook.getReplacedMethod() != null) {
if ("false".equals(hook.getReplacedMethod())) {
listWork.add(new PRestriction(uid, hook.getRestrictionName(), hook.getName(), false,
false));
Util.log(null, Log.WARN, "Resetting restriction " + hook + " uid=" + uid);
} else {
PRestriction restriction = PrivacyManager.getRestrictionEx(uid,
hook.getReplacedRestriction(), hook.getReplacedMethod());
listWork.add(new PRestriction(uid, hook.getRestrictionName(), hook.getName(),
restriction.restricted, restriction.asked));
Util.log(null, Log.WARN,
"Replacing " + hook.getReplacedRestriction() + "/" + hook.getReplacedMethod()
+ " by " + hook + " from=" + hook.getFrom() + " uid=" + uid);
}
}
}
}
// Restrict dangerous
if (dangerous && restricted && hook.isDangerous()) {
PRestriction restriction = new PRestriction(uid, hook.getRestrictionName(), hook.getName(), true,
hook.whitelist() == null);
if (PrivacyManager.isRestrictionSet(restriction))
Util.log(null, Log.WARN, "Restrict dangerous set restriction=" + restriction);
else {
Util.log(null, Log.WARN, "Restrict dangerous setting restriction=" + restriction);
listWork.add(restriction);
}
}
}
}
return listWork;
}
private static void notifyProgress(Context context, int id, String format, int percentage) {
String message = String.format(format, String.format("%d %%", percentage));
Util.log(null, Log.WARN, message);
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle(context.getString(R.string.app_name));
builder.setContentText(message);
builder.setWhen(System.currentTimeMillis());
builder.setAutoCancel(percentage == 100);
builder.setOngoing(percentage < 100);
Notification notification = builder.build();
notificationManager.notify(id, notification);
}
}
| 14,742 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XGoogleMapV2.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XGoogleMapV2.java | package biz.bokhorst.xprivacy;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import android.location.Location;
import android.os.Binder;
public class XGoogleMapV2 extends XHook {
private Methods mMethod;
private XGoogleMapV2(Methods method, String restrictionName) {
super(restrictionName, method.name(), String.format("MapV2.%s", method.name()));
mMethod = method;
}
public String getClassName() {
if (mMethod == Methods.getPosition)
return "com.google.android.gms.maps.model.Marker";
else
return "com.google.android.gms.maps.GoogleMap";
}
// @formatter:off
// final Location getMyLocation()
// final void setLocationSource(LocationSource source)
// final void setOnMapClickListener(GoogleMap.OnMapClickListener listener)
// final void setOnMapLongClickListener(GoogleMap.OnMapLongClickListener listener)
// final void setOnMyLocationChangeListener(GoogleMap.OnMyLocationChangeListener listener)
// http://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html
// public LatLng getPosition ()
// http://developer.android.com/reference/com/google/android/gms/maps/model/Marker.html
// http://developer.android.com/reference/com/google/android/gms/maps/model/LatLng.html
// @formatter:on
private enum Methods {
getMyLocation, getPosition, setLocationSource, setOnMapClickListener, setOnMapLongClickListener, setOnMyLocationChangeListener
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
for (Methods method : Methods.values())
listHook.add(new XGoogleMapV2(method, PrivacyManager.cLocation));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case getMyLocation:
// Do nothing
break;
case getPosition:
// Do nothing
break;
case setLocationSource:
case setOnMapClickListener:
case setOnMapLongClickListener:
case setOnMyLocationChangeListener:
if (isRestricted(param))
param.setResult(null);
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getMyLocation:
if (param.getResult() != null)
if (isRestricted(param)) {
Location originalLocation = (Location) param.getResult();
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), originalLocation);
param.setResult(fakeLocation);
}
break;
case getPosition:
if (param.getResult() != null)
if (isRestricted(param)) {
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), null);
Field fLat = param.getResult().getClass().getField("latitude");
Field fLon = param.getResult().getClass().getField("longitude");
fLat.setAccessible(true);
fLon.setAccessible(true);
fLat.set(param.getResult(), fakeLocation.getLatitude());
fLon.set(param.getResult(), fakeLocation.getLongitude());
}
break;
case setLocationSource:
case setOnMapClickListener:
case setOnMapLongClickListener:
case setOnMyLocationChangeListener:
// Do nothing
break;
}
}
}
| 3,138 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
WhitelistAdapter.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/WhitelistAdapter.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.ImageView;
@SuppressLint("DefaultLocale")
public class WhitelistAdapter extends ArrayAdapter<String> {
private String mSelectedType;
private int mUid;
private Map<String, TreeMap<String, Boolean>> mMapWhitelists;
private LayoutInflater mInflater;
public WhitelistAdapter(Context context, int resource, int uid, Map<String, TreeMap<String, Boolean>> mapWhitelists) {
super(context, resource, new ArrayList<String>());
mUid = uid;
mMapWhitelists = mapWhitelists;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void setType(String selectedType) {
mSelectedType = selectedType;
this.clear();
if (mMapWhitelists.containsKey(selectedType))
this.addAll(mMapWhitelists.get(selectedType).keySet());
}
private class ViewHolder {
private View row;
public CheckedTextView ctvName;
public ImageView imgDelete;
public ViewHolder(View theRow, int thePosition) {
row = theRow;
ctvName = (CheckedTextView) row.findViewById(R.id.cbName);
imgDelete = (ImageView) row.findViewById(R.id.imgDelete);
}
}
@Override
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.whitelistentry, null);
holder = new ViewHolder(convertView, position);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
// Set data
final String name = this.getItem(position);
holder.ctvName.setText(name);
holder.ctvName.setChecked(mMapWhitelists.get(mSelectedType).get(name));
final boolean wnomod = PrivacyManager.getSettingBool(mUid, PrivacyManager.cSettingWhitelistNoModify, false);
holder.ctvName.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Toggle white/black list entry
holder.ctvName.toggle();
boolean isChecked = holder.ctvName.isChecked();
mMapWhitelists.get(mSelectedType).put(name, isChecked);
PrivacyManager.setSetting(mUid, mSelectedType, name, Boolean.toString(isChecked));
if (!wnomod)
PrivacyManager.updateState(mUid);
}
});
holder.imgDelete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// Delete white/black list entry
WhitelistAdapter.this.remove(name);
mMapWhitelists.get(mSelectedType).remove(name);
PrivacyManager.setSetting(mUid, mSelectedType, name, null);
if (!wnomod)
PrivacyManager.updateState(mUid);
}
});
return convertView;
}
}
| 2,995 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XGoogleApiClient.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XGoogleApiClient.java | package biz.bokhorst.xprivacy;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.util.Log;
public class XGoogleApiClient extends XHook {
private Methods mMethod;
private XGoogleApiClient(Methods method, String restrictionName) {
super(restrictionName, method.name(), "GMS5." + method.name());
mMethod = method;
}
public String getClassName() {
return "com.google.android.gms.common.api.GoogleApiClient$Builder";
}
// @formatter:off
// GoogleApiClient.Builder addConnectionCallbacks(GoogleApiClient.ConnectionCallbacks listener)
// https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.Builder.html
// https://developer.android.com/reference/com/google/android/gms/common/api/PendingResult.html
// https://developer.android.com/reference/com/google/android/gms/common/api/Status.html
// https://developer.android.com/reference/com/google/android/gms/common/api/ResultCallback.html
// @formatter:on
private enum Methods {
addConnectionCallbacks
};
public static List<XHook> getInstances() {
Util.log(null, Log.INFO, "Loaded GoogleApiClient$Builder uid=" + Binder.getCallingUid());
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XGoogleApiClient(Methods.addConnectionCallbacks, null));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case addConnectionCallbacks:
if (param.args.length > 0 && param.args[0] != null) {
Class<?> clazz = param.args[0].getClass();
if (PrivacyManager.getTransient(clazz.getName(), null) == null) {
PrivacyManager.setTransient(clazz.getName(), Boolean.toString(true));
XPrivacy.hookAll(XConnectionCallbacks.getInstances(param.args[0]), clazz.getClassLoader(),
getSecret(), true);
}
}
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
public static Object getPendingResult(ClassLoader loader) throws Throwable {
InvocationHandler ih = new PendingResultHandler(loader);
Class<?> pr = Class.forName("com.google.android.gms.common.api.PendingResult", false, loader);
return Proxy.newProxyInstance(loader, new Class<?>[] { pr }, ih);
}
private static class PendingResultHandler implements InvocationHandler {
private ClassLoader mLoader;
private boolean mCancelled = false;
public PendingResultHandler(ClassLoader loader) {
mLoader = loader;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("await".equals(method.getName())) {
// abstract R await()
// abstract R await(long time, TimeUnit units)
return getStatus(mLoader);
} else if ("cancel".equals(method.getName())) {
// abstract void cancel()
mCancelled = true;
return null;
} else if ("isCanceled".equals(method.getName())) {
// abstract boolean isCanceled()
return mCancelled;
} else if ("setResultCallback".equals(method.getName())) {
// abstract void setResultCallback(ResultCallback<R> callback,
// long time, TimeUnit units)
// abstract void setResultCallback(ResultCallback<R> callback)
Object callback = args[0];
if (callback != null) {
// abstract void onResult(R result)
Class<?> cStatus = Class.forName("com.google.android.gms.common.api.Status", false, mLoader);
callback.getClass().getMethod("onResult", cStatus).invoke(callback, getStatus(mLoader));
}
return null;
}
return null;
}
}
private static Object getStatus(ClassLoader loader) throws Throwable {
// public com.google.android.gms.common.api.Status(int)
Class<?> cStatus = Class.forName("com.google.android.gms.common.api.Status", false, loader);
Constructor<?> iStatus = cStatus.getConstructor(int.class);
Object status = iStatus.newInstance(0); // SUCCESS
return status;
}
}
| 4,037 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XLinkProperties.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XLinkProperties.java | package biz.bokhorst.xprivacy;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import android.net.LinkAddress;
import android.net.LinkProperties;
public class XLinkProperties extends XHook {
private Methods mMethod;
private XLinkProperties(Methods method, String restrictionName, String specifier) {
super(restrictionName, method.name(), "LinkProperties." + method.name());
mMethod = method;
}
public String getClassName() {
return "android.net.LinkProperties";
}
// public List<InetAddress> getAddresses()
// public List<InetAddress> getAllAddresses()
// public List<LinkAddress> getAllLinkAddresses()
// public List<LinkAddress> getLinkAddresses()
// public @NonNull List<LinkProperties> getStackedLinks()
// http://developer.android.com/reference/android/net/LinkProperties.html
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/net/LinkProperties.java
private enum Methods {
getAddresses, getAllAddresses, getAllLinkAddresses, getLinkAddresses, getStackedLinks
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
for (Methods addr : Methods.values())
listHook.add(new XLinkProperties(addr, PrivacyManager.cInternet, null));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getAddresses:
case getAllAddresses:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<InetAddress>());
break;
case getAllLinkAddresses:
case getLinkAddresses:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<LinkAddress>());
break;
case getStackedLinks:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<LinkProperties>());
break;
}
}
} | 2,001 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XProcessBuilder.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XProcessBuilder.java | package biz.bokhorst.xprivacy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.text.TextUtils;
import android.util.Log;
public class XProcessBuilder extends XHook {
private String mCommand;
private XProcessBuilder(String methodName, String restrictionName, String command) {
super(restrictionName, methodName, command);
mCommand = command;
}
public String getClassName() {
return "java.lang.ProcessBuilder";
}
// public Process start()
// libcore/luni/src/main/java/java/lang/ProcessBuilder.java
// http://developer.android.com/reference/java/lang/ProcessBuilder.html
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XProcessBuilder("start", PrivacyManager.cShell, "sh"));
listHook.add(new XProcessBuilder("start", PrivacyManager.cShell, "su"));
listHook.add(new XProcessBuilder("start", PrivacyManager.cShell, null));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
String methodName = param.method.getName();
if (methodName.equals("start")) {
// Get commands
ProcessBuilder builder = (ProcessBuilder) param.thisObject;
List<String> listProg = (builder == null ? null : builder.command());
// Check commands
if (listProg != null) {
String command = TextUtils.join(" ", listProg);
if (XRuntime.matches(command, mCommand) && isRestrictedExtra(param, command))
param.setThrowable(new IOException("XPrivacy"));
}
} else
Util.log(this, Log.WARN, "Unknown method=" + methodName);
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
| 1,684 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XWebSettings.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XWebSettings.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.util.Log;
public class XWebSettings extends XHook {
private Methods mMethod;
private String mClassName;
private XWebSettings(Methods method, String restrictionName, String className) {
super(restrictionName, method.name(), null);
mMethod = method;
mClassName = className;
}
public String getClassName() {
return mClassName;
}
// public static String getDefaultUserAgent(Context context) [17]
// public synchronized int getUserAgent()
// public synchronized String getUserAgentString()
// public synchronized void setUserAgent(int ua)
// public synchronized void setUserAgentString (String ua)
// http://developer.android.com/reference/android/webkit/WebSettings.html
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/android/webkit/WebSettings.java
private enum Methods {
getDefaultUserAgent, getUserAgent, getUserAgentString, setUserAgent, setUserAgentString
};
public static List<XHook> getInstances(Object instance) {
String className = instance.getClass().getName();
Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid());
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XWebSettings(Methods.getDefaultUserAgent, PrivacyManager.cView, className));
listHook.add(new XWebSettings(Methods.getUserAgent, PrivacyManager.cView, className));
listHook.add(new XWebSettings(Methods.getUserAgentString, PrivacyManager.cView, className));
listHook.add(new XWebSettings(Methods.setUserAgent, PrivacyManager.cView, className));
listHook.add(new XWebSettings(Methods.setUserAgentString, PrivacyManager.cView, className));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case getDefaultUserAgent:
int uid = Binder.getCallingUid();
if (getRestricted(uid)) {
String ua = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
param.setResult(ua);
}
break;
case getUserAgent:
if (isRestricted(param))
param.setResult(-1); // User defined
break;
case getUserAgentString:
if (isRestrictedExtra(param, (String) param.getResult())) {
String ua = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
param.setResult(ua);
}
break;
case setUserAgent:
if (param.args.length > 0)
if (isRestricted(param))
param.args[0] = -1; // User defined
break;
case setUserAgentString:
if (param.args.length > 0)
if (isRestricted(param)) {
String ua = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
param.args[0] = ua;
}
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
| 2,878 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XPackageManager.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XPackageManager.java | package biz.bokhorst.xprivacy;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.util.Log;
import android.content.ComponentName;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
public class XPackageManager extends XHook {
private Methods mMethod;
private String mClassName;
private static final String cClassName = "android.app.ApplicationPackageManager";
private XPackageManager(Methods method, String restrictionName) {
super(restrictionName, method.name().replace("Srv_", ""), method.name());
mMethod = method;
mClassName = "com.android.server.pm.PackageManagerService";
}
private XPackageManager(Methods method, String restrictionName, String className) {
super(restrictionName, method.name(), null);
mMethod = method;
mClassName = className;
}
public String getClassName() {
return mClassName;
}
// @formatter:off
// public List<ApplicationInfo> getInstalledApplications(int flags)
// public List<PackageInfo> getInstalledPackages(int flags)
// public String[] getPackagesForUid(int uid)
// public List<PackageInfo> getPackagesHoldingPermissions(String[] permissions, int flags)
// public List<PackageInfo> getPreferredPackages(int flags)
// public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags)
// public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags)
// public List<ResolveInfo> queryIntentActivities(Intent intent, int flags)
// public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, Intent[] specifics, Intent intent, int flags)
// public List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags)
// public List<ResolveInfo> queryIntentServices(Intent intent, int flags)
// frameworks/base/core/java/android/app/ApplicationPackageManager.java
// http://developer.android.com/reference/android/content/pm/PackageManager.html
// public int checkPermission(String permName, String pkgName)
// public int checkUidPermission(String permName, int uid)
// public java.lang.String[] getPackagesForUid(int uid)
// public java.util.List<android.content.pm.ResolveInfo> queryIntentActivities(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId)
// public java.util.List<android.content.pm.ResolveInfo> queryIntentActivityOptions(android.content.ComponentName caller, android.content.Intent[] specifics, java.lang.String[] specificTypes, android.content.Intent intent, java.lang.String resolvedType, int flags, int userId)
// public java.util.List<android.content.pm.ResolveInfo> queryIntentReceivers(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId)
// public java.util.List<android.content.pm.ResolveInfo> queryIntentServices(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId)
// public java.util.List<android.content.pm.ResolveInfo> queryIntentContentProviders(android.content.Intent intent, java.lang.String resolvedType, int flags, int userId)
// public java.util.List<android.content.pm.ApplicationInfo> getPersistentApplications(int flags)
// public java.util.List<android.content.pm.ProviderInfo> queryContentProviders(java.lang.String processName, int uid, int flags)
// public java.util.List<android.content.pm.PackageInfo> getPreferredPackages(int flags)
// public android.content.pm.ParceledListSlice getInstalledPackages(int flags, int userId)
// public android.content.pm.ParceledListSlice getPackagesHoldingPermissions(java.lang.String[] permissions, int flags, int userId)
// public android.content.pm.ParceledListSlice getInstalledApplications(int flags, int userId)
// public PackageInfo getPackageInfo(String packageName, int flags, int userId)
// public ApplicationInfo getApplicationInfo(String packageName, int flags, int userId)
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/com/android/server/pm/PackageManagerService.java
// @formatter:on
// @formatter:off
private enum Methods {
getInstalledApplications, getInstalledPackages,
getPackagesForUid,
getPackagesHoldingPermissions,
getPreferredActivities, getPreferredPackages,
queryBroadcastReceivers, queryContentProviders,
queryIntentActivities, queryIntentActivityOptions,
queryIntentContentProviders, queryIntentServices,
checkPermission, checkUidPermission,
Srv_getPackageInfo, Srv_getApplicationInfo,
Srv_getInstalledApplications, Srv_getInstalledPackages,
Srv_getPackagesForUid,
Srv_getPackagesHoldingPermissions,
Srv_getPersistentApplications,
Srv_getPreferredPackages,
Srv_queryContentProviders,
Srv_queryIntentActivities, Srv_queryIntentActivityOptions,
Srv_queryIntentContentProviders,
Srv_queryIntentReceivers,
Srv_queryIntentServices
};
// @formatter:on
public static List<XHook> getInstances(String className, boolean server) {
List<XHook> listHook = new ArrayList<XHook>();
if (!cClassName.equals(className)) {
if (className == null)
className = cClassName;
if (server) {
listHook.add(new XPackageManager(Methods.Srv_getPackageInfo, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getApplicationInfo, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getInstalledApplications, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getInstalledPackages, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getPackagesForUid, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getPackagesHoldingPermissions, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getPersistentApplications, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_getPreferredPackages, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryContentProviders, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryIntentActivities, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryIntentActivityOptions, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryIntentContentProviders, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryIntentReceivers, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.Srv_queryIntentServices, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.checkPermission, PrivacyManager.cSystem));
listHook.add(new XPackageManager(Methods.checkUidPermission, PrivacyManager.cSystem));
} else {
listHook.add(new XPackageManager(Methods.getInstalledApplications, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.getInstalledPackages, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.getPackagesForUid, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.getPackagesHoldingPermissions, PrivacyManager.cSystem,
className));
listHook.add(new XPackageManager(Methods.getPreferredActivities, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.getPreferredPackages, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryBroadcastReceivers, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryContentProviders, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryIntentActivities, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryIntentActivityOptions, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryIntentContentProviders, PrivacyManager.cSystem, className));
listHook.add(new XPackageManager(Methods.queryIntentServices, PrivacyManager.cSystem, className));
}
}
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
if (mMethod == Methods.getPreferredActivities)
if (param.args.length > 1)
if (isRestricted(param)) {
param.args[0] = new ArrayList<IntentFilter>();
param.args[1] = new ArrayList<ComponentName>();
param.setResult(0);
}
}
@Override
@SuppressWarnings("unchecked")
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case Srv_getPackageInfo:
case Srv_getApplicationInfo:
if (param.args.length > 0 && param.args[0] instanceof String && param.getResult() != null) {
// Allow own package name
int uid = -1;
if (mMethod == Methods.Srv_getPackageInfo) {
PackageInfo pInfo = (PackageInfo) param.getResult();
if (pInfo.applicationInfo != null)
uid = pInfo.applicationInfo.uid;
} else if (mMethod == Methods.Srv_getApplicationInfo) {
ApplicationInfo aInfo = (ApplicationInfo) param.getResult();
uid = aInfo.uid;
}
if (uid == Binder.getCallingUid())
return;
// Prevent recursion
String packageName = (String) param.args[0];
if (!XPackageManager.class.getPackage().getName().equals(packageName))
if (isRestrictedExtra(param, packageName))
if (!isPackageAllowed(uid, packageName))
param.setResult(null);
}
break;
case Srv_getInstalledApplications:
if (param.getResult() != null)
if (isRestricted(param)) {
Method mGetList = param.getResult().getClass().getDeclaredMethod("getList");
List<ApplicationInfo> listAppInfo = (List<ApplicationInfo>) mGetList.invoke(param.getResult());
Constructor<?> constructor = param.getResult().getClass().getConstructor(List.class);
param.setResult(constructor.newInstance(filterApplicationInfo(listAppInfo)));
}
break;
case Srv_getInstalledPackages:
case Srv_getPackagesHoldingPermissions:
if (param.getResult() != null)
if (isRestricted(param)) {
Method mGetList = param.getResult().getClass().getDeclaredMethod("getList");
List<PackageInfo> listPkgInfo = (List<PackageInfo>) mGetList.invoke(param.getResult());
Constructor<?> constructor = param.getResult().getClass().getConstructor(List.class);
param.setResult(constructor.newInstance(filterPackageInfo(listPkgInfo)));
}
break;
case getPackagesForUid:
case Srv_getPackagesForUid:
if (param.args.length > 0 && param.args[0] instanceof Integer && param.getResult() != null) {
int uid = (Integer) param.args[0];
if (uid != Binder.getCallingUid())
if (isRestrictedExtra(param, Integer.toString(uid))) {
List<String> lstResult = new ArrayList<String>();
if (param.getResult() instanceof String[])
for (String packageName : (String[]) param.getResult())
if (isPackageAllowed(Binder.getCallingUid(), packageName))
lstResult.add(packageName);
if (lstResult.size() == 0)
param.setResult(null);
else
param.setResult(lstResult.toArray(new String[0]));
}
}
break;
case Srv_getPersistentApplications:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterApplicationInfo((List<ApplicationInfo>) param.getResult()));
break;
case Srv_getPreferredPackages:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterPackageInfo((List<PackageInfo>) param.getResult()));
break;
case Srv_queryIntentActivities:
case Srv_queryIntentActivityOptions:
case Srv_queryIntentContentProviders:
case Srv_queryIntentReceivers:
case Srv_queryIntentServices:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterResolveInfo((List<ResolveInfo>) param.getResult()));
break;
case getInstalledApplications:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterApplicationInfo((List<ApplicationInfo>) param.getResult()));
break;
case getPreferredActivities:
break;
case getInstalledPackages:
case getPackagesHoldingPermissions:
case getPreferredPackages:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterPackageInfo((List<PackageInfo>) param.getResult()));
break;
case queryBroadcastReceivers:
case queryIntentActivities:
case queryIntentActivityOptions:
case queryIntentContentProviders:
case queryIntentServices:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(filterResolveInfo((List<ResolveInfo>) param.getResult()));
break;
case queryContentProviders:
case Srv_queryContentProviders:
if (param.args.length > 1 && param.args[1] instanceof Integer && param.getResult() != null) {
int uid = (Integer) param.args[1];
if (uid != Binder.getCallingUid()) {
String processName = (String) param.args[0];
if (isRestrictedExtra(param, processName))
param.setResult(filterProviderInfo((List<ProviderInfo>) param.getResult()));
}
}
break;
case checkPermission:
if (param.args.length > 1 && param.args[0] instanceof String && param.args[1] instanceof String) {
String permName = (String) param.args[0];
String pkgName = (String) param.args[1];
int resultOfCheck = (Integer) param.getResult();
if (resultOfCheck != PackageManager.PERMISSION_GRANTED)
return;
// Get uid
int uid;
Class<?> clazz = param.thisObject.getClass();
try {
// public int getPackageUid(String packageName, int userId)
Method mGetPackageUid = clazz.getDeclaredMethod("getPackageUid", String.class, int.class);
mGetPackageUid.setAccessible(true);
int userId = Util.getUserId(Binder.getCallingUid());
uid = (Integer) mGetPackageUid.invoke(param.thisObject, pkgName, userId);
} catch (NoSuchMethodException ignored) {
// public int getPackageUid(String packageName)
Method mGetPackageUid = clazz.getDeclaredMethod("getPackageUid", String.class);
mGetPackageUid.setAccessible(true);
uid = (Integer) mGetPackageUid.invoke(param.thisObject, pkgName);
}
checkPermission(param, uid, permName);
}
break;
case checkUidPermission:
if (param.args.length > 1 && param.args[0] instanceof String && param.args[1] instanceof Integer) {
String permName = (String) param.args[0];
int uid = (Integer) param.args[1];
int resultOfCheck = (Integer) param.getResult();
if (resultOfCheck == PackageManager.PERMISSION_GRANTED)
checkPermission(param, uid, permName);
}
break;
}
}
private void checkPermission(XParam param, int uid, String permName) throws Throwable {
if ("android.permission.CAMERA".endsWith(permName))
if (getRestricted(uid, PrivacyManager.cMedia, "Camera.permission"))
param.setResult(PackageManager.PERMISSION_DENIED);
if ("android.permission.RECORD_AUDIO".endsWith(permName))
if (getRestricted(uid, PrivacyManager.cMedia, "Record.Audio.permission"))
param.setResult(PackageManager.PERMISSION_DENIED);
if ("android.permission.RECORD_VIDEO".endsWith(permName))
if (getRestricted(uid, PrivacyManager.cMedia, "Record.Video.permission"))
param.setResult(PackageManager.PERMISSION_DENIED);
if (PrivacyManager.getSettingBool(0, PrivacyManager.cSettingPermMan, false)) {
permName = permName.replace("android.permission.", "");
if (isRestrictedExtra(uid, getRestrictionName(), getMethodName(), permName))
param.setResult(PackageManager.PERMISSION_DENIED);
}
}
private List<ApplicationInfo> filterApplicationInfo(List<ApplicationInfo> original) {
ArrayList<ApplicationInfo> result = new ArrayList<ApplicationInfo>();
for (ApplicationInfo appInfo : original)
if (isPackageAllowed(appInfo.uid, appInfo.packageName))
result.add(appInfo);
return result;
}
private List<PackageInfo> filterPackageInfo(List<PackageInfo> original) {
ArrayList<PackageInfo> result = new ArrayList<PackageInfo>();
for (PackageInfo pkgInfo : original)
if (isPackageAllowed(pkgInfo.applicationInfo == null ? 0 : pkgInfo.applicationInfo.uid, pkgInfo.packageName))
result.add(pkgInfo);
return result;
}
private List<ProviderInfo> filterProviderInfo(List<ProviderInfo> original) {
ArrayList<ProviderInfo> result = new ArrayList<ProviderInfo>();
for (ProviderInfo provInfo : original)
if (isPackageAllowed(provInfo.applicationInfo == null ? 0 : provInfo.applicationInfo.uid,
provInfo.packageName))
result.add(provInfo);
return result;
}
private List<ResolveInfo> filterResolveInfo(List<ResolveInfo> original) {
ArrayList<ResolveInfo> result = new ArrayList<ResolveInfo>();
for (ResolveInfo resInfo : original)
if (resInfo.activityInfo != null && resInfo.activityInfo.applicationInfo != null)
if (isPackageAllowed(resInfo.activityInfo.applicationInfo.uid,
resInfo.activityInfo.applicationInfo.packageName))
result.add(resInfo);
return result;
}
public static boolean isPackageAllowed(int puid, String packageName) {
int uid = Binder.getCallingUid();
if (puid == uid)
return true;
if (packageName == null) {
Util.log(null, Log.WARN, "isPackageAllowed uid=" + uid + " package=" + packageName);
Util.logStack(null, Log.WARN);
return false;
}
boolean allowed = PrivacyManager.getSettingBool(-uid, Meta.cTypeApplication, packageName, false);
boolean blacklist = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
if (blacklist)
allowed = !allowed;
if (allowed)
Util.log(null, Log.INFO, "Allowing package=" + packageName);
return allowed;
}
}
| 17,759 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XLocationClient.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XLocationClient.java | package biz.bokhorst.xprivacy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import android.app.PendingIntent;
import android.location.Location;
import android.os.Binder;
import android.util.Log;
public class XLocationClient extends XHook {
private Methods mMethod;
private static final Map<Object, Object> mMapProxy = new WeakHashMap<Object, Object>();
private XLocationClient(Methods method, String restrictionName) {
super(restrictionName, method.name(), String.format("GMS.%s", method.name()));
mMethod = method;
}
public String getClassName() {
return "com.google.android.gms.location.LocationClient";
}
// @formatter:off
// void addGeofences(List<Geofence> geofences, PendingIntent pendingIntent, LocationClient.OnAddGeofencesResultListener listener)
// Location getLastLocation()
// void removeGeofences(List<String> geofenceRequestIds, LocationClient.OnRemoveGeofencesResultListener listener)
// void removeGeofences(PendingIntent pendingIntent, LocationClient.OnRemoveGeofencesResultListener listener)
// void removeLocationUpdates(LocationListener listener)
// void removeLocationUpdates(PendingIntent callbackIntent)
// void requestLocationUpdates(LocationRequest request, PendingIntent callbackIntent)
// void requestLocationUpdates(LocationRequest request, LocationListener listener)
// void requestLocationUpdates(LocationRequest request, LocationListener listener, Looper looper)
// https://developer.android.com/reference/com/google/android/gms/location/LocationClient.html
// @formatter:on
private enum Methods {
addGeofences, getLastLocation, removeGeofences, removeLocationUpdates, requestLocationUpdates
};
public static List<XHook> getInstances() {
Util.log(null, Log.WARN, "Hooking LocationClient uid=" + Binder.getCallingUid());
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XLocationClient(Methods.addGeofences, PrivacyManager.cLocation));
listHook.add(new XLocationClient(Methods.getLastLocation, PrivacyManager.cLocation));
listHook.add(new XLocationClient(Methods.removeGeofences, null));
listHook.add(new XLocationClient(Methods.removeLocationUpdates, null));
listHook.add(new XLocationClient(Methods.requestLocationUpdates, PrivacyManager.cLocation));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case addGeofences:
if (isRestricted(param))
param.setResult(null);
break;
case getLastLocation:
// Do nothing
break;
case removeGeofences:
if (isRestricted(param, PrivacyManager.cLocation, "GMS.addGeofences"))
param.setResult(null);
break;
case removeLocationUpdates:
if (param.args.length > 0)
if (param.args[0] instanceof PendingIntent) {
if (isRestricted(param, PrivacyManager.cLocation, "GMS.requestLocationUpdates"))
param.setResult(null);
} else if (param.args[0] != null)
synchronized (mMapProxy) {
if (mMapProxy.containsKey(param.args[0]))
param.args[0] = mMapProxy.get(param.args[0]);
}
break;
case requestLocationUpdates:
if (param.args.length > 1)
if (isRestricted(param))
if (param.args[1] instanceof PendingIntent)
param.setResult(null);
else if (param.thisObject != null && param.args[1] != null) {
// Create proxy
ClassLoader cl = param.thisObject.getClass().getClassLoader();
Class<?> ll = Class.forName("com.google.android.gms.location.LocationListener", false, cl);
InvocationHandler ih = new OnLocationChangedHandler(Binder.getCallingUid(), param.args[1]);
Object proxy = Proxy.newProxyInstance(cl, new Class<?>[] { ll }, ih);
// Use proxy
synchronized (mMapProxy) {
mMapProxy.put(param.args[1], proxy);
}
param.args[1] = proxy;
}
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case addGeofences:
case removeGeofences:
// Do nothing
break;
case getLastLocation:
Location location = (Location) param.getResult();
if (location != null)
if (isRestricted(param))
param.setResult(PrivacyManager.getDefacedLocation(Binder.getCallingUid(), location));
break;
case removeLocationUpdates:
// Do nothing
break;
case requestLocationUpdates:
// Do nothing
break;
}
}
private class OnLocationChangedHandler implements InvocationHandler {
private int mUid;
private Object mTarget;
public OnLocationChangedHandler(int uid, Object target) {
mUid = uid;
mTarget = target;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("onLocationChanged".equals(method.getName()))
args[0] = PrivacyManager.getDefacedLocation(mUid, (Location) args[0]);
return method.invoke(mTarget, args);
}
}
}
| 4,976 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XRuntime.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XRuntime.java | package biz.bokhorst.xprivacy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
public class XRuntime extends XHook {
private Methods mMethod;
private String mCommand;
private XRuntime(Methods method, String restrictionName, String command) {
super(restrictionName, method.name(), command);
mMethod = method;
mCommand = command;
}
public String getClassName() {
return "java.lang.Runtime";
}
@Override
public boolean isVisible() {
return !(mMethod == Methods.load || mMethod == Methods.loadLibrary);
}
// public Process exec(String[] progArray)
// public Process exec(String[] progArray, String[] envp)
// public Process exec(String[] progArray, String[] envp, File directory)
// public Process exec(String prog)
// public Process exec(String prog, String[] envp)
// public Process exec(String prog, String[] envp, File directory)
// public void load(String pathName)
// public void loadLibrary(String libName)
// libcore/luni/src/main/java/java/lang/Runtime.java
// http://developer.android.com/reference/java/lang/Runtime.html
private enum Methods {
exec, load, loadLibrary
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, "sh"));
listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, "su"));
listHook.add(new XRuntime(Methods.exec, PrivacyManager.cShell, null));
listHook.add(new XRuntime(Methods.load, PrivacyManager.cShell, null));
listHook.add(new XRuntime(Methods.loadLibrary, PrivacyManager.cShell, null));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case exec:
// Get programs
String[] progs = null;
if (param.args.length > 0 && param.args[0] != null)
if (String.class.isAssignableFrom(param.args[0].getClass()))
progs = new String[] { (String) param.args[0] };
else
progs = (String[]) param.args[0];
// Check programs
if (progs != null) {
String command = TextUtils.join(" ", progs);
if (matches(command, mCommand) && isRestrictedExtra(param, command))
param.setThrowable(new IOException("XPrivacy"));
}
break;
case load:
case loadLibrary:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || Process.myUid() != Process.SYSTEM_UID)
if (param.args.length > 0) {
String libName = (String) param.args[0];
if (isRestrictedExtra(param, libName))
param.setThrowable(new UnsatisfiedLinkError("XPrivacy"));
}
break;
}
}
@Override
protected void after(final XParam param) throws Throwable {
// Do nothing
}
public static boolean matches(String command, String mCommand) {
if (mCommand == null)
return !isShell(command) && !isSU(command);
else if (mCommand.equals("sh"))
return isShell(command);
else if (mCommand.equals("su"))
return isSU(command);
else
return false;
}
private static boolean isShell(String command) {
return command.startsWith("sh") || command.matches("/.*/.*/sh.*") || command.contains("sh ");
}
private static boolean isSU(String command) {
return command.startsWith("su") || command.matches("/.*/.*/su.*") || command.contains("su ");
}
}
| 3,351 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XSettingsSecure.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XSettingsSecure.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.provider.Settings;
import android.util.Log;
public class XSettingsSecure extends XHook {
private Methods mMethod;
private XSettingsSecure(Methods method, String restrictionName) {
super(restrictionName, method.name(), null);
mMethod = method;
}
public String getClassName() {
return "android.provider.Settings.Secure";
}
// @formatter:off
// public synchronized static String getString(ContentResolver resolver, String name)
// frameworks/base/core/java/android/provider/Settings.java
// frameworks/base/core/java/android/content/ContentResolver.java
// http://developer.android.com/reference/android/provider/Settings.Secure.html
// @formatter:on
private enum Methods {
getString
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XSettingsSecure(Methods.getString, PrivacyManager.cIdentification));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getString) {
String name = (param.args.length > 1 ? (String) param.args[1] : null);
if (Settings.Secure.ANDROID_ID.equals(name)) {
String id = (String) param.getResult();
if (id != null)
if (isRestrictedValue(param, id))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "ANDROID_ID"));
}
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
}
| 1,645 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XProcess.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XProcess.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.util.Log;
public class XProcess extends XHook {
private Methods mMethod;
private String mRestrictionName;
private String mAction;
private XProcess(Methods method, String restrictionName, String action) {
super(restrictionName, method.name(), action);
mMethod = method;
mRestrictionName = restrictionName;
mAction = action;
}
public String getClassName() {
return "android.os.Process";
}
public boolean isVisible() {
return false;
}
private enum Methods {
startViaZygote
};
// @formatter:off
// private static ProcessStartResult startViaZygote(
// final String processClass, final String niceName,
// final int uid, final int gid, final int[] gids, ...
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/os/Process.java
// @formatter:on
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cInternet, "inet"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cInternet, "inet_admin"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cInternet, "inet_bw"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cInternet, "inet_vpn"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cInternet, "inet_mesh"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cStorage, "media"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cStorage, "sdcard"));
listHook.add(new XProcess(Methods.startViaZygote, PrivacyManager.cStorage, "mtp"));
return listHook;
}
final static int sdcard_r = 1028; // 4.1+
final static int sdcard_rw = 1015; // 4.0+
final static int media_rw = 1023; // 4.0+
final static int mtp = 1024;
final static int sdcard_pics = 1033; // 4.4+ photos
final static int sdcard_av = 1034; // 4.4+ audio/video
final static int sdcard_all = 1035; // 4.4+ all users
final static int inet = 3003; // 4.0+
final static int inet_raw = 3004; // 4.0+
final static int inet_admin = 3005;
final static int inet_bw_stats = 3006;
final static int inet_bw_acct = 3007;
final static int inet_vpn = 1016;
final static int inet_mesh = 1030;
// frameworks/base/data/etc/platform.xml
// https://android.googlesource.com/platform/system/core/+/master/include/private/android_filesystem_config.h
// http://www.doubleencore.com/2014/03/android-external-storage/
// http://www.chainfire.eu/articles/113/Is_Google_blocking_apps_writing_to_SD_cards_/
// https://android.googlesource.com/platform/system/core/+/dfe0cba
// https://android.googlesource.com/platform/system/core/+/master/sdcard/sdcard.c
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case startViaZygote:
if (param.args.length >= 5 && param.args[2] instanceof Integer && param.args[4] instanceof int[]) {
// Get IDs
int uid = (Integer) param.args[2];
int[] gids = (int[]) param.args[4];
// Build list of modified gids
List<Integer> listGids = new ArrayList<Integer>();
for (int i = 0; i < gids.length; i++) {
if (gids[i] == media_rw)
if (mRestrictionName.equals(PrivacyManager.cStorage) && mAction.equals("media")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking media uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == sdcard_r || gids[i] == sdcard_rw || gids[i] == sdcard_all
|| gids[i] == sdcard_pics || gids[i] == sdcard_av)
if (mRestrictionName.equals(PrivacyManager.cStorage) && mAction.equals("sdcard")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking sdcard uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == mtp)
if (mRestrictionName.equals(PrivacyManager.cStorage) && mAction.equals("mtp")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking mtp uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == inet || gids[i] == inet_raw)
if (mRestrictionName.equals(PrivacyManager.cInternet) && mAction.equals("inet")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking inet uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == inet_admin)
if (mRestrictionName.equals(PrivacyManager.cInternet) && mAction.equals("inet_admin")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking inet_admin uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == inet_bw_stats || gids[i] == inet_bw_acct)
if (mRestrictionName.equals(PrivacyManager.cInternet) && mAction.equals("inet_bw")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking inet_bw uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == inet_vpn)
if (mRestrictionName.equals(PrivacyManager.cInternet) && mAction.equals("inet_vpn")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking inet_vpn uid=" + uid);
else
listGids.add(gids[i]);
else if (gids[i] == inet_mesh)
if (mRestrictionName.equals(PrivacyManager.cInternet) && mAction.equals("inet_mesh")
&& getRestricted(uid, mAction))
Util.log(this, Log.INFO, "Revoking inet_mesh uid=" + uid);
else
listGids.add(gids[i]);
else
listGids.add(gids[i]);
}
// Proces list of modified gids
int[] mGids = new int[listGids.size()];
for (int i = 0; i < listGids.size(); i++)
mGids[i] = listGids.get(i);
param.args[4] = (mGids.length == 0 ? null : mGids);
}
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
| 5,943 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XContentResolver.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XContentResolver.java | package biz.bokhorst.xprivacy;
import java.io.FileNotFoundException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import android.annotation.SuppressLint;
import android.content.SyncAdapterType;
import android.content.SyncInfo;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
public class XContentResolver extends XHook {
private Methods mMethod;
private boolean mClient;
private String mClassName;
private XContentResolver(Methods method, String restrictionName, String className) {
super(restrictionName, method.name().replace("Srv_", ""), method.name());
mMethod = method;
if (className == null)
mClassName = "com.android.server.content.ContentService";
else
mClassName = className;
}
private XContentResolver(Methods method, String restrictionName, boolean client) {
super(restrictionName, method.name(), null);
mMethod = method;
mClient = client;
mClassName = null;
}
public String getClassName() {
if (mClassName == null)
return (mClient ? "android.content.ContentProviderClient" : "android.content.ContentResolver");
else
return mClassName;
}
// @formatter:off
// public static SyncInfo getCurrentSync()
// static List<SyncInfo> getCurrentSyncs()
// static SyncAdapterType[] getSyncAdapterTypes()
// final AssetFileDescriptor openAssetFileDescriptor(Uri uri, String mode)
// final AssetFileDescriptor openAssetFileDescriptor(Uri uri, String mode, CancellationSignal cancellationSignal)
// final ParcelFileDescriptor openFileDescriptor(Uri uri, String mode, CancellationSignal cancellationSignal)
// final ParcelFileDescriptor openFileDescriptor(Uri uri, String mode)
// final InputStream openInputStream(Uri uri)
// final OutputStream openOutputStream(Uri uri)
// final OutputStream openOutputStream(Uri uri, String mode)
// final AssetFileDescriptor openTypedAssetFileDescriptor(Uri uri, String mimeType, Bundle opts, CancellationSignal cancellationSignal)
// final AssetFileDescriptor openTypedAssetFileDescriptor(Uri uri, String mimeType, Bundle opts)
// AssetFileDescriptor openAssetFile(Uri url, String mode, CancellationSignal signal)
// AssetFileDescriptor openAssetFile(Uri url, String mode)
// ParcelFileDescriptor openFile(Uri url, String mode)
// ParcelFileDescriptor openFile(Uri url, String mode, CancellationSignal signal)
// public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder)
// public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal)
// https://developers.google.com/gmail/android/
// http://developer.android.com/reference/android/content/ContentResolver.html
// http://developer.android.com/reference/android/content/ContentProviderClient.html
// http://developer.android.com/reference/android/provider/Contacts.People.html
// http://developer.android.com/reference/android/provider/ContactsContract.Contacts.html
// http://developer.android.com/reference/android/provider/ContactsContract.Data.html
// http://developer.android.com/reference/android/provider/ContactsContract.PhoneLookup.html
// http://developer.android.com/reference/android/provider/ContactsContract.Profile.html
// http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html
// frameworks/base/core/java/android/content/ContentResolver.java
// public List<SyncInfo> getCurrentSyncs()
// public void registerContentObserver(android.net.Uri uri, boolean notifyForDescendants, android.database.IContentObserver observer, int userHandle)
// public void unregisterContentObserver(android.database.IContentObserver observer)
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/content/ContentService.java
// public List<android.content.SyncInfo> getCurrentSyncsAsUser(int userId)
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/android/content/IContentService.java
// public Bundle call(String method, String request, Bundle args)
// http://developer.android.com/reference/android/provider/Settings.html
// http://developer.android.com/reference/android/provider/Settings.Global.html
// http://developer.android.com/reference/android/provider/Settings.Secure.html
// http://developer.android.com/reference/android/provider/Settings.System.html
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/com/android/providers/settings/SettingsProvider.java
// @formatter:on
// @formatter:off
private enum Methods {
getCurrentSync, getCurrentSyncs, getSyncAdapterTypes,
openAssetFile, openFile, openAssetFileDescriptor, openFileDescriptor, openInputStream, openOutputStream, openTypedAssetFileDescriptor,
query, Srv_call, Srv_query,
Srv_getCurrentSyncs, Srv_getCurrentSyncsAsUser
};
// @formatter:on
// @formatter:off
public static List<String> cProviderClassName = Arrays.asList(new String[] {
"com.android.providers.downloads.DownloadProvider",
"com.android.providers.calendar.CalendarProvider2",
"com.android.providers.contacts.CallLogProvider",
"com.android.providers.contacts.ContactsProvider2",
"com.google.android.gm.provider.PublicContentProvider",
"com.google.android.gsf.gservices.GservicesProvider",
"com.android.providers.telephony.MmsProvider",
"com.android.providers.telephony.MmsSmsProvider",
"com.android.providers.telephony.SmsProvider",
"com.android.providers.telephony.TelephonyProvider",
"com.android.providers.userdictionary.UserDictionaryProvider",
"com.android.providers.settings.SettingsProvider",
});
// @formatter:on
public static List<XHook> getPackageInstances(String packageName, ClassLoader loader) {
if (packageName.startsWith("com.android.browser.provider"))
try {
Class.forName("com.android.browser.provider.BrowserProviderProxy", false, loader);
return getInstances("com.android.browser.provider.BrowserProviderProxy");
} catch (ClassNotFoundException ignored) {
try {
Class.forName("com.android.browser.provider.BrowserProvider2", false, loader);
return getInstances("com.android.browser.provider.BrowserProvider2");
} catch (ClassNotFoundException ignored2) {
Util.log(null, Log.ERROR, "Browser provider not found, package=" + packageName);
return new ArrayList<XHook>();
}
}
else if (packageName.startsWith("com.android.email.provider"))
try {
Class.forName("com.android.email.provider.EmailProvider", false, loader);
return getInstances("com.android.email.provider.EmailProvider");
} catch (ClassNotFoundException ignored) {
Util.log(null, Log.WARN, "E-mail provider not found, package=" + packageName);
return new ArrayList<XHook>();
}
else if (packageName.startsWith("com.google.android.gm.provider"))
try {
Class.forName("com.google.android.gm.provider.PublicContentProvider", false, loader);
return getInstances("com.google.android.gm.provider.PublicContentProvider");
} catch (ClassNotFoundException ignored) {
Util.log(null, Log.WARN, "G-mail provider not found, package=" + packageName);
return new ArrayList<XHook>();
}
else {
List<XHook> listHook = new ArrayList<XHook>();
for (String className : cProviderClassName)
if (className.startsWith(packageName))
listHook.addAll(getInstances(className));
return listHook;
}
}
private static List<XHook> getInstances(String className) {
List<XHook> listHook = new ArrayList<XHook>();
if ("com.android.providers.settings.SettingsProvider".equals(className))
listHook.add(new XContentResolver(Methods.Srv_call, null, className));
else
listHook.add(new XContentResolver(Methods.Srv_query, null, className));
return listHook;
}
public static List<XHook> getInstances(boolean server) {
List<XHook> listHook = new ArrayList<XHook>();
if (server) {
listHook.add(new XContentResolver(Methods.Srv_query, null, "com.android.internal.telephony.IccProvider"));
listHook.add(new XContentResolver(Methods.Srv_getCurrentSyncs, PrivacyManager.cAccounts, null));
listHook.add(new XContentResolver(Methods.Srv_getCurrentSyncsAsUser, PrivacyManager.cAccounts, null));
} else {
listHook.add(new XContentResolver(Methods.getCurrentSync, PrivacyManager.cAccounts, false));
listHook.add(new XContentResolver(Methods.getCurrentSyncs, PrivacyManager.cAccounts, false));
listHook.add(new XContentResolver(Methods.getSyncAdapterTypes, PrivacyManager.cAccounts, false));
listHook.add(new XContentResolver(Methods.openAssetFileDescriptor, PrivacyManager.cStorage, false));
listHook.add(new XContentResolver(Methods.openFileDescriptor, PrivacyManager.cStorage, false));
listHook.add(new XContentResolver(Methods.openInputStream, PrivacyManager.cStorage, false));
listHook.add(new XContentResolver(Methods.openOutputStream, PrivacyManager.cStorage, false));
listHook.add(new XContentResolver(Methods.openTypedAssetFileDescriptor, PrivacyManager.cStorage, false));
listHook.add(new XContentResolver(Methods.openAssetFile, PrivacyManager.cStorage, true));
listHook.add(new XContentResolver(Methods.openFile, PrivacyManager.cStorage, true));
listHook.add(new XContentResolver(Methods.openTypedAssetFileDescriptor, PrivacyManager.cStorage, true));
listHook.add(new XContentResolver(Methods.query, null, false));
listHook.add(new XContentResolver(Methods.query, null, true));
}
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case getCurrentSync:
case getCurrentSyncs:
case getSyncAdapterTypes:
case openAssetFile:
case openFile:
case openAssetFileDescriptor:
case openFileDescriptor:
case openInputStream:
case openOutputStream:
case openTypedAssetFileDescriptor:
// Do nothing
break;
case Srv_call:
break;
case query:
case Srv_query:
handleUriBefore(param);
break;
case Srv_getCurrentSyncs:
case Srv_getCurrentSyncsAsUser:
// Do nothing
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getCurrentSync:
if (isRestricted(param))
param.setResult(null);
break;
case getCurrentSyncs:
if (isRestricted(param))
param.setResult(new ArrayList<SyncInfo>());
break;
case getSyncAdapterTypes:
if (isRestricted(param))
param.setResult(new SyncAdapterType[0]);
break;
case openAssetFileDescriptor:
case openFileDescriptor:
case openInputStream:
case openOutputStream:
case openTypedAssetFileDescriptor:
case openAssetFile:
case openFile:
if (param.args.length > 0 && param.args[0] instanceof Uri) {
String uri = ((Uri) param.args[0]).toString();
if (isRestrictedExtra(param, uri))
param.setThrowable(new FileNotFoundException("XPrivacy"));
}
break;
case Srv_call:
handleCallAfter(param);
break;
case query:
case Srv_query:
handleUriAfter(param);
break;
case Srv_getCurrentSyncs:
case Srv_getCurrentSyncsAsUser:
if (param.getResult() != null)
if (isRestricted(param)) {
int uid = Binder.getCallingUid();
@SuppressWarnings("unchecked")
List<SyncInfo> listSync = (List<SyncInfo>) param.getResult();
List<SyncInfo> listFiltered = new ArrayList<SyncInfo>();
for (SyncInfo sync : listSync)
if (XAccountManager.isAccountAllowed(sync.account, uid))
listFiltered.add(sync);
param.setResult(listFiltered);
}
break;
}
}
@SuppressLint("DefaultLocale")
private void handleUriBefore(XParam param) throws Throwable {
// Check URI
if (param.args.length > 1 && param.args[0] instanceof Uri) {
String uri = ((Uri) param.args[0]).toString().toLowerCase();
String[] projection = (param.args[1] instanceof String[] ? (String[]) param.args[1] : null);
if (uri.startsWith("content://com.android.contacts/contacts/name_phone_or_email")) {
// Do nothing
} else if (uri.startsWith("content://com.android.contacts/")
&& !uri.equals("content://com.android.contacts/")) {
String[] components = uri.replace("content://com.android.", "").split("/");
String methodName = components[0] + "/" + components[1].split("\\?")[0];
if (methodName.equals("contacts/contacts") || methodName.equals("contacts/data")
|| methodName.equals("contacts/phone_lookup") || methodName.equals("contacts/raw_contacts"))
if (isRestrictedExtra(param, PrivacyManager.cContacts, methodName, uri)) {
// Get ID from URL if any
int urlid = -1;
if ((methodName.equals("contacts/contacts") || methodName.equals("contacts/phone_lookup"))
&& components.length > 2 && TextUtils.isDigitsOnly(components[2]))
urlid = Integer.parseInt(components[2]);
// Modify projection
boolean added = false;
if (projection != null && urlid < 0) {
List<String> listProjection = new ArrayList<String>();
listProjection.addAll(Arrays.asList(projection));
String cid = getIdForUri(uri);
if (cid != null && !listProjection.contains(cid)) {
added = true;
listProjection.add(cid);
}
param.args[1] = listProjection.toArray(new String[0]);
}
if (added)
param.setObjectExtra("column_added", added);
}
}
}
}
@SuppressLint("DefaultLocale")
private void handleUriAfter(XParam param) throws Throwable {
// Check URI
if (param.args.length > 1 && param.args[0] instanceof Uri && param.getResult() != null) {
String uri = ((Uri) param.args[0]).toString().toLowerCase();
String[] projection = (param.args[1] instanceof String[] ? (String[]) param.args[1] : null);
String selection = (param.args[2] instanceof String ? (String) param.args[2] : null);
Cursor cursor = (Cursor) param.getResult();
if (uri.startsWith("content://applications")) {
// Applications provider: allow selected applications
if (isRestrictedExtra(param, PrivacyManager.cSystem, "ApplicationsProvider", uri)) {
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
while (cursor.moveToNext()) {
int colPackage = cursor.getColumnIndex("package");
String packageName = (colPackage < 0 ? null : cursor.getString(colPackage));
if (packageName != null && XPackageManager.isPackageAllowed(0, packageName))
copyColumns(cursor, result);
}
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
}
} else if (uri.startsWith("content://com.google.android.gsf.gservices")) {
// Google services provider: block only android_id
if (param.args.length > 3 && param.args[3] != null) {
List<String> listSelection = Arrays.asList((String[]) param.args[3]);
if (listSelection.contains("android_id"))
if (isRestrictedExtra(param, PrivacyManager.cIdentification, "GservicesProvider", uri)) {
int ikey = cursor.getColumnIndex("key");
int ivalue = cursor.getColumnIndex("value");
if (ikey == 0 && ivalue == 1 && cursor.getColumnCount() == 2) {
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
while (cursor.moveToNext()) {
if ("android_id".equals(cursor.getString(ikey)) && cursor.getString(ivalue) != null)
result.addRow(new Object[] { "android_id",
PrivacyManager.getDefacedProp(Binder.getCallingUid(), "GSF_ID") });
else
copyColumns(cursor, result);
}
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
} else
Util.log(this, Log.ERROR,
"Unexpected result uri=" + uri + " columns=" + cursor.getColumnNames());
}
}
} else if (uri.startsWith("content://com.android.contacts/contacts/name_phone_or_email")) {
// Do nothing
} else if (uri.startsWith("content://com.android.contacts/")
&& !uri.equals("content://com.android.contacts/")) {
// Contacts provider: allow selected contacts
String[] components = uri.replace("content://com.android.", "").split("/");
String methodName = components[0] + "/" + components[1].split("\\?")[0];
if (methodName.equals("contacts/contacts") || methodName.equals("contacts/data")
|| methodName.equals("contacts/phone_lookup") || methodName.equals("contacts/raw_contacts")) {
if (isRestrictedExtra(param, PrivacyManager.cContacts, methodName, uri)) {
// Get ID from URL if any
int urlid = -1;
if ((methodName.equals("contacts/contacts") || methodName.equals("contacts/phone_lookup"))
&& components.length > 2 && TextUtils.isDigitsOnly(components[2]))
urlid = Integer.parseInt(components[2]);
// Modify column names back
Object column_added = param.getObjectExtra("column_added");
boolean added = (column_added == null ? false : (Boolean) param.getObjectExtra("column_added"));
List<String> listColumn = new ArrayList<String>();
listColumn.addAll(Arrays.asList(cursor.getColumnNames()));
if (added)
listColumn.remove(listColumn.size() - 1);
// Get blacklist setting
int uid = Binder.getCallingUid();
boolean blacklist = PrivacyManager
.getSettingBool(-uid, PrivacyManager.cSettingBlacklist, false);
MatrixCursor result = new MatrixCursor(listColumn.toArray(new String[0]));
// Filter rows
String cid = getIdForUri(uri);
int iid = (cid == null ? -1 : cursor.getColumnIndex(cid));
if (iid >= 0 || urlid >= 0)
while (cursor.moveToNext()) {
// Check if allowed
long id = (urlid >= 0 ? urlid : cursor.getLong(iid));
boolean allowed = PrivacyManager.getSettingBool(-uid, Meta.cTypeContact,
Long.toString(id), false);
if (blacklist)
allowed = !allowed;
if (allowed)
copyColumns(cursor, result, listColumn.size());
}
else
Util.log(this, Log.WARN, "ID missing URI=" + uri + " added=" + added + "/" + cid
+ " columns=" + TextUtils.join(",", cursor.getColumnNames()) + " projection="
+ (projection == null ? "null" : TextUtils.join(",", projection)) + " selection="
+ selection);
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
}
} else {
methodName = null;
if (uri.startsWith("content://com.android.contacts/profile"))
methodName = "contacts/profile";
else
methodName = "ContactsProvider2"; // fall-back
if (methodName != null)
if (isRestrictedExtra(param, PrivacyManager.cContacts, methodName, uri)) {
// Return empty cursor
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
}
}
} else {
// Other uri restrictions
String restrictionName = null;
String methodName = null;
if (uri.startsWith("content://browser")) {
restrictionName = PrivacyManager.cBrowser;
methodName = "BrowserProvider2";
}
else if (uri.startsWith("content://com.android.calendar")) {
restrictionName = PrivacyManager.cCalendar;
methodName = "CalendarProvider2";
}
else if (uri.startsWith("content://call_log")) {
restrictionName = PrivacyManager.cCalling;
methodName = "CallLogProvider";
}
else if (uri.startsWith("content://contacts/people")) {
restrictionName = PrivacyManager.cContacts;
methodName = "contacts/people";
}
else if (uri.startsWith("content://downloads")) {
restrictionName = PrivacyManager.cBrowser;
methodName = "Downloads";
}
else if (uri.startsWith("content://com.android.email.provider")) {
restrictionName = PrivacyManager.cEMail;
methodName = "EMailProvider";
}
else if (uri.startsWith("content://com.google.android.gm")) {
restrictionName = PrivacyManager.cEMail;
methodName = "GMailProvider";
}
else if (uri.startsWith("content://icc")) {
restrictionName = PrivacyManager.cContacts;
methodName = "IccProvider";
}
else if (uri.startsWith("content://mms")) {
restrictionName = PrivacyManager.cMessages;
methodName = "MmsProvider";
}
else if (uri.startsWith("content://mms-sms")) {
restrictionName = PrivacyManager.cMessages;
methodName = "MmsSmsProvider";
}
else if (uri.startsWith("content://sms")) {
restrictionName = PrivacyManager.cMessages;
methodName = "SmsProvider";
}
else if (uri.startsWith("content://telephony")) {
restrictionName = PrivacyManager.cPhone;
methodName = "TelephonyProvider";
}
else if (uri.startsWith("content://user_dictionary")) {
restrictionName = PrivacyManager.cDictionary;
methodName = "UserDictionary";
}
else if (uri.startsWith("content://com.android.voicemail")) {
restrictionName = PrivacyManager.cMessages;
methodName = "VoicemailContentProvider";
}
// Check if know / restricted
if (restrictionName != null && methodName != null) {
if (isRestrictedExtra(param, restrictionName, methodName, uri)) {
// Return empty cursor
MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
result.respond(cursor.getExtras());
param.setResult(result);
cursor.close();
}
}
}
}
}
private void handleCallAfter(XParam param) throws Throwable {
if (param.args.length > 1 && param.args[0] instanceof String && param.args[1] instanceof String) {
String method = (String) param.args[0];
String request = (String) param.args[1];
if ("GET_secure".equals(method)) {
if (Settings.Secure.ANDROID_ID.equals(request)) {
if (!hasEmptyValue(param.getResult()))
if (isRestricted(param, PrivacyManager.cIdentification, "Srv_Android_ID")) {
int uid = Binder.getCallingUid();
String value = (String) PrivacyManager.getDefacedProp(uid, "ANDROID_ID");
Bundle bundle = new Bundle(1);
bundle.putString("value", value);
param.setResult(bundle);
}
}
} else if ("GET_system".equals(method)) {
// Do nothing
} else if ("GET_global".equals(method)) {
if ("default_dns_server".equals(request)) {
if (!hasEmptyValue(param.getResult()))
if (isRestricted(param, PrivacyManager.cNetwork, "Srv_Default_DNS")) {
int uid = Binder.getCallingUid();
InetAddress value = (InetAddress) PrivacyManager.getDefacedProp(uid, "InetAddress");
Bundle bundle = new Bundle(1);
bundle.putString("value", value.getHostAddress());
param.setResult(bundle);
}
} else if ("wifi_country_code".equals(request)) {
if (!hasEmptyValue(param.getResult()))
if (isRestricted(param, PrivacyManager.cNetwork, "Srv_WiFi_Country")) {
int uid = Binder.getCallingUid();
String value = (String) PrivacyManager.getDefacedProp(uid, "CountryIso");
Bundle bundle = new Bundle(1);
bundle.putString("value", value == null ? null : value.toLowerCase(Locale.ROOT));
param.setResult(bundle);
}
}
}
}
}
// Helper methods
private boolean hasEmptyValue(Object result) {
Bundle bundle = (Bundle) result;
if (bundle == null)
return true;
if (!bundle.containsKey("value"))
return true;
return (bundle.get("value") == null);
}
private String getIdForUri(String uri) {
if (uri.startsWith("content://com.android.contacts/contacts"))
return "_id";
else if (uri.startsWith("content://com.android.contacts/data"))
return "contact_id";
else if (uri.startsWith("content://com.android.contacts/phone_lookup"))
return "_id";
else if (uri.startsWith("content://com.android.contacts/raw_contacts"))
return "contact_id";
else
Util.log(this, Log.ERROR, "Unexpected uri=" + uri);
return null;
}
private void copyColumns(Cursor cursor, MatrixCursor result) {
copyColumns(cursor, result, cursor.getColumnCount());
}
private void copyColumns(Cursor cursor, MatrixCursor result, int count) {
try {
Object[] columns = new Object[count];
for (int i = 0; i < count; i++)
switch (cursor.getType(i)) {
case Cursor.FIELD_TYPE_NULL:
columns[i] = null;
break;
case Cursor.FIELD_TYPE_INTEGER:
columns[i] = cursor.getInt(i);
break;
case Cursor.FIELD_TYPE_FLOAT:
columns[i] = cursor.getFloat(i);
break;
case Cursor.FIELD_TYPE_STRING:
columns[i] = cursor.getString(i);
break;
case Cursor.FIELD_TYPE_BLOB:
columns[i] = cursor.getBlob(i);
break;
default:
Util.log(this, Log.WARN, "Unknown cursor data type=" + cursor.getType(i));
}
result.addRow(columns);
} catch (Throwable ex) {
Util.bug(this, ex);
}
}
@SuppressWarnings("unused")
private void _dumpCursor(String uri, Cursor cursor) {
_dumpHeader(uri, cursor);
int i = 0;
while (cursor.moveToNext() && i++ < 10)
_dumpColumns(cursor, "");
cursor.moveToFirst();
}
private void _dumpHeader(String uri, Cursor cursor) {
Util.log(this, Log.WARN, TextUtils.join(", ", cursor.getColumnNames()) + " uri=" + uri);
}
private void _dumpColumns(Cursor cursor, String msg) {
String[] columns = new String[cursor.getColumnCount()];
for (int i = 0; i < cursor.getColumnCount(); i++)
switch (cursor.getType(i)) {
case Cursor.FIELD_TYPE_NULL:
columns[i] = null;
break;
case Cursor.FIELD_TYPE_INTEGER:
columns[i] = Integer.toString(cursor.getInt(i));
break;
case Cursor.FIELD_TYPE_FLOAT:
columns[i] = Float.toString(cursor.getFloat(i));
break;
case Cursor.FIELD_TYPE_STRING:
columns[i] = cursor.getString(i);
break;
case Cursor.FIELD_TYPE_BLOB:
columns[i] = "[blob]";
break;
default:
Util.log(this, Log.WARN, "Unknown cursor data type=" + cursor.getType(i));
}
Util.log(this, Log.WARN, TextUtils.join(", ", columns) + " " + msg);
}
}
| 26,240 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
DeviceAdministratorReceiver.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/DeviceAdministratorReceiver.java | package biz.bokhorst.xprivacy;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class DeviceAdministratorReceiver extends DeviceAdminReceiver {
@Override
public void onEnabled(Context context, Intent intent) {
super.onEnabled(context, intent);
Util.log(null, Log.WARN, "Device admin enabled");
}
@Override
public void onDisabled(Context context, Intent intent) {
super.onDisabled(context, intent);
Util.log(null, Log.WARN, "Device admin disabled");
}
}
| 562 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XBluetoothDevice.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XBluetoothDevice.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.util.Log;
import biz.bokhorst.xprivacy.XHook;
public class XBluetoothDevice extends XHook {
private Methods mMethod;
private XBluetoothDevice(Methods method, String restrictionName) {
super(restrictionName, method.name(), "Bluetooth." + method.name());
mMethod = method;
}
public String getClassName() {
return "android.bluetooth.BluetoothDevice";
}
// public String getAddress()
// frameworks/base/core/java/android/bluetooth/BluetoothDevice.java
// http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html
private enum Methods {
getAddress
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XBluetoothDevice(Methods.getAddress, PrivacyManager.cNetwork));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getAddress) {
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "MAC"));
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
}
| 1,334 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XUsbDevice.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XUsbDevice.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import biz.bokhorst.xprivacy.XHook;
public class XUsbDevice extends XHook {
private Methods mMethod;
private XUsbDevice(Methods method, String restrictionName) {
super(restrictionName, method.name(), "USB." + method.name());
mMethod = method;
}
public String getClassName() {
return "android.hardware.usb.UsbDevice";
}
// public static int getDeviceId(String name)
// public int getDeviceId()
// public String getDeviceName()
// public static String getDeviceName(int id)
// public String getSerialNumber()
// http://developer.android.com/reference/android/hardware/usb/UsbDevice.html
private enum Methods {
getDeviceId, getDeviceName, getSerialNumber
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XUsbDevice(Methods.getDeviceId, PrivacyManager.cIdentification));
listHook.add(new XUsbDevice(Methods.getDeviceName, PrivacyManager.cIdentification));
listHook.add(new XUsbDevice(Methods.getSerialNumber, PrivacyManager.cIdentification));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getDeviceId:
if (param.args.length > 0 && param.args[0] instanceof String) {
if (isRestrictedExtra(param, (String) param.args[0]))
param.setResult(0);
} else {
if (isRestricted(param))
param.setResult(0);
}
break;
case getDeviceName:
case getSerialNumber:
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "USB"));
break;
}
}
}
| 1,800 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XIntentFirewall.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XIntentFirewall.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.provider.Telephony;
import android.service.notification.NotificationListenerService;
import android.telephony.TelephonyManager;
@SuppressLint("InlinedApi")
public class XIntentFirewall extends XHook {
private Methods mMethod;
private static Map<String, String> mapIntentRestriction = new HashMap<String, String>();
static {
// Intent receive: calling
mapIntentRestriction.put(Intent.ACTION_NEW_OUTGOING_CALL, PrivacyManager.cCalling);
mapIntentRestriction.put(TelephonyManager.ACTION_PHONE_STATE_CHANGED, PrivacyManager.cPhone);
mapIntentRestriction.put(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, PrivacyManager.cCalling);
// Intent receive: C2DM
mapIntentRestriction.put("com.google.android.c2dm.intent.REGISTRATION", PrivacyManager.cNotifications);
mapIntentRestriction.put("com.google.android.c2dm.intent.RECEIVE", PrivacyManager.cNotifications);
// Intent receive: NFC
mapIntentRestriction.put(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED, PrivacyManager.cNfc);
mapIntentRestriction.put(NfcAdapter.ACTION_NDEF_DISCOVERED, PrivacyManager.cNfc);
mapIntentRestriction.put(NfcAdapter.ACTION_TAG_DISCOVERED, PrivacyManager.cNfc);
mapIntentRestriction.put(NfcAdapter.ACTION_TECH_DISCOVERED, PrivacyManager.cNfc);
// Intent receive: SMS
mapIntentRestriction.put(Telephony.Sms.Intents.DATA_SMS_RECEIVED_ACTION, PrivacyManager.cMessages);
mapIntentRestriction.put(Telephony.Sms.Intents.SMS_RECEIVED_ACTION, PrivacyManager.cMessages);
mapIntentRestriction.put(Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION, PrivacyManager.cMessages);
mapIntentRestriction.put(Telephony.Sms.Intents.SMS_DELIVER_ACTION, PrivacyManager.cMessages);
mapIntentRestriction.put(Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION, PrivacyManager.cMessages);
// Intent receive: notifications
mapIntentRestriction.put(NotificationListenerService.SERVICE_INTERFACE, PrivacyManager.cNotifications);
// Intent receive: package changes
mapIntentRestriction.put(Intent.ACTION_PACKAGE_ADDED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_REPLACED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_RESTARTED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_REMOVED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_CHANGED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_DATA_CLEARED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_FIRST_LAUNCH, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_FULLY_REMOVED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_PACKAGE_VERIFIED, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE, PrivacyManager.cSystem);
mapIntentRestriction.put(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE, PrivacyManager.cSystem);
}
private XIntentFirewall(Methods method) {
super(null, method.name(), null);
mMethod = method;
}
public String getClassName() {
return "com.android.server.firewall.IntentFirewall";
}
// @formatter:off
// public boolean checkIntent(FirewallIntentResolver resolver, ComponentName resolvedComponent, int intentType, Intent intent, int callerUid, int callerPid, String resolvedType, int receivingUid)
// http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/com/android/server/firewall/IntentFirewall.java
// @formatter:on
private enum Methods {
checkIntent
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XIntentFirewall(Methods.checkIntent));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case checkIntent:
if (param.args.length > 7 && param.args[3] instanceof Intent && param.args[7] instanceof Integer) {
Intent intent = (Intent) param.args[3];
int receivingUid = (Integer) param.args[7];
if (isIntentRestricted(receivingUid, intent))
param.setResult(false);
}
break;
}
}
private boolean isIntentRestricted(int uid, Intent intent) throws Throwable {
String action = intent.getAction();
String data = intent.getDataString();
String actionData = (action == null ? "" : action) + (data == null ? "" : ":" + data);
if (PrivacyManager.getSettingBool(0, PrivacyManager.cSettingIntentWall, false))
if (isRestrictedExtra(uid, "system", "IntentFirewall", actionData))
return true;
if (mapIntentRestriction.containsKey(action)) {
// Get restriction category
String restrictionName = mapIntentRestriction.get(action);
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
// Outgoing call
if (intent.hasExtra(Intent.EXTRA_PHONE_NUMBER)) {
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (phoneNumber != null)
if (isRestrictedExtraValue(uid, restrictionName, action, phoneNumber, phoneNumber))
return true;
}
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
// Incoming call
if (intent.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)) {
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (phoneNumber != null)
if (isRestrictedExtraValue(uid, restrictionName, action, phoneNumber, phoneNumber))
return true;
}
} else if (PrivacyManager.cSystem.equals(restrictionName)) {
// Package event
if (isRestrictedExtra(uid, restrictionName, action, intent.getDataString())) {
String[] packageNames;
if (action.equals(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE)
|| action.equals(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE))
packageNames = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
else
packageNames = new String[] { intent.getData().getSchemeSpecificPart() };
for (String packageName : packageNames)
if (!XPackageManager.isPackageAllowed(0, packageName))
return true;
}
} else if (isRestrictedExtra(uid, restrictionName, action, intent.getDataString()))
return true;
}
return false;
}
}
| 6,635 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XCastDevice.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XCastDevice.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import biz.bokhorst.xprivacy.XHook;
public class XCastDevice extends XHook {
private Methods mMethod;
private XCastDevice(Methods method, String restrictionName) {
super(restrictionName, method.name(), "Cast." + method.name());
mMethod = method;
}
public String getClassName() {
return "com.google.android.gms.cast.CastDevice";
}
// public static getDeviceId()
// public Inet4Address getIpAddress()
// http://developer.android.com/reference/com/google/android/gms/cast/CastDevice.html
private enum Methods {
getDeviceId, getIpAddress
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XCastDevice(Methods.getDeviceId, PrivacyManager.cIdentification));
listHook.add(new XCastDevice(Methods.getIpAddress, PrivacyManager.cIdentification));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
switch (mMethod) {
case getDeviceId:
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "CastID"));
break;
case getIpAddress:
if (param.getResult() != null && isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "InetAddress"));
break;
}
}
}
| 1,512 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XPlaceDetectionApi.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XPlaceDetectionApi.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
import android.util.Log;
public class XPlaceDetectionApi extends XHook {
private Methods mMethod;
private String mClassName;
private XPlaceDetectionApi(Methods method, String restrictionName, String className) {
super(restrictionName, method.name(), "GMS5." + method.name());
mMethod = method;
mClassName = className;
}
public String getClassName() {
return mClassName;
}
// @formatter:off
// abstract PendingResult<PlaceLikelihoodBuffer> getCurrentPlace(GoogleApiClient client, PlaceFilter filter)
// https://developer.android.com/reference/com/google/android/gms/location/places/PlaceDetectionApi.html
// @formatter:on
private enum Methods {
getCurrentPlace
};
public static List<XHook> getInstances(Object instance) {
String className = instance.getClass().getName();
Util.log(null, Log.WARN, "Hooking PlaceDetectionApi class=" + className + " uid=" + Binder.getCallingUid());
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XPlaceDetectionApi(Methods.getCurrentPlace, PrivacyManager.cLocation, className));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}
@Override
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getCurrentPlace:
if (isRestricted(param))
param.setResult(XGoogleApiClient.getPendingResult(param.thisObject.getClass().getClassLoader()));
break;
}
}
}
| 1,548 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
SharedPreferencesEx.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/SharedPreferencesEx.java | package biz.bokhorst.xprivacy;
// Based on:
// https://github.com/rovo89/XposedBridge/blob/master/src/de/robv/android/xposed/XSharedPreferences.java
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import android.content.SharedPreferences;
import android.os.Process;
import android.util.Log;
import com.android.internal.util.XmlUtils;
/**
* This class is basically the same as SharedPreferencesImpl from AOSP, but
* read-only and without listeners support. Instead, it is made to be compatible
* with all ROMs.
*/
public final class SharedPreferencesEx implements SharedPreferences {
private final File mFile;
private final File mBackupFile;
private Map<String, Object> mMap;
private boolean mLoaded = false;
private long mLastModified;
private long mFileSize;
private static int cTryMaxCount = 10;
private static int cTryWaitMs = 50;
public SharedPreferencesEx(File prefFile) {
mFile = prefFile;
mBackupFile = makeBackupFile(prefFile);
startLoadFromDisk();
}
public SharedPreferencesEx(String packageName, String prefFileName) {
mFile = new File(Util.getUserDataDirectory(Process.myUid()) + File.pathSeparator + "shared_prefs"
+ File.pathSeparator + prefFileName + ".xml");
mBackupFile = makeBackupFile(mFile);
startLoadFromDisk();
}
private void startLoadFromDisk() {
synchronized (this) {
mLoaded = false;
}
new Thread("SharedPreferencesEx-load") {
@Override
public void run() {
synchronized (SharedPreferencesEx.this) {
loadFromDiskLocked();
}
}
}.start();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private void loadFromDiskLocked() {
int tries = 0;
while (++tries <= cTryMaxCount && !mLoaded && (mFile.exists() || mBackupFile.exists())) {
// Log retry
if (tries > 1)
Util.log(null, Log.WARN, "Load " + mFile + " try=" + tries + " exists=" + mFile.exists() + " readable="
+ mFile.canRead() + " backup=" + mBackupFile.exists());
// Read file if possible
if (mFile.exists() && mFile.canRead() && !mBackupFile.exists()) {
Map map = null;
long lastModified = mFile.lastModified();
long fileSize = mFile.length();
BufferedInputStream str = null;
try {
str = new BufferedInputStream(new FileInputStream(mFile), 16 * 1024);
map = XmlUtils.readMapXml(str);
} catch (Throwable ex) {
Util.log(null, Log.WARN, "Error reading " + mFile + ": " + ex);
} finally {
if (str != null) {
try {
str.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Throwable ex) {
Util.log(null, Log.WARN, "Error closing " + mFile + ": " + ex);
}
}
}
if (map != null) {
mLoaded = true;
mMap = map;
mLastModified = lastModified;
mFileSize = fileSize;
notifyAll();
}
}
// Wait for next try
if (!mLoaded && tries < cTryMaxCount)
try {
Thread.sleep(cTryWaitMs);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
// File not read
if (!mLoaded) {
if (tries >= cTryMaxCount)
// Not loaded: try to load again on next access
Util.log(null, Log.ERROR, "Not loaded " + mFile);
else
mLoaded = true;
mMap = new HashMap<String, Object>();
notifyAll();
}
}
private static File makeBackupFile(File prefsFile) {
return new File(prefsFile.getPath() + ".bak");
}
/**
* Reload the settings from file if they have changed.
*/
public void reload() {
synchronized (this) {
if (hasFileChanged())
startLoadFromDisk();
}
}
private boolean hasFileChanged() {
// canRead returns false for non existing files
if (!mFile.canRead() || mBackupFile.exists())
return true;
long lastModified = mFile.lastModified();
long fileSize = mFile.length();
synchronized (this) {
return (mLastModified != lastModified || mFileSize != fileSize);
}
}
private void awaitLoadedLocked() {
while (!mLoaded)
try {
wait();
} catch (InterruptedException unused) {
}
}
@Override
public Map<String, ?> getAll() {
synchronized (this) {
awaitLoadedLocked();
return new HashMap<String, Object>(mMap);
}
}
@Override
public String getString(String key, String defValue) {
synchronized (this) {
awaitLoadedLocked();
String v = (String) mMap.get(key);
return v != null ? v : defValue;
}
}
@Override
@SuppressWarnings("unchecked")
public Set<String> getStringSet(String key, Set<String> defValues) {
synchronized (this) {
awaitLoadedLocked();
Set<String> v = (Set<String>) mMap.get(key);
return v != null ? v : defValues;
}
}
@Override
public int getInt(String key, int defValue) {
synchronized (this) {
awaitLoadedLocked();
Integer v = (Integer) mMap.get(key);
return v != null ? v : defValue;
}
}
@Override
public long getLong(String key, long defValue) {
synchronized (this) {
awaitLoadedLocked();
Long v = (Long) mMap.get(key);
return v != null ? v : defValue;
}
}
@Override
public float getFloat(String key, float defValue) {
synchronized (this) {
awaitLoadedLocked();
Float v = (Float) mMap.get(key);
return v != null ? v : defValue;
}
}
@Override
public boolean getBoolean(String key, boolean defValue) {
synchronized (this) {
awaitLoadedLocked();
Boolean v = (Boolean) mMap.get(key);
return v != null ? v : defValue;
}
}
@Override
public boolean contains(String key) {
synchronized (this) {
awaitLoadedLocked();
return mMap.containsKey(key);
}
}
@Override
public Editor edit() {
throw new UnsupportedOperationException("read-only implementation");
}
@Override
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
throw new UnsupportedOperationException("listeners are not supported in this implementation");
}
@Override
public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener) {
throw new UnsupportedOperationException("listeners are not supported in this implementation");
}
}
| 6,134 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XSensorManager.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XSensorManager.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.util.Log;
public class XSensorManager extends XHook {
private Methods mMethod;
private String mClassName;
private static final String cClassName = "android.hardware.SensorManager";
private static final int cMaxRateUs = (int) (0.01 * 1000 * 1000); // 100 Hz
private XSensorManager(Methods method, String restrictionName, String className) {
super(restrictionName, method.name(), null);
mMethod = method;
mClassName = className;
}
public String getClassName() {
return mClassName;
}
// @formatter:off
// public Sensor getDefaultSensor(int type)
// public List<Sensor> getSensorList(int type)
// boolean registerListener(SensorEventListener listener, Sensor sensor, int rateUs, int maxBatchReportLatencyUs)
// boolean registerListener(SensorEventListener listener, Sensor sensor, int rateUs, Handler handler)
// boolean registerListener(SensorEventListener listener, Sensor sensor, int rateUs, int maxBatchReportLatencyUs, Handler handler)
// boolean registerListener(SensorEventListener listener, Sensor sensor, int rateUs)
// frameworks/base/core/java/android/hardware/SensorManager.java
// http://developer.android.com/reference/android/hardware/SensorManager.html
// http://developer.android.com/reference/android/hardware/Sensor.html
// @formatter:on
private enum Methods {
getDefaultSensor, getSensorList, registerListener
};
public static List<XHook> getInstances(String className, boolean server) {
List<XHook> listHook = new ArrayList<XHook>();
if (!cClassName.equals(className)) {
if (className == null)
className = cClassName;
listHook.add(new XSensorManager(Methods.getDefaultSensor, PrivacyManager.cSensors, className));
listHook.add(new XSensorManager(Methods.getSensorList, PrivacyManager.cSensors, className));
listHook.add(new XSensorManager(Methods.registerListener, PrivacyManager.cSensors, className));
}
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case getDefaultSensor:
if (isRestricted(param))
param.setResult(null);
else if (param.args.length > 0 && param.args[0] instanceof Integer)
if (isRestricted(param, (Integer) param.args[0]))
param.setResult(null);
break;
case getSensorList:
if (isRestricted(param))
param.setResult(new ArrayList<Sensor>());
else if (param.args.length > 0 && param.args[0] instanceof Integer)
if (isRestricted(param, (Integer) param.args[0]))
param.setResult(new ArrayList<Sensor>());
break;
case registerListener:
if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) {
int type = ((Sensor) param.args[1]).getType();
if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
int rateUs = (Integer) param.args[2];
// http://developer.android.com/guide/topics/sensors/sensors_overview.html
if (rateUs == SensorManager.SENSOR_DELAY_NORMAL)
return; // 200,000 us
else if (rateUs == SensorManager.SENSOR_DELAY_UI)
return; // 60,000 us
else if (rateUs == SensorManager.SENSOR_DELAY_GAME)
return; // 20,000 us
else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST)
; // 0 us
if (rateUs < cMaxRateUs) // 10,000 us
if (isRestricted(param))
param.args[2] = cMaxRateUs;
}
}
break;
}
}
@Override
@SuppressWarnings("unchecked")
protected void after(XParam param) throws Throwable {
switch (mMethod) {
case getDefaultSensor:
case registerListener:
// Do nothing
break;
case getSensorList:
if (param.getResult() != null && param.args.length > 0 && param.args[0] instanceof Integer)
if ((Integer) param.args[0] == Sensor.TYPE_ALL) {
List<Sensor> listSensor = new ArrayList<Sensor>();
for (Sensor sensor : (List<Sensor>) param.getResult())
if (!isRestricted(param, sensor.getType()))
listSensor.add(sensor);
param.setResult(listSensor);
}
break;
}
}
@SuppressWarnings("deprecation")
private boolean isRestricted(XParam param, int type) throws Throwable {
if (type == Sensor.TYPE_ALL)
return false;
else if (type == Sensor.TYPE_ACCELEROMETER || type == Sensor.TYPE_LINEAR_ACCELERATION) {
if (isRestricted(param, "acceleration"))
return true;
} else if (type == Sensor.TYPE_GRAVITY) {
if (isRestricted(param, "gravity"))
return true;
} else if (type == Sensor.TYPE_RELATIVE_HUMIDITY) {
if (isRestricted(param, "humidity"))
return true;
} else if (type == Sensor.TYPE_LIGHT) {
if (isRestricted(param, "light"))
return true;
} else if (type == Sensor.TYPE_MAGNETIC_FIELD || type == Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED) {
if (isRestricted(param, "magnetic"))
return true;
} else if (type == Sensor.TYPE_SIGNIFICANT_MOTION) {
if (isRestricted(param, "motion"))
return true;
} else if (type == Sensor.TYPE_ORIENTATION || type == Sensor.TYPE_GYROSCOPE
|| type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
if (isRestricted(param, "orientation"))
return true;
} else if (type == Sensor.TYPE_PRESSURE) {
if (isRestricted(param, "pressure"))
return true;
} else if (type == Sensor.TYPE_PROXIMITY) {
if (isRestricted(param, "proximity"))
return true;
} else if (type == Sensor.TYPE_GAME_ROTATION_VECTOR || type == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR
|| type == Sensor.TYPE_ROTATION_VECTOR) {
if (isRestricted(param, "rotation"))
return true;
} else if (type == Sensor.TYPE_TEMPERATURE || type == Sensor.TYPE_AMBIENT_TEMPERATURE) {
if (isRestricted(param, "temperature"))
return true;
} else if (type == Sensor.TYPE_STEP_COUNTER || type == Sensor.TYPE_STEP_DETECTOR) {
if (isRestricted(param, "step"))
return true;
} else if (type == Sensor.TYPE_HEART_RATE) {
if (isRestricted(param, "heartrate"))
return true;
} else if (type == 22) {
// 22 = TYPE_TILT_DETECTOR
// Do nothing
} else if (type == 23 || type == 24 || type == 25) {
// 23 = TYPE_WAKE_GESTURE
// 24 = TYPE_GLANCE_GESTURE
// 25 = TYPE_PICK_UP_GESTURE
// 23/24 This sensor is expected to only be used by the system ui
// 25 Expected to be used internally for always on display
} else
Util.log(this, Log.WARN, "Unknown sensor type=" + type);
return false;
}
}
| 6,492 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
XInputDevice.java | /FileExtraction/Java_unseen/M66B_XPrivacy/src/biz/bokhorst/xprivacy/XInputDevice.java | package biz.bokhorst.xprivacy;
import java.util.ArrayList;
import java.util.List;
import android.os.Binder;
public class XInputDevice extends XHook {
private Methods mMethod;
private XInputDevice(Methods method, String restrictionName) {
super(restrictionName, method.name(), "InputDevice." + method.name());
mMethod = method;
}
public String getClassName() {
return "android.view.InputDevice";
}
// @formatter:off
// public String getDescriptor()
// public String getName()
// frameworks/base/core/java/android/view/InputDevice.java
// http://developer.android.com/reference/android/view/InputDevice.html
// @formatter:on
private enum Methods {
getDescriptor, getName
};
public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XInputDevice(Methods.getDescriptor, PrivacyManager.cIdentification));
listHook.add(new XInputDevice(Methods.getName, PrivacyManager.cIdentification));
return listHook;
}
@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case getDescriptor:
case getName:
if (isRestricted(param))
param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "DeviceDescriptor"));
break;
}
}
@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
| 1,347 | Java | .java | M66B/XPrivacy | 2,074 | 527 | 71 | 2013-05-26T14:08:37Z | 2019-09-05T19:16:53Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.