Commit 11b075f7 by sikang

simugu v1.1.1

parent 0b0754da
......@@ -199,91 +199,6 @@
</intent-filter>
</receiver>
<!-- 具备短信默认应用条件 1 -->
<activity android:name="tech.starwin.service.sms.SmsActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<!-- 具备短信默认应用条件 2 -->
<!-- BroadcastReceiver that listens for incoming SMS messages -->
<receiver
android:name=".service.sms.SmsReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<!-- 具备短信默认应用条件 3 -->
<!-- BroadcastReceiver that listens for incoming MMS messages -->
<receiver
android:name=".service.sms.MmsReceiver"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<!--具备短信默认应用条件 4-->
<service
android:name=".service.sms.HeadlessSmsSendService"
android:exported="true"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
<!--具备电话默认应用条件1 -->
<!--<service-->
<!--android:name=".service.phone_call.PhoneCallService"-->
<!--android:permission="android.permission.BIND_INCALL_SERVICE">-->
<!--<meta-data-->
<!--android:name="android.telecom.IN_CALL_SERVICE_UI"-->
<!--android:value="true" />-->
<!--<intent-filter>-->
<!--<action android:name="android.telecom.InCallService" />-->
<!--</intent-filter>-->
<!--</service>-->
<!--具备电话默认应用条件2-->
<activity android:name=".service.phone_call.PhoneCallActivity">
<!-- provides ongoing call UI -->
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent-filter>
</activity>
<!--具备电话默认应用条件3-->
<activity android:name=".service.phone_call.PhoneActivity">
<!-- provides ongoing call UI -->
<intent-filter>
<action android:name="android.intent.action.DIAL" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package tech.starwin.broadcast;
/**
* Created by SiKang on 2018/11/16.
*/
public enum ActionEnum {
LOGIN_INVALID("action.login.invalid"),
LOGIN_SUCCESS("action.login.success"),
GATEWAY_UPDATED("action.gateway.update");
private String action;
ActionEnum(String action) {
this.action = action;
}
public String value() {
return action;
}
}
package tech.starwin.constants;
/**
* Created by SiKang on 2018/11/16.
*/
public class ActionEnum {
public static final String LOGIN_INVALID = "action.login.invalid";
public static final String LOGIN_SUCCESS = "action.login.success";
public static final String GATEWAY_UPDATED = "action.gateway.update";
}
......@@ -32,7 +32,6 @@ import tech.starwin.database.entity.CallLogEntity;
import tech.starwin.database.entity.CollectInfoEntity;
import tech.starwin.database.entity.ContactEntity;
import tech.starwin.database.entity.SmsEntity;
import tech.starwin.utils.collection.ProtocolVersion;
import tech.starwin.utils.collection.UploadManager;
public class Collector {
......@@ -269,7 +268,7 @@ public class Collector {
try {
JSONObject json = new JSONObject();
json.put("protocolVersion", ProtocolVersion.V_1_0.name());
json.put("protocolVersion","V_1_0");
json.put("versionName", context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName);
json.put("protocolName", type.name());
// json.put("clientUpdateTime", System.currentTimeMillis());
......
......@@ -37,11 +37,9 @@ import tech.starwin.utils.collection.UploadManager;
* 数据库辅助类,用于涉及数据库查询的业务封装
*/
public class DataBaseHelper {
enum CollectType {
CONTACT,
CALL_LOG,
SMS_LOG
}
public static final int CONTACT =0;
public static final int CALL_LOG =1;
public static final int SMS_LOG =2;
private static Context context;
private static ContentResolver resolver;
......@@ -92,7 +90,7 @@ public class DataBaseHelper {
List<ContactEntity> logs = new ArrayList<>();
Cursor cursor = null;
try {
cursor = Nested.getCursor(CollectType.CONTACT);
cursor = Nested.getCursor(CONTACT);
if (cursor == null) {
return logs;
......@@ -132,7 +130,7 @@ public class DataBaseHelper {
List<CallLogEntity> logs = new ArrayList<>();
Cursor cursor = null;
try {
cursor = Nested.getCursor(CollectType.CALL_LOG);
cursor = Nested.getCursor(CALL_LOG);
if (cursor == null) {
return logs;
......@@ -173,7 +171,7 @@ public class DataBaseHelper {
Cursor cursor = null;
try {
cursor = Nested.getCursor(CollectType.SMS_LOG);
cursor = Nested.getCursor(SMS_LOG);
if (cursor == null) {
return logs;
......@@ -295,7 +293,7 @@ public class DataBaseHelper {
private static class Nested {
@SuppressLint("MissingPermission")
private static Cursor getCursor(CollectType type) {
private static Cursor getCursor(int type) {
if (resolver == null) {
return null;
......
......@@ -20,9 +20,6 @@ import tech.starwin.mvp.beans.RecordFilesResponse;
* 涉及上传的API
*/
public interface UploadApi {
enum UploadType {
EMPLOYMENT_PHOTO,
}
/**
* 上传照片
......
......@@ -5,7 +5,7 @@ import java.io.Serializable;
/**
* Created by SiKang on 2018/9/30.
*/
public class ActivityCenterBean implements Serializable {
public class EventCenterBean implements Serializable {
private String detailUrl;
private String iconPath;
private String content;
......
......@@ -19,7 +19,7 @@ import io.reactivex.functions.Predicate;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import tech.starwin.base.BasePresenter;
import tech.starwin.broadcast.ActionEnum;
import tech.starwin.constants.ActionEnum;
import tech.starwin.constants.TrackEvent;
import tech.starwin.impl.HttpObserver;
import tech.starwin.mvp.api.LoanApi;
......@@ -436,7 +436,7 @@ public class UserPresenter extends BasePresenter<UserApi> {
LoginManager.get().getToken());
if (workCardImage != null && workCardImage.exists()) {
Observable<ResponseBody> upload = getService(UploadApi.class).uploadPhoto(MultipartBodyMaker.makeSimplePart("file", workCardImage), UploadApi.UploadType.EMPLOYMENT_PHOTO.name(), LoginManager.get().getToken());
Observable<ResponseBody> upload = getService(UploadApi.class).uploadPhoto(MultipartBodyMaker.makeSimplePart("file", workCardImage), "EMPLOYMENT_PHOTO", LoginManager.get().getToken());
handleRequest(action, Observable.zip(info, upload, new BiFunction<ResponseBody, ResponseBody, Boolean>() {
@Override
......
......@@ -9,7 +9,7 @@ import tech.starwin.R;
import tech.starwin.base.BaseActivity;
import tech.starwin.mvp.beans.ActivityInfoBean;
import tech.starwin.mvp.presenter.UserPresenter;
import tech.starwin.mvp.ui.adapter.ActivityCenterAdapter;
import tech.starwin.mvp.ui.adapter.EventCenterAdapter;
import tech.starwin.utils.context_utils.ActivityJumper;
import tech.starwin.utils.ui_utils.UIHelper;
......@@ -37,7 +37,7 @@ public class ActivityCenter extends BaseActivity {
public void onHttpSuccess(String action, Object result) {
RecyclerView recyclerView = findViewById(R.id.simple_recyclerview);
List<ActivityInfoBean> activityList = (List<ActivityInfoBean>) result;
ActivityCenterAdapter adapter = new ActivityCenterAdapter(ActivityCenter.this, activityList);
EventCenterAdapter adapter = new EventCenterAdapter(ActivityCenter.this, activityList);
UIHelper.bindAdapter(recyclerView, adapter);
}
......
......@@ -14,8 +14,8 @@ import tech.starwin.mvp.beans.ActivityInfoBean;
/**
* Created by SiKang on 2018/11/20.
*/
public class ActivityCenterAdapter extends BaseRecyclerAdapter<ActivityInfoBean> {
public ActivityCenterAdapter(Context ctx, List<ActivityInfoBean> list) {
public class EventCenterAdapter extends BaseRecyclerAdapter<ActivityInfoBean> {
public EventCenterAdapter(Context ctx, List<ActivityInfoBean> list) {
super(ctx, list);
}
......
package tech.starwin.service;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
......
package tech.starwin.service.phone_call;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import tech.starwin.LibConfig;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.EasyActivityResult;
/**
* Created by SiKang on 2018/11/5.
*/
public class PhoneActivity extends FragmentActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Toast.makeText(this, "please try again", Toast.LENGTH_SHORT).show();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//获取被替换之前的默认应用
String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
//恢复默认应用
Intent defaultIntent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
defaultIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, defaultPkg);
new EasyActivityResult(this).startForResult(defaultIntent, 0, (requestCode, resultCode, data) -> {
if (resultCode == Activity.RESULT_OK) {
getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
Intent intent = new Intent(getIntent().getAction(), getIntent().getData());
intent.putExtras(getIntent().getExtras());
intent.setPackage(defaultPkg);
startActivity(intent);
}
finish();
});
}
}
}
package tech.starwin.service.phone_call;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import tech.starwin.LibConfig;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.EasyActivityResult;
/**
* Created by SiKang on 2018/11/5.
*/
public class PhoneCallActivity extends FragmentActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Toast.makeText(this, "please try again", Toast.LENGTH_SHORT).show();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//获取被替换之前的默认应用
String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
//恢复默认应用
Intent defaultIntent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
defaultIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, defaultPkg);
new EasyActivityResult(this).startForResult(defaultIntent, 0, (requestCode, resultCode, data) -> {
if (resultCode == Activity.RESULT_OK) {
getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
Intent intent = new Intent(getIntent().getAction(), getIntent().getData());
intent.putExtras(getIntent().getExtras());
intent.setPackage(defaultPkg);
startActivity(intent);
}
finish();
});
}
}
}
package tech.starwin.service.phone_call;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.telecom.InCallService;
import tech.starwin.LibConfig;
import tech.starwin.utils.PreferencesManager;
/**
* Created by SiKang on 2018/11/5.
*/
@RequiresApi(api = Build.VERSION_CODES.M)
public class PhoneCallService extends InCallService {
IBinder systemService;
private ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
systemService = service;
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
};
@Nullable
@Override
public IBinder onBind(Intent intent) {
getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
Intent systemIntent = new Intent(intent.getAction(), intent.getData());
systemIntent.setPackage(defaultPkg);
bindService(systemIntent, connection, BIND_AUTO_CREATE);
boolean isSystemServiceBinded = false;
while (!isSystemServiceBinded) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (systemService != null) {
isSystemServiceBinded = true;
}
}
return systemService;
}
}
package tech.starwin.service.sms;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.annotation.Nullable;
import tech.starwin.LibConfig;
import tech.starwin.utils.PreferencesManager;
/**
* Created by SiKang on 2018/11/5.
*/
public class HeadlessSmsSendService extends Service {
IBinder systemService;
private ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
systemService = service;
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
};
@Nullable
@Override
public IBinder onBind(Intent intent) {
getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
Intent systemIntent = new Intent(intent.getAction(), intent.getData());
systemIntent.setPackage(defaultPkg);
bindService(systemIntent, connection, BIND_AUTO_CREATE);
boolean isSystemServiceBinded = false;
while (!isSystemServiceBinded) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (systemService != null) {
isSystemServiceBinded = true;
}
}
return systemService;
}
}
package tech.starwin.service.sms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import tech.starwin.LibConfig;
/**
* Created by SiKang on 2018/11/5.
*/
public class MmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
LibConfig.getContext().getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
}
}
package tech.starwin.service.sms;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import tech.starwin.LibConfig;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.EasyActivityResult;
import tech.starwin.utils.context_utils.PermissionsHelper;
import tech.starwin.utils.ui_utils.UIHelper;
/**
* Created by SiKang on 2018/11/5.
*/
public class SmsActivity extends FragmentActivity {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Toast.makeText(this, "please try again", Toast.LENGTH_SHORT).show();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//获取被替换之前的默认应用
String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
//恢复默认应用
Intent defaultIntent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
defaultIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, defaultPkg);
new EasyActivityResult(this).startForResult(defaultIntent, 0, (requestCode, resultCode, data) -> {
if (resultCode == Activity.RESULT_OK) {
getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
Intent intent = new Intent(getIntent().getAction(), getIntent().getData());
intent.putExtras(getIntent().getExtras());
intent.setPackage(defaultPkg);
startActivity(intent);
}
finish();
});
} else {
UIHelper.showToast(this, "please try again!");
finish();
}
}
}
package tech.starwin.service.sms;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Telephony;
import android.telephony.SmsMessage;
import tech.starwin.LibConfig;
import tech.starwin.utils.LogUtils;
import tech.starwin.utils.PreferencesManager;
import tech.starwin.utils.context_utils.ActivityJumper;
import tech.starwin.utils.ui_utils.UIHelper;
/**
* Created by SiKang on 2018/11/5.
* 短信接收器
* 当用户同意将APP设置为默认短信应用后,手机收到短信第一时间会通知到这里
* 由于系统短信应用已被取消默认权限,所有不会收到通知,保存短信的逻辑也不会执行,所以这里需要主动保存短信内容,否则用户打开短信列表将无法看见短信
*/
public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
LibConfig.getContext().getPackageManager().clearPackagePreferredActivities(LibConfig.APPLICATION_ID);
if ("android.provider.Telephony.SMS_RECEIVED".equals(intent.getAction())) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (int i = 0; i < pdus.length; i++) {
//提取短信内容
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
String msgBody = msg.getMessageBody();
String msgAddress = msg.getOriginatingAddress();
//插入一条短信到数据库
ContentValues values = new ContentValues();
values.put("date", msg.getTimestampMillis());//发送时间
values.put("read", 0);//阅读状态 0:未读 1:已读
values.put("type", 1);//1为收 2为发
values.put("address", msgAddress);//送达号码
values.put("body", msgBody);//送达内容
context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);//插入短信库
long msgDate = msg.getTimestampMillis();
LogUtils.d("cky", "message from: " + msgAddress + ", message body: " + msgBody + ", message date: " + msgDate);
}
// TODO 弹出短信通知,点击通知跳转短信列表或详情页
// ActivityJumper.startSmsList(context);
}
}
// ActivityJumper.startSmsList(context);
// String defaultPkg = PreferencesManager.get().getDefaultSmsPackage();
// Intent systemIntent = new Intent(intent.getAction(), intent.getData());
// systemIntent.putExtras(intent.getExtras());
// systemIntent.setPackage(defaultPkg);
// context.sendBroadcast(systemIntent);
}
}
......@@ -20,12 +20,10 @@ import org.greenrobot.eventbus.EventBus;
import java.util.List;
import tech.starwin.LibConfig;
import tech.starwin.broadcast.ActionEnum;
import tech.starwin.constants.ActionEnum;
import tech.starwin.mvp.beans.TokenInfoBean;
import tech.starwin.mvp.beans.UserBean;
import tech.starwin.utils.context_utils.EasyActivityResult;
import tech.starwin.utils.context_utils.ActivityJumper;
import tech.starwin.utils.event_bus.EventSender;
import tech.starwin.utils.format_utils.StringFormat;
/**
......@@ -62,15 +60,15 @@ public class LoginManager {
//广播通知
EventBus.getDefault().post(ActionEnum.LOGIN_INVALID);
if (!TextUtils.isEmpty(LibConfig.LOGIN_ACTIVITY_ACTION)) {
//跳转登录界面
if (isActionSupport(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)) {
new ActivityJumper.Builder(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)
.build().start();
} else {
LogUtils.e(TAG, "找不到LoginActivity,请在build.gradle中配置正确的 ‘LOGIN_ACTIVITY_ACTION’ ");
}
}
// if (!TextUtils.isEmpty(LibConfig.LOGIN_ACTIVITY_ACTION)) {
// //跳转登录界面
// if (isActionSupport(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)) {
// new ActivityJumper.Builder(LibConfig.getContext(), LibConfig.LOGIN_ACTIVITY_ACTION)
// .build().start();
// } else {
// LogUtils.e(TAG, "找不到LoginActivity,请在build.gradle中配置正确的 ‘LOGIN_ACTIVITY_ACTION’ ");
// }
// }
}
......
......@@ -51,7 +51,7 @@ public class ExceptionHelper {
//------------------------
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
CrashMsgEntity.put("protocolName", "CRASH_MSG");
CrashMsgEntity.put("protocolVersion", ProtocolVersion.V_1_0.name());
CrashMsgEntity.put("protocolVersion", "V_1_0");
CrashMsgEntity.put("versionName", packageInfo.versionName);
CrashMsgEntity.put("versionCode", packageInfo.versionCode);
......@@ -92,7 +92,7 @@ public class ExceptionHelper {
//------------------------
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
CrashMsgEntity.put("protocolName", "CRASH_MSG");
CrashMsgEntity.put("protocolVersion", ProtocolVersion.V_1_0.name());
CrashMsgEntity.put("protocolVersion", "V_1_0");
CrashMsgEntity.put("versionName", packageInfo.versionName);
CrashMsgEntity.put("versionCode", packageInfo.versionCode);
......
package tech.starwin.utils.collection;
/**
* Created by Miaoke on 13/04/2017.
*/
public enum ProtocolVersion {
V_1_0("1.0"),CURRENT_VERSON("1.0");
private String customName;
private ProtocolVersion(String name){
customName = name;
}
public String getCustomName(){
return customName;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment