version:1.8
fix:应用使用记录 add:
This commit is contained in:
@@ -4,8 +4,10 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.TTUtils.APKUtils;
|
||||
import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -33,7 +35,7 @@ public class HTTPInterface {
|
||||
private static final String TAG = HTTPInterface.class.getSimpleName();
|
||||
|
||||
public static void getAppPasswd() {
|
||||
NetWorkManager.getInstance().getAppPasswordObservable()
|
||||
NetworkManager.getInstance().getAppPasswordObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppPasswdBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -66,7 +68,7 @@ public class HTTPInterface {
|
||||
}
|
||||
|
||||
synchronized public static void setJpushTags(final Context context) {
|
||||
NetWorkManager.getInstance()
|
||||
NetworkManager.getInstance()
|
||||
.getJpushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -115,6 +117,38 @@ public class HTTPInterface {
|
||||
});
|
||||
}
|
||||
|
||||
public static void SendRunningApp(Context context) {
|
||||
String packageName = TimeUtils.getInstance().getAppPackageName();
|
||||
long time = TimeUtils.getInstance().getStartTime();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", packageName);
|
||||
jsonObject.addProperty("version_name", APKUtils.getAPPVersionName(context, packageName));
|
||||
jsonObject.addProperty("run_time", time / 1000);
|
||||
String jsonString = jsonObject.toString();
|
||||
NetworkManager.getInstance().getRunningAppObservable(jsonString)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("SendRunningApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("SendRunningApp", "onSubscribe: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("SendRunningApp", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("SendRunningApp", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setTag(Context context, Set set) {
|
||||
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||
tagAliasBean.action = ACTION_SET;
|
||||
|
||||
@@ -5,10 +5,12 @@ import android.os.Environment;
|
||||
|
||||
import com.aoleyun.os.TTUtils.Utils;
|
||||
import com.aoleyun.os.network.api.AddAppLog;
|
||||
import com.aoleyun.os.network.api.AppUsageRecordApi;
|
||||
import com.aoleyun.os.network.api.CheckUpdate;
|
||||
import com.aoleyun.os.network.api.GetAppPassword;
|
||||
import com.aoleyun.os.network.api.GetJpushTagsApi;
|
||||
import com.aoleyun.os.network.api.RunningApp;
|
||||
import com.aoleyun.os.network.api.SendScreenshotApi;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -25,12 +27,12 @@ import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class NetWorkManager {
|
||||
private static NetWorkManager sInstance;
|
||||
public class NetworkManager {
|
||||
private static NetworkManager sInstance;
|
||||
private Context mContext;
|
||||
private static Retrofit mRetrofit;
|
||||
|
||||
private NetWorkManager(Context context) {
|
||||
private NetworkManager(Context context) {
|
||||
this.mContext = context;
|
||||
if (null == mRetrofit) {
|
||||
mRetrofit = new Retrofit.Builder()
|
||||
@@ -44,12 +46,12 @@ public class NetWorkManager {
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new NetWorkManager(context);
|
||||
sInstance = new NetworkManager(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static NetWorkManager getInstance() {
|
||||
public static NetworkManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init NetworkManager first");
|
||||
}
|
||||
@@ -80,7 +82,7 @@ public class NetWorkManager {
|
||||
|
||||
public Observable<BaseResponse> getRunningAppObservable(String json) {
|
||||
return mRetrofit.create(RunningApp.class)
|
||||
.sendAppInfo(Utils.getSerial(), json)
|
||||
.sendRunningInfo(Utils.getSerial(), json)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
@@ -92,6 +94,14 @@ public class NetWorkManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public SendScreenshotApi getScreenshotApi() {
|
||||
return mRetrofit.create(SendScreenshotApi.class);
|
||||
}
|
||||
|
||||
public AddAppLog getapplogControl() {
|
||||
return mRetrofit.create(AddAppLog.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取极光推送的tag
|
||||
*
|
||||
@@ -104,8 +114,10 @@ public class NetWorkManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public AddAppLog getapplogControl() {
|
||||
return mRetrofit.create(AddAppLog.class);
|
||||
|
||||
|
||||
public AppUsageRecordApi getAppUsageRecordControl() {
|
||||
return mRetrofit.create(AppUsageRecordApi.class);
|
||||
}
|
||||
|
||||
public CheckUpdate getCheckUpdateObservable() {
|
||||
@@ -3,7 +3,7 @@ package com.aoleyun.os.network;
|
||||
public class URLPath {
|
||||
public static final String ROOT_URL = "https://led.aoleyun.cn/api/";
|
||||
public static final String APP_LOG = "app/addAppLog";
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
public static final String RUN_NEW_APP = "And/runNewApp";
|
||||
//更新
|
||||
public final static String GET_NEWESTAPPUPDATE = "Silent/silent";
|
||||
//是否有应用密码锁
|
||||
@@ -14,7 +14,10 @@ public class URLPath {
|
||||
public final static String GET_APP_PASSWD = "And/getApplicationLock";
|
||||
//获取设备标签
|
||||
public static final String GET_DEVICES_TAGS = "Sn/getSnTag";
|
||||
|
||||
//发送app使用时长
|
||||
public static final String SEND_APP_RECORD = "And/appUsageRecord";
|
||||
//上传截图
|
||||
public static final String SEND_SCREENSHOT = "Screenshot/addImg";
|
||||
|
||||
//删除alias
|
||||
public static final String DELETE_JPUSH_ALIAS = "https://device.jpush.cn/v3/aliases/";
|
||||
|
||||
22
src/com/aoleyun/os/network/api/AppUsageRecordApi.java
Normal file
22
src/com/aoleyun/os/network/api/AppUsageRecordApi.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.aoleyun.os.network.api;
|
||||
|
||||
import com.aoleyun.os.network.BaseResponse;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AppUsageRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(value = URLPath.SEND_APP_RECORD)
|
||||
Observable<BaseResponse> sendAppUsageRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_name") String app_name,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("open_time") long open_time,
|
||||
@Field("close_time") long close_time
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import retrofit2.http.POST;
|
||||
public interface RunningApp {
|
||||
@FormUrlEncoded
|
||||
@POST(URLPath.RUN_NEW_APP)
|
||||
Observable<BaseResponse> sendAppInfo(
|
||||
Observable<BaseResponse> sendRunningInfo(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
);
|
||||
|
||||
22
src/com/aoleyun/os/network/api/SendScreenshotApi.java
Normal file
22
src/com/aoleyun/os/network/api/SendScreenshotApi.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.aoleyun.os.network.api;
|
||||
|
||||
import com.aoleyun.os.network.BaseResponse;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface SendScreenshotApi {
|
||||
@Multipart
|
||||
@POST(URLPath.SEND_SCREENSHOT)
|
||||
Observable<BaseResponse> sendScreenshot(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user