version:8.5

fix:
update:接口优化,固定横屏,取消地图
This commit is contained in:
2023-02-06 19:06:41 +08:00
parent a2ef127a4d
commit f8b3d96ced
30 changed files with 618 additions and 695 deletions

View File

@@ -27,9 +27,9 @@
<!-- 允许访问网络,必选权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 允许获取精确位置,精准定位必选 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
<!-- 允许获取粗略位置,粗略定位必选 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->
<!-- 允许获取设备和运营商信息用于问题排查和网络定位无gps情况下的定位若需网络定位功能则必选 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 允许获取网络状态用于网络定位无gps情况下的定位若需网络定位功能则必选 -->
@@ -39,9 +39,9 @@
<!-- 允许获取wifi状态改变用于网络定位无gps情况下的定位若需网络定位功能则必选 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!-- 后台获取位置信息,若需后台定位则必选 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
<!-- 用于申请调用A-GPS模块,卫星定位加速 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />-->
<!-- 允许写设备缓存,用于问题排查 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- 允许写入扩展存储,用于写入缓存定位数据 -->
@@ -81,6 +81,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".activity.main.MainActivity"
android:screenOrientation="userLandscape"
android:clearTaskOnLaunch="true"
android:enabled="true"
android:excludeFromRecents="true"
@@ -102,7 +103,7 @@
</activity>
<activity android:name=".activity.contact.ContactActivity" />
<activity
android:name=".activity.code.HealthCodeActivity"
android:name=".activity.code.FamilySpaceActivity"
android:launchMode="singleTask"
android:screenOrientation="sensorPortrait" />
<activity
@@ -174,16 +175,16 @@
</intent-filter>
</service>
<!-- 声明service组件 -->
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
<!-- &lt;!&ndash; 声明service组件 &ndash;&gt;-->
<!-- <service-->
<!-- android:name="com.baidu.location.f"-->
<!-- android:enabled="true"-->
<!-- android:process=":remote" />-->
<!-- 应用的其它配置 -->
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<!-- &lt;!&ndash; 应用的其它配置 &ndash;&gt;-->
<!-- <uses-library-->
<!-- android:name="org.apache.http.legacy"-->
<!-- android:required="false" />-->
<activity
android:name="com.tencent.android.tpush.TpnsActivity"

View File

@@ -0,0 +1,31 @@
// IGetInfoInterface.aidl
package com.uiui.sn;
// Declare any non-default types here with import statements
interface IGetInfoInterface {
/**
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
double aDouble, String aString);
//获取sn
String getSerial();
//获取用户信息
String getUserInfo();
//获取隐藏APP
List<String> getHideAPP();
//获取禁止打开的APP
List<String> getForbidAPP();
//获取app设置
String getAppTimeControl();
//获取整机设置
String getSnTimeControl();
//获取系统设置
String getSetting();
//获取定位结果
String getMapResult();
}

View File

@@ -18,8 +18,8 @@ import com.tencent.mmkv.MMKV;
import com.uiui.aios.R;
import com.uiui.aios.bean.BaseResponse;
import com.uiui.aios.bean.Contact;
import com.uiui.aios.config.CommonConfig;
import com.uiui.aios.disklrucache.CacheHelper;
import com.uiui.aios.manager.AmapManager;
import com.uiui.aios.network.NetInterfaceManager;
import com.uiui.aios.network.URLAddress;
import com.uiui.aios.receiver.BootReceiver;
@@ -28,7 +28,6 @@ import com.uiui.aios.utils.ToastUtil;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import butterknife.BindView;
@@ -41,12 +40,13 @@ import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
public class EmergencyActivity extends AppCompatActivity {
private static final String TAG = EmergencyActivity.class.getSimpleName();
@BindView(R.id.tv_countdown)
TextView tv_countdown;
@BindView(R.id.iv_finish)
ImageView iv_finish;
private Disposable subscribe;
private String TAG = EmergencyActivity.class.getSimpleName();
private boolean needDial = false;
private boolean isCalling = false;
private List<Contact> phoneListSet;
@@ -98,9 +98,9 @@ public class EmergencyActivity extends AppCompatActivity {
Log.e(TAG, "accept: " + (time - aLong - 1));
} else {
MMKV mmkv = MMKV.defaultMMKV();
String longitude = mmkv.decodeString(AmapManager.LONGITUDE_KEY, "未知");
String latitude = mmkv.decodeString(AmapManager.LATITUDE_KEY, "未知");
String address = mmkv.decodeString(AmapManager.ADDRESS_KEY, "未知");
String longitude = mmkv.decodeString(CommonConfig.MAP_LONGITUDE_KEY, "未知");
String latitude = mmkv.decodeString(CommonConfig.MAP_LATITUDE_KEY, "未知");
String address = mmkv.decodeString(CommonConfig.MAP_ADDRESS_KEY, "未知");
NetInterfaceManager.getInstance()
.getSOSRecordObservable(longitude, latitude, address)
.subscribe(new Observer<BaseResponse>() {
@@ -162,10 +162,13 @@ public class EmergencyActivity extends AppCompatActivity {
@Override
protected void onStart() {
super.onStart();
Log.e(TAG, "onResume: ");
Log.e(TAG, "onResume: " + phoneListSet);
Log.e(TAG, "onStart: ");
Log.e(TAG, "onStart: " + phoneListSet);
if (needDial) {
if (phoneListSet == null || phoneListSet.size() == 0) return;
if (phoneListSet == null || phoneListSet.size() == 0) {
finish();
return;
}
Handler.getMain().postDelayed(new Runnable() {
@Override
public void run() {

View File

@@ -23,29 +23,30 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class HealthCodeActivity extends BaseActivity implements HealthCodeContact.CodeView {
public class FamilySpaceActivity extends BaseActivity implements FamilySpaceContact.CodeView {
@BindView(R.id.iv_back)
ImageView iv_back;
@BindView(R.id.viewPager)
ViewPager mViewPager;
@BindView(R.id.magicIndicator)
MagicIndicator mMagicIndicator;
@BindView(R.id.iv_nodata)
ImageView iv_nodata;
@BindView(R.id.iv_back)
ImageView iv_back;
private HealthCodePresenter mPresenter;
private FamilySpacePresenter mPresenter;
private HealthCodeAdapter mHealthCodeAdapter;
private ScaleCircleNavigator scaleCircleNavigator;
@Override
public int getLayoutId() {
return R.layout.activity_code;
return R.layout.activity_family_space;
}
@Override
public void initView() {
ButterKnife.bind(this);
mPresenter = new HealthCodePresenter(this);
mPresenter = new FamilySpacePresenter(this);
mPresenter.attachView(this);
mPresenter.setLifecycle(lifecycleSubject);
iv_back.setOnClickListener(new View.OnClickListener() {

View File

@@ -6,7 +6,7 @@ import com.uiui.aios.bean.HealthCode;
import java.util.List;
public class HealthCodeContact {
public class FamilySpaceContact {
public interface Presenter extends BasePresenter<CodeView> {
void getHealthCode();
}

View File

@@ -2,22 +2,20 @@ package com.uiui.aios.activity.code;
import android.content.Context;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.uiui.aios.bean.HealthCode;
import com.uiui.aios.network.NetInterfaceManager;
import com.uiui.aios.utils.ToastUtil;
import java.util.List;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
public class HealthCodePresenter implements HealthCodeContact.Presenter {
private static final String TAG = HealthCodePresenter.class.getSimpleName();
private HealthCodeContact.CodeView mView;
public class FamilySpacePresenter implements FamilySpaceContact.Presenter {
private static final String TAG = FamilySpacePresenter.class.getSimpleName();
private FamilySpaceContact.CodeView mView;
private Context mContext;
@@ -31,14 +29,14 @@ public class HealthCodePresenter implements HealthCodeContact.Presenter {
return lifecycle;
}
HealthCodePresenter(Context context) {
FamilySpacePresenter(Context context) {
this.mContext = context;
Log.e(TAG, "MainPresenter: " + context.getClass());
}
@Override
public void attachView(@NonNull HealthCodeContact.CodeView view) {
public void attachView(@NonNull FamilySpaceContact.CodeView view) {
this.mView = view;
}

View File

@@ -10,7 +10,9 @@ import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.provider.Settings;
import android.text.TextUtils;
@@ -100,20 +102,16 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
mMainPresenter.attachView(this);
mMainPresenter.setLifecycle(lifecycleSubject);
if (BuildConfig.DEBUG) {
Log.e(TAG, "initView: " + this.getClass().getName());
// SystemClock.setCurrentTimeMillis(1662123600000L);//09-02
// SystemClock.setCurrentTimeMillis(1662210000000L);//09-03
}
mFragmentManager = getSupportFragmentManager();
// mFragmentTransaction = mFragmentManager.beginTransaction();
mFragments = new ArrayList<>();
mBaseFragmentPagerAdapter = new BaseFragmentPagerAdapter(mFragmentManager, mFragments);
// fragmentTransaction.add(R.id.viewPager, appListFragment);
// fragmentTransaction.commit();
mControlFragment = new ControlFragment();
mFragments.add(mControlFragment);
is_twoscreen = Settings.Global.getInt(getContentResolver(), "is_twoscreen", 0) == 1;
if (is_twoscreen) {
appListIndex = 3;
@@ -121,12 +119,12 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
mSecondFragment = new SecondFragment();
mFragments.add(mSecondFragment);
}
mCustomFragment = new CustomFragment();
mFragments.add(mCustomFragment);
mMainPresenter.getSystemSettings();
// mMainPresenter.getAdminSnSetting();
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
int x = 0;
for (int i = 0; i <= desktopIcons.size(); i++) {
if (i != 0 && i % APP_LIST_SIZE == 0) {
@@ -153,7 +151,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
});
mViewPager.setAdapter(mBaseFragmentPagerAdapter);
mViewPager.setOffscreenPageLimit(5);
mViewPager.setOffscreenPageLimit(3);
mMagicIndicator.setNavigator(scaleCircleNavigator);
ViewPagerHelper.bind(mMagicIndicator, mViewPager);
if (mFragments.size() > 1) {
@@ -255,6 +253,16 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {//表示渲染结束
addData();
}
}
private final static int APP_LIST_SIZE = 3 * 4;
private void addData() {
@@ -326,6 +334,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.e(TAG, "onConfigurationChanged: ");
}
@Override
@@ -341,6 +350,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
protected void onResume() {
super.onResume();
Log.e(TAG, "onResume: ");
Log.e(TAG, "onResume: " + System.currentTimeMillis());
int agree = mMMKV.decodeInt("AgreePrivacyPolicy", 0);
if (agree == 0) {
showPolicyDialog();
@@ -385,7 +395,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
privacyPolicyDialog.show();
}
private void addHomeWatcher() {
if (mHomeWatcher == null) {
mHomeWatcher = new HomeWatcher(this);
@@ -476,6 +485,20 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
}
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
Log.e(TAG, "onSaveInstanceState: ");
Log.e(TAG, "onSaveInstanceState: " + System.currentTimeMillis());
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.e(TAG, "onRestoreInstanceState: ");
Log.e(TAG, "onRestoreInstanceState: " + System.currentTimeMillis());
}
@Override
protected void onStop() {
super.onStop();
@@ -498,12 +521,13 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
}
}
private void registmNewAppReceiver() {
mNewAppReceiver = new NewAppReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
// filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addDataScheme("package");
@@ -519,7 +543,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
Log.e(TAG, "onReceive: " + action);
if (Intent.ACTION_PACKAGE_ADDED.equals(action)
|| Intent.ACTION_PACKAGE_REMOVED.equals(action)
|| Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
// || Intent.ACTION_PACKAGE_CHANGED.equals(action)
) {
addData();
}
}

View File

@@ -19,9 +19,11 @@ import com.uiui.aios.utils.Utils;
import java.util.List;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
public class MainPresenter implements MainContact.Presenter {
@@ -122,12 +124,15 @@ public class MainPresenter implements MainContact.Presenter {
if (!TextUtils.isEmpty(packagename)) {
Log.e(TAG, "onRestart: " + ApkUtils.getAppNameByPackage(mContext, packagename));
Log.e(TAG, "onRestart: " + packagename);
NetInterfaceManager.getInstance().getAppUsageRecordControl()
NetInterfaceManager.getInstance()
.getAppUsageRecordControl()
.sendappUsageRecord(Utils.getSerial(),
ApkUtils.getAppNameByPackage(mContext, packagename),
packagename,
AppUsedTimeUtils.getInstance().getStartTime() / 1000,
AppUsedTimeUtils.getInstance().getEndTime() / 1000)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse>() {
@Override
@@ -171,6 +176,8 @@ public class MainPresenter implements MainContact.Presenter {
Log.e(TAG, "sendRunningInfo: " + jsonString);
NetInterfaceManager.getInstance()
.getRunningAppObservable(jsonString)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse>() {
@Override

View File

@@ -13,6 +13,7 @@ import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.uiui.aios.R;
import com.uiui.aios.adapter.WeatherDayApdapter;
import com.uiui.aios.base.BaseActivity;
import com.uiui.aios.manager.RemoteManager;
import com.uiui.aios.view.HorizontalItemDecoration;
import butterknife.BindView;
@@ -40,6 +41,7 @@ public class WeatherActivity extends BaseActivity implements WeatherContact.Weat
mPresenter = new WeatherPresenter(this);
mPresenter.attachView(this);
mPresenter.setLifecycle(lifecycleSubject);
RemoteManager.getInstance().getLocation();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
Resources resources = getResources();
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {

View File

@@ -5,14 +5,13 @@ import android.util.Log;
import androidx.annotation.NonNull;
import com.baidu.location.BDLocation;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.qweather.sdk.bean.weather.WeatherDailyBean;
import com.qweather.sdk.view.QWeather;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.uiui.aios.manager.AmapManager;
import com.uiui.aios.manager.RemoteManager;
import java.lang.reflect.Type;
@@ -58,11 +57,7 @@ public class WeatherPresenter implements WeatherContact.Presenter {
@Override
public void getLocation() {
BDLocation bdLocation = AmapManager.getInstance().getNowMapLocation();
String location = "未知";
if (bdLocation != null) {
location = bdLocation.getCity() + "\t" + bdLocation.getDistrict();
}
String location = RemoteManager.getInstance().getCityDistrict();
mView.setLocation(location);
}
@@ -78,7 +73,7 @@ public class WeatherPresenter implements WeatherContact.Presenter {
@Override
public void getWeather() {
QWeather.getWeather7D(mContext, AmapManager.getInstance().getLocation(), new QWeather.OnResultWeatherDailyListener() {
QWeather.getWeather7D(mContext, RemoteManager.getInstance().getLocationTude(), new QWeather.OnResultWeatherDailyListener() {
@Override
public void onError(Throwable throwable) {
Log.e("getWeather", "onError: " + throwable.getMessage());

View File

@@ -21,6 +21,7 @@ import java.util.List;
public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.Holder> {
private static final String TAG = AppSelectedAdapter.class.getSimpleName();
private Context mContext;
private List<AppSelectBean> mAppSelectBeans;
private int unselectedStatus = -1;

View File

@@ -14,8 +14,8 @@ import com.tencent.android.tpush.XGPushManager;
import com.tencent.mmkv.MMKV;
import com.uiui.aios.BuildConfig;
import com.uiui.aios.alarm.AlarmUtils;
import com.uiui.aios.manager.AmapManager;
import com.uiui.aios.manager.ConnectManager;
import com.uiui.aios.manager.RemoteManager;
import com.uiui.aios.network.NetInterfaceManager;
import com.uiui.aios.service.main.MainService;
import com.uiui.aios.utils.AppUsedTimeUtils;
@@ -51,7 +51,7 @@ public class BaseApplication extends Application {
HeConfig.init("HE2206151627491952", "03125bfee8934cf4b640af48e8187c9d");
//切换至开发版服务
HeConfig.switchToDevService();
AmapManager.init(this);
RemoteManager.init(this);
ConnectManager.init(this);
NetInterfaceManager.init(this);
startService(new Intent(this, MainService.class));

View File

@@ -0,0 +1,134 @@
package com.uiui.aios.bean;
import java.io.Serializable;
public class MapBean implements Serializable {
private static final long serialVersionUID = -4356064111098876676L;
double longitude;
double latitude;
String adcode;
String address;
String city;
String cityCode;
String country;
String countryCode;
String district;
String province;
String street;
String streetNumber;
String town;
String locationDescribe;
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public String getAdcode() {
return adcode;
}
public void setAdcode(String adcode) {
this.adcode = adcode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCountryCode() {
return countryCode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getStreetNumber() {
return streetNumber;
}
public void setStreetNumber(String streetNumber) {
this.streetNumber = streetNumber;
}
public String getTown() {
return town;
}
public void setTown(String town) {
this.town = town;
}
public String getLocationDescribe() {
return locationDescribe;
}
public void setLocationDescribe(String locationDescribe) {
this.locationDescribe = locationDescribe;
}
}

View File

@@ -9,4 +9,10 @@ public class CommonConfig {
public static final String UIUI_CODE_TYPE_KEY = "uiui_code_type";
/*体验到期时间戳*/
public static final String UIUI_EXPIRE_TIME_KEY = "uiui_expire_time";
public static final String MAP_LOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
public static final String MAP_LONGITUDE_KEY = "map_longitude_key";
public static final String MAP_LATITUDE_KEY = "map_latitude_key";
public static final String MAP_ADDRESS_KEY = "map_address_key";
public static final String MAP_ERROR_KEY = "map_error_key";
}

View File

@@ -22,7 +22,7 @@ import com.google.gson.JsonObject;
import com.trello.rxlifecycle4.RxLifecycle;
import com.trello.rxlifecycle4.android.FragmentEvent;
import com.uiui.aios.R;
import com.uiui.aios.activity.code.HealthCodeActivity;
import com.uiui.aios.activity.code.FamilySpaceActivity;
import com.uiui.aios.base.BaseFragment;
import com.uiui.aios.bean.BaseResponse;
import com.uiui.aios.bean.DesktopIcon;
@@ -195,7 +195,7 @@ public class AppListFragment extends BaseFragment {
}
break;
case "aios.family":
startActivity(new Intent(mContext, HealthCodeActivity.class));
startActivity(new Intent(mContext, FamilySpaceActivity.class));
break;
case "com.android.dialer":
int qch_call_forbid = Settings.System.getInt(mContext.getContentResolver(), "qch_call_forbid", 0);

View File

@@ -33,12 +33,11 @@ import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.tencent.mmkv.MMKV;
import com.uiui.aios.R;
import com.uiui.aios.config.CommonConfig;
import com.uiui.aios.disklrucache.CacheHelper;
import com.uiui.aios.manager.AmapManager;
import com.uiui.aios.manager.RemoteManager;
import com.uiui.aios.utils.BrightnessUtils;
import com.uiui.aios.view.RulerSeekBar;
@@ -748,43 +747,17 @@ public class ControlFragment extends Fragment {
}, 1999);
}
private LocationClient locationClient;
private void getLocation() {
String addr = mCacheHelper.getAsString(AmapManager.ADDRESS_KEY);
String addr = MMKV.defaultMMKV().decodeString(CommonConfig.MAP_ADDRESS_KEY);
if (TextUtils.isEmpty(addr)) {
tv_location.setText("未知");
} else {
tv_location.setText(addr);
}
startLocation();
cl_location.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startLocation();
}
});
}
private void startLocation() {
if (locationClient == null) {
locationClient = AmapManager.getInstance().getLocationClient();
}
locationClient.stop();
locationClient.start();
locationClient.registerLocationListener(new BDAbstractLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
switch (bdLocation.getLocType()) {
case BDLocation.TypeGpsLocation:// GPS定位结果
case BDLocation.TypeNetWorkLocation:// 网络定位结果
case BDLocation.TypeOffLineLocation:// 离线定位结果
tv_location.setText(bdLocation.getAddrStr());
break;
default:
tv_location.setText("定位失败");
break;
}
RemoteManager.getInstance().getLocation();
}
});
}

View File

@@ -9,6 +9,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
@@ -25,14 +26,12 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.blankj.utilcode.util.NetworkUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -49,10 +48,9 @@ import com.uiui.aios.R;
import com.uiui.aios.activity.EmergencyActivity;
import com.uiui.aios.activity.QuickAppActivity;
import com.uiui.aios.activity.alarm.AlarmClockActivity;
import com.uiui.aios.activity.code.HealthCodeActivity;
import com.uiui.aios.activity.code.FamilySpaceActivity;
import com.uiui.aios.activity.contact.ContactActivity;
import com.uiui.aios.activity.weather.WeatherActivity;
import com.uiui.aios.adapter.NotificationAdapter;
import com.uiui.aios.adapter.SOSNnmberAdapter;
import com.uiui.aios.base.BaseFragment;
import com.uiui.aios.bean.AlarmClockData;
@@ -64,7 +62,7 @@ import com.uiui.aios.bean.UserAvatarInfo;
import com.uiui.aios.config.CommonConfig;
import com.uiui.aios.dialog.SingleDialog;
import com.uiui.aios.disklrucache.CacheHelper;
import com.uiui.aios.manager.AmapManager;
import com.uiui.aios.manager.RemoteManager;
import com.uiui.aios.network.NetInterfaceManager;
import com.uiui.aios.network.URLAddress;
import com.uiui.aios.tpush.MessageReceiver;
@@ -180,6 +178,28 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
private String mParam1;
private String mParam2;
@Override
public void onDisconnected() {
// wifi_ssid.setText("WiFi未连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
if (networkType == NetworkUtils.NetworkType.NETWORK_WIFI) {
// wifi_ssid.setText(getConnectWifiSsid());
} else {
// wifi_ssid.setText("WiFi未连接");
}
}
private String getConnectWifiSsid() {
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Log.d("wifiInfo", wifiInfo.toString());
Log.d("SSID", wifiInfo.getSSID());
return wifiInfo.getSSID();
}
public CustomFragment() {
// Required empty public constructor
}
@@ -216,155 +236,20 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
mParam2 = getArguments().getString(ARG_PARAM2);
}
mMMKV = MMKV.defaultMMKV();
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
public void fetchData() {
Log.e(TAG, "fetchData: ");
RemoteManager.getInstance().getLocation();
initData();
}
@Override
public void onDisconnected() {
// wifi_ssid.setText("WiFi未连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
if (networkType == NetworkUtils.NetworkType.NETWORK_WIFI) {
// wifi_ssid.setText(getConnectWifiSsid());
} else {
// wifi_ssid.setText("WiFi未连接");
}
}
private String getConnectWifiSsid() {
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Log.d("wifiInfo", wifiInfo.toString());
Log.d("SSID", wifiInfo.getSSID());
return wifiInfo.getSSID();
}
/**
* 检查wifi是否处开连接状态
*
* @return
*/
public boolean isWifiConnect() {
ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return mWifiInfo.isConnected();
}
private RefreshBroadcastReceiver mRefreshBroadcastReceiver;
private void registerRefreshReceiver() {
if (mRefreshBroadcastReceiver == null) {
mRefreshBroadcastReceiver = new RefreshBroadcastReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(QuickAppActivity.QUICK_APP_REFRESH_KEY);
mContext.registerReceiver(mRefreshBroadcastReceiver, filter);
}
class RefreshBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
setQuickApp();
}
}
private void registerAlarmClockReceiver() {
if (null == mAlarmClockReceiver) {
mAlarmClockReceiver = new AlarmClockReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(MessageReceiver.SET_ALARMCLOCK);
mContext.registerReceiver(mAlarmClockReceiver, filter);
}
private AlarmClockReceiver mAlarmClockReceiver;
private class AlarmClockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive: " + action);
if (MessageReceiver.SET_ALARMCLOCK.equals(action)) {
Handler.getMain().postDelayed(new Runnable() {
@Override
public void run() {
mCustomPresenter.getAlarmClock();
}
}, 3456);
}
}
}
private void registerBatteryReceiver() {
if (null == batteryReceiver) {
batteryReceiver = new BatteryReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(Intent.ACTION_BATTERY_LOW);
filter.addAction(Intent.ACTION_BATTERY_OKAY);
filter.addAction(Intent.ACTION_POWER_CONNECTED);
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
mContext.registerReceiver(batteryReceiver, filter);
}
private BatteryReceiver batteryReceiver;
private class BatteryReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
// 当前电量
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
// 最大电量
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
int elec = (level * 100) / scale;
Log.i(TAG, "electricity:=" + elec + "%");
// tv_battery.setText(elec + "%");
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|| Intent.ACTION_BATTERY_LOW.equals(action)
|| Intent.ACTION_BATTERY_OKAY.equals(action)
) {
}
}
}
private BroadcastReceiver mbatteryReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "onReceive: " + action);
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
if (rootView != null) {
// iv_charging.setVisibility(View.VISIBLE);
}
} else {
if (rootView != null) {
// iv_charging.setVisibility(View.GONE);
}
}
}
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
@@ -545,6 +430,17 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
refreshMemory();
}
/**
* 检查wifi是否处开连接状态
*
* @return
*/
public boolean isWifiConnect() {
ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return mWifiInfo.isConnected();
}
private void showExpired() {
SingleDialog dialog = new SingleDialog(mContext);
dialog.setTitle("温馨提示")
@@ -805,28 +701,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
}
private void initAmap() {
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
locationClient.stop();
locationClient.start();
locationClient.registerLocationListener(new BDAbstractLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
Log.e(TAG, "onReceiveLocation: ");
switch (bdLocation.getLocType()) {
case BDLocation.TypeGpsLocation:// GPS定位结果
case BDLocation.TypeNetWorkLocation:// 网络定位结果
case BDLocation.TypeOffLineLocation:// 离线定位结果
String city = bdLocation.getCity();
tv_location.setText(city);
getweather(bdLocation.getLongitude(), bdLocation.getLatitude());
break;
default:
BDLocation location = AmapManager.getInstance().getNowMapLocation();
getweather(location.getLongitude(), location.getLatitude());
break;
}
}
});
String city = RemoteManager.getInstance().getCity();
tv_location.setText(city);
getweather(RemoteManager.getInstance().getLongitude(), RemoteManager.getInstance().getLatitude());
}
private void getAlarm() {
@@ -871,7 +748,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
NetInterfaceManager.getInstance().getHealthCode(new NetInterfaceManager.HealthCodeCallback() {
@Override
public void setHealthCode(List<HealthCode> healthCode) {
startActivity(new Intent(mContext, HealthCodeActivity.class));
startActivity(new Intent(mContext, FamilySpaceActivity.class));
}
@Override
@@ -999,6 +876,111 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
float x2 = (((total - avail) / (float) total));
}
private RefreshBroadcastReceiver mRefreshBroadcastReceiver;
private void registerRefreshReceiver() {
if (mRefreshBroadcastReceiver == null) {
mRefreshBroadcastReceiver = new RefreshBroadcastReceiver();
}
IntentFilter filter = new IntentFilter();
filter.addAction(QuickAppActivity.QUICK_APP_REFRESH_KEY);
mContext.registerReceiver(mRefreshBroadcastReceiver, filter);
}
class RefreshBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "onReceive: " + intent.getAction());
setQuickApp();
}
}
private void registerAlarmClockReceiver() {
if (null == mAlarmClockReceiver) {
mAlarmClockReceiver = new AlarmClockReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(MessageReceiver.SET_ALARMCLOCK);
mContext.registerReceiver(mAlarmClockReceiver, filter);
}
private AlarmClockReceiver mAlarmClockReceiver;
private class AlarmClockReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e(TAG, "onReceive: " + action);
if (MessageReceiver.SET_ALARMCLOCK.equals(action)) {
Handler.getMain().postDelayed(new Runnable() {
@Override
public void run() {
mCustomPresenter.getAlarmClock();
}
}, 3456);
}
}
}
private void registerBatteryReceiver() {
if (null == batteryReceiver) {
batteryReceiver = new BatteryReceiver();
}
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(Intent.ACTION_BATTERY_LOW);
filter.addAction(Intent.ACTION_BATTERY_OKAY);
filter.addAction(Intent.ACTION_POWER_CONNECTED);
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
mContext.registerReceiver(batteryReceiver, filter);
}
private BatteryReceiver batteryReceiver;
private class BatteryReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
// 当前电量
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
// 最大电量
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
int elec = (level * 100) / scale;
Log.i(TAG, "electricity:=" + elec + "%");
// tv_battery.setText(elec + "%");
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|| Intent.ACTION_BATTERY_LOW.equals(action)
|| Intent.ACTION_BATTERY_OKAY.equals(action)
) {
}
}
}
private BroadcastReceiver mbatteryReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "onReceive: " + action);
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
if (rootView != null) {
// iv_charging.setVisibility(View.VISIBLE);
}
} else {
if (rootView != null) {
// iv_charging.setVisibility(View.GONE);
}
}
}
}
};
/**
* 时间

View File

@@ -1,410 +0,0 @@
package com.uiui.aios.manager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.mmkv.MMKV;
import com.uiui.aios.disklrucache.CacheHelper;
import com.uiui.aios.utils.GsonUtils;
import java.lang.reflect.Type;
public class AmapManager {
private static final String TAG = AmapManager.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static AmapManager sInstance;
private Context mContext;
@SuppressLint("StaticFieldLeak")
private LocationClient mLocationClient = null;
private LocationClientOption mOption;
private BDLocation mLocation;
private CacheHelper mCacheHelper;
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
public static final String LONGITUDE_KEY = "map_longitude_key";
public static final String LATITUDE_KEY = "map_latitude_key";
public static final String ADDRESS_KEY = "map_address_key";
public static final String ERROR_KEY = "map_error_key";
private AmapManager(Context context) {
this.mContext = context;
this.mCacheHelper = new CacheHelper(context);
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
initAmap();
}
public static void init(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
if (sInstance == null) {
sInstance = new AmapManager(context);
}
}
public static AmapManager getInstance() {
if (sInstance == null) {
throw new IllegalStateException("You must be init AmapManager first");
}
return sInstance;
}
public void initAmap() {
if (mLocationClient == null) {
mLocationClient = new LocationClient(mContext);
}
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
mLocationClient.setLocOption(getDefaultLocationClientOption());
mLocationClient.registerLocationListener(mListener);
mLocationClient.stop();
mLocationClient.start();
}
public LocationClient getLocationClient() {
if (mLocationClient == null) {
initAmap();
}
return mLocationClient;
}
public BDLocation getNowMapLocation() {
if (mLocation == null) {
String aMapLocationjson = SPUtils.getInstance().getString(AMAPLOCATION_JSON_KEY);
if (TextUtils.isEmpty(aMapLocationjson)) {
return null;
}
Type type = new TypeToken<BDLocation>() {
}.getType();
try {
BDLocation bdLocation = new Gson().fromJson(aMapLocationjson, type);
return bdLocation;
} catch (Exception e) {
Log.e(TAG, "getNowMapLocation: " + e.getMessage());
return null;
}
}
return this.mLocation;
}
public String getLocation() {
BDLocation bdLocation = getNowMapLocation();
if (bdLocation == null) {
return "0,0";
} else {
String location = bdLocation.getLongitude() + "," + bdLocation.getLatitude();
Log.e(TAG, "getLocation: " + location);
return location;
}
}
/***
*
* @return DefaultLocationClientOption 默认O设置
*/
public LocationClientOption getDefaultLocationClientOption() {
if (mOption == null) {
mOption = new LocationClientOption();
mOption.setCoorType("bd09ll"); // 可选默认gcj02设置返回的定位结果坐标系如果配合百度地图使用建议设置为bd09ll;
mOption.setScanSpan(0); // 可选默认0即仅定位一次设置发起连续定位请求的间隔需要大于等于1000ms才是有效的
mOption.setIsNeedAddress(true); // 可选,设置是否需要地址信息,默认不需要
mOption.setIsNeedLocationDescribe(true); // 可选,设置是否需要地址描述
mOption.setNeedDeviceDirect(false); // 可选,设置是否需要设备方向结果
mOption.setLocationNotify(false); // 可选默认false设置是否当gps有效时按照1S1次频率输出GPS结果
mOption.setIgnoreKillProcess(true); // 可选默认true定位SDK内部是一个SERVICE并放到了独立进程设置是否在stop
mOption.setIsNeedLocationDescribe(true); // 可选默认false设置是否需要位置语义化结果可以在BDLocation
mOption.setIsNeedLocationPoiList(true); // 可选默认false设置是否需要POI结果可以在BDLocation
mOption.SetIgnoreCacheException(false); // 可选默认false设置是否收集CRASH信息默认收集
mOption.setLocationMode(LocationClientOption.LocationMode.Battery_Saving); // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备,模糊
mOption.setIsNeedAltitude(false); // 可选默认false设置定位时是否需要海拔信息默认不需要除基础定位版本都可用
// 可选,设置首次定位时选择定位速度优先还是定位准确性优先,默认为速度优先
// mOption.setFirstLocType(LocationClientOption.FirstLocType.SPEED_IN_FIRST_LOC);
}
return mOption;
}
/*****
*
* 定位结果回调重写onReceiveLocation方法可以直接拷贝如下代码到自己工程中修改
*
*/
private BDAbstractLocationListener mListener = new BDAbstractLocationListener() {
/**
* 定位请求回调函数
* @param location 定位结果
*/
@Override
public void onReceiveLocation(BDLocation location) {
if (null != location) {
switch (location.getLocType()) {
case BDLocation.TypeGpsLocation:// GPS定位结果
case BDLocation.TypeNetWorkLocation:// 网络定位结果
case BDLocation.TypeOffLineLocation:// 离线定位结果
SPUtils.getInstance().put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
Log.e(TAG, "onLocationChanged: " + "定位成功");
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
Log.e(TAG, "onLocationChanged: " + location.getAddrStr() + location.getLocationDescribe());
mCacheHelper.put(ADDRESS_KEY, location.getAddrStr() + location.getLocationDescribe());
mCacheHelper.put(LONGITUDE_KEY, location.getLongitude());
mCacheHelper.put(LATITUDE_KEY, location.getLatitude());
mCacheHelper.put(ERROR_KEY, "-");
break;
case BDLocation.TypeServerError:
Log.e(TAG, "onReceiveLocation: " + "服务端网络定位失败");
mCacheHelper.put(ERROR_KEY, "服务端网络定位失败可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com会有人追查原因");
break;
case BDLocation.TypeNetWorkException:
Log.e(TAG, "onReceiveLocation: " + "网络不同导致定位失败,请检查网络是否通畅");
mCacheHelper.put(ERROR_KEY, "网络不同导致定位失败,请检查网络是否通畅");
break;
case BDLocation.TypeCriteriaException:
Log.e(TAG, "onReceiveLocation: " + "无法获取有效定位依据导致定位失败");
mCacheHelper.put(ERROR_KEY, "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
break;
default:
}
}
// if (null != location && location.getLocType() != BDLocation.TypeServerError) {
// StringBuffer sb = new StringBuffer(256);
// sb.append("time : ");
// /**
// * 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间;
// * location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变
// */
// sb.append(location.getTime());
// sb.append("\nsysTime : ");
// sb.append(SystemClock.elapsedRealtime());
// sb.append("\nlocType : ");// 定位类型
// sb.append(location.getLocType());
// sb.append("\nlocType description : ");// *****对应的定位类型说明*****
// sb.append(location.getLocTypeDescription());
// sb.append("\nlatitude : ");// 纬度
// sb.append(location.getLatitude());
// sb.append("\nlongtitude : ");// 经度
// sb.append(location.getLongitude());
// sb.append("\nradius : ");// 半径
// sb.append(location.getRadius());
// sb.append("\nCountryCode : ");// 国家码
// sb.append(location.getCountryCode());
// sb.append("\nProvince : ");// 获取省份
// sb.append(location.getProvince());
// sb.append("\nCountry : ");// 国家名称
// sb.append(location.getCountry());
// sb.append("\ncitycode : ");// 城市编码
// sb.append(location.getCityCode());
// sb.append("\ncity : ");// 城市
// sb.append(location.getCity());
// sb.append("\nDistrict : ");// 区
// sb.append(location.getDistrict());
// sb.append("\nTown : ");// 获取镇信息
// sb.append(location.getTown());
// sb.append("\nStreet : ");// 街道
// sb.append(location.getStreet());
// sb.append("\naddr : ");// 地址信息
// sb.append(location.getAddrStr());
// sb.append("\nStreetNumber : ");// 获取街道号码
// sb.append(location.getStreetNumber());
// sb.append("\nUserIndoorState: ");// *****返回用户室内外判断结果*****
// sb.append(location.getUserIndoorState());
// sb.append("\nDirection(not all devices have value): ");
// sb.append(location.getDirection());// 方向
// sb.append("\nlocationdescribe: ");
// sb.append(location.getLocationDescribe());// 位置语义化信息
// sb.append("\nPoi: ");// POI信息
// if (location.getPoiList() != null && !location.getPoiList().isEmpty()) {
// for (int i = 0; i < location.getPoiList().size(); i++) {
// Poi poi = (Poi) location.getPoiList().get(i);
// sb.append("poiName:");
// sb.append(poi.getName() + ", ");
// sb.append("poiTag:");
// sb.append(poi.getTags() + "\n");
// }
// }
// if (location.getPoiRegion() != null) {
// sb.append("PoiRegion: ");// 返回定位位置相对poi的位置关系仅在开发者设置需要POI信息时才会返回在网络不通或无法获取时有可能返回null
// PoiRegion poiRegion = location.getPoiRegion();
// sb.append("DerectionDesc:"); // 获取POIREGION的位置关系ex:"内"
// sb.append(poiRegion.getDerectionDesc() + "; ");
// sb.append("Name:"); // 获取POIREGION的名字字符串
// sb.append(poiRegion.getName() + "; ");
// sb.append("Tags:"); // 获取POIREGION的类型
// sb.append(poiRegion.getTags() + "; ");
// sb.append("\nSDK版本: ");
// }
//// int permission = checkPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION);
//// sb.append("\npermsission: " + permission);
//// sb.append(locationService.getSDKVersion()); // 获取SDK版本
// if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位结果
// sb.append("\nspeed : ");
// sb.append(location.getSpeed());// 速度 单位km/h
// sb.append("\nsatellite : ");
// sb.append(location.getSatelliteNumber());// 卫星数目
// sb.append("\nheight : ");
// sb.append(location.getAltitude());// 海拔高度 单位:米
// sb.append("\ngps status : ");
// sb.append(location.getGpsAccuracyStatus());// *****gps质量判断*****
// sb.append("\ndescribe : ");
// sb.append("gps定位成功");
// } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果
// // 运营商信息
// if (location.hasAltitude()) {// *****如果有海拔高度*****
// sb.append("\nheight : ");
// sb.append(location.getAltitude());// 单位:米
// }
// sb.append("\noperationers : ");// 运营商信息
// sb.append(location.getOperators());
// sb.append("\ndescribe : ");
// sb.append("网络定位成功");
// } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
// sb.append("\ndescribe : ");
// sb.append("离线定位成功,离线定位结果也是有效的");
// } else if (location.getLocType() == BDLocation.TypeServerError) {
// sb.append("\ndescribe : ");
// sb.append("服务端网络定位失败可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com会有人追查原因");
// } else if (location.getLocType() == BDLocation.TypeNetWorkException) {
// sb.append("\ndescribe : ");
// sb.append("网络不同导致定位失败,请检查网络是否通畅");
// } else if (location.getLocType() == BDLocation.TypeCriteriaException) {
// sb.append("\ndescribe : ");
// sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
// }
//// logMsg(sb.toString(), tag);
// Log.e(TAG, "onReceiveLocation: " + sb);
// }
Log.e(TAG, "AmapAddress: " + mCacheHelper.getAsString(ADDRESS_KEY));
Log.e(TAG, "AmapError: " + mCacheHelper.getAsString(ERROR_KEY));
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-network");
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-gps");
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0);
}
@Override
public void onConnectHotSpotMessage(String s, int i) {
super.onConnectHotSpotMessage(s, i);
}
/**
* 回调定位诊断信息,开发者可以根据相关信息解决定位遇到的一些问题
* @param locType 当前定位类型
* @param diagnosticType 诊断类型1~9
* @param diagnosticMessage 具体的诊断信息释义
*/
@Override
public void onLocDiagnosticMessage(int locType, int diagnosticType, String diagnosticMessage) {
super.onLocDiagnosticMessage(locType, diagnosticType, diagnosticMessage);
// int tag = 2;
StringBuffer sb = new StringBuffer(256);
sb.append("诊断结果: ");
if (locType == BDLocation.TypeNetWorkLocation) {
if (diagnosticType == 1) {
sb.append("网络定位成功没有开启GPS建议打开GPS会更好");
sb.append("\n" + diagnosticMessage);
} else if (diagnosticType == 2) {
sb.append("网络定位成功没有开启Wi-Fi建议打开Wi-Fi会更好");
sb.append("\n" + diagnosticMessage);
}
} else if (locType == BDLocation.TypeOffLineLocationFail) {
if (diagnosticType == 3) {
sb.append("定位失败,请您检查您的网络状态");
sb.append("\n" + diagnosticMessage);
}
} else if (locType == BDLocation.TypeCriteriaException) {
if (diagnosticType == 4) {
sb.append("定位失败,无法获取任何有效定位依据");
sb.append("\n" + diagnosticMessage);
} else if (diagnosticType == 5) {
sb.append("定位失败无法获取有效定位依据请检查运营商网络或者Wi-Fi网络是否正常开启尝试重新请求定位");
sb.append(diagnosticMessage);
} else if (diagnosticType == 6) {
sb.append("定位失败无法获取有效定位依据请尝试插入一张sim卡或打开Wi-Fi重试");
sb.append("\n" + diagnosticMessage);
} else if (diagnosticType == 7) {
sb.append("定位失败,飞行模式下无法获取有效定位依据,请关闭飞行模式重试");
sb.append("\n" + diagnosticMessage);
} else if (diagnosticType == 9) {
sb.append("定位失败,无法获取任何有效定位依据");
sb.append("\n" + diagnosticMessage);
}
} else if (locType == BDLocation.TypeServerError) {
if (diagnosticType == 8) {
sb.append("定位失败请确认您定位的开关打开状态是否赋予APP定位权限");
sb.append("\n" + diagnosticMessage);
}
}
Log.e(TAG, "onLocationChanged: " + "定位失败");
mCacheHelper.put(ERROR_KEY, sb.toString());
Log.e(TAG, "onLocDiagnosticMessage: " + sb);
// logMsg(sb.toString(), tag);
}
};
// public AMapLocationClient getLocationClient() {
// if (null == locationClient) {
// initAmap();
// }
// return locationClient;
// }
// public void initAmap() {
// locationClient = new AMapLocationClient(mContext);
// AMapLocationClientOption option = new AMapLocationClientOption();
// option.setLocationPurpose(AMapLocationClientOption.AMapLocationPurpose.SignIn);
// option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
// option.setNeedAddress(true);
// //获取一次定位结果:
// //该方法默认为false。
// option.setOnceLocation(true);
// //获取最近3s内精度最高的一次定位结果
// //设置setOnceLocationLatest(boolean b)接口为true启动定位时SDK会返回最近3s内精度最高的一次定位结果。
// // 如果设置其为truesetOnceLocation(boolean b)接口也会被设置为true反之不会默认为false。
// option.setOnceLocationLatest(true);
// locationClient.setLocationOption(option);
// //设置定位模式为AMapLocationMode.Hight_Accuracy高精度模式。
// //设置定位监听
// locationClient.setLocationListener(new AMapLocationListener() {
//
// @Override
// public void onLocationChanged(AMapLocation aMapLocation) {
// StringBuilder sb = new StringBuilder();
// //errCode等于0代表定位成功其他的为定位失败具体的可以参照官网定位错误码说明
// if (aMapLocation.getErrorCode() == 0) {
// Log.e(TAG, "onLocationChanged: " + "定位成功");
// Log.e(TAG, "onLocationChanged: " + aMapLocation.getAddress());
// sb.append(aMapLocation.getAddress()).append("\n");
// mMMKV.encode( ADDRESS_KEY, aMapLocation.getAddress());
// mMMKV.encode( LONGITUDE_KEY, aMapLocation.getLongitude());
// mMMKV.encode( LATITUDE_KEY, aMapLocation.getLatitude());
// mMMKV.encode( ERROR_KEY, "");
// } else {
// //定位失败
// sb.append("定位失败" + "\n");
// Log.e(TAG, "onLocationChanged: " + "定位失败");
// mMMKV.encode( ERROR_KEY, String.valueOf(aMapLocation.getErrorInfo()));
// }
// Log.e(TAG, (String) SPUtils.get(mContext, ADDRESS_KEY, "-"));
// Log.e(TAG, (String) SPUtils.get(mContext, ERROR_KEY, "-"));
// Log.e(TAG, "amap: " + sb.toString());
// }
// });
// //设置场景模式后最好调用一次stop再调用start以保证场景模式生效
// locationClient.stopLocation();
// locationClient.startLocation();
// Log.e(TAG, "initAmap: " + "startLocation");
// }
}

View File

@@ -0,0 +1,165 @@
package com.uiui.aios.manager;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.mmkv.MMKV;
import com.uiui.aios.bean.MapBean;
import com.uiui.aios.config.CommonConfig;
import com.uiui.aios.disklrucache.CacheHelper;
import com.uiui.sn.IGetInfoInterface;
import java.lang.reflect.Type;
public class RemoteManager {
private static final String TAG = RemoteManager.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static RemoteManager sInstance;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private CacheHelper mCacheHelper;
private IGetInfoInterface getInfoInterface;
private ServiceConnection mIGetInfoConnection;
private RemoteManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.mCacheHelper = new CacheHelper(context);
mIGetInfoConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
getLocation();
}
@Override
public void onServiceDisconnected(ComponentName name) {
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
getInfoInterface = null;
bindInfoService();
}
};
bindInfoService();
}
public static void init(Context context) {
if (sInstance == null) {
Log.e(TAG, "init: ");
sInstance = new RemoteManager(context);
}
}
public static RemoteManager getInstance() {
if (sInstance == null) {
throw new IllegalStateException("You must be init RemoteManager first");
}
return sInstance;
}
private void bindInfoService() {
if (getInfoInterface == null) {
//这是连接aidl服务的代码
Intent intent = new Intent();
intent.setAction("com.uiui.sn.IGetInfoInterface");
intent.setPackage("com.uiui.sn");
intent.setComponent(new ComponentName("com.uiui.sn", "com.uiui.sn.service.RemoteService"));
mContext.bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
}
}
public void getLocation() {
if (getInfoInterface != null) {
try {
String jsonString = getInfoInterface.getMapResult();
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString);
} catch (Exception e) {
Log.e(TAG, "getMapResult: " + e.getMessage());
}
} else {
bindInfoService();
}
}
public MapBean getMapBean() {
String jsonString = mMMKV.decodeString(CommonConfig.MAP_LOCATION_JSON_KEY);
if (TextUtils.isEmpty(jsonString)) {
return null;
} else {
Gson gson = new Gson();
Type type = new TypeToken<MapBean>() {
}.getType();
MapBean mapBean = gson.fromJson(jsonString, type);
mMMKV.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress() + mapBean.getLocationDescribe());
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
return mapBean;
}
}
public String getCity() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return "北京";
} else {
return mapBean.getCity();
}
}
public String getCityDistrict() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return "北京";
} else {
return mapBean.getCity() + "\t" + mapBean.getDistrict();
}
}
public double getLongitude() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return 0.0;
} else {
return mapBean.getLongitude();
}
}
public double getLatitude() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return 0.0;
} else {
return mapBean.getLatitude();
}
}
public String getLocationTude() {
MapBean mapBean = getMapBean();
if (mapBean == null) {
getLocation();
return "0.0";
} else {
return mapBean.getLongitude() + "," + mapBean.getLatitude();
}
}
}

View File

@@ -182,7 +182,7 @@ public class NetInterfaceManager {
public Observable<BaseResponse<List<AlarmClockData>>> getAlarmClockObservable() {
return mRetrofit
.create(AlarmClockApi.class)
.getAlarmClockApiApi(Utils.getSerial())
.getAlarmClock(Utils.getSerial())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}

View File

@@ -12,7 +12,7 @@ import retrofit2.http.Query;
public interface AlarmClockApi {
@GET(URLAddress.GET_ALARM_CLOCK)
Observable<BaseResponse<List<AlarmClockData>>> getAlarmClockApiApi(
Observable<BaseResponse<List<AlarmClockData>>> getAlarmClock(
@Query("sn") String sn
);
}

View File

@@ -70,11 +70,10 @@ public class BootReceiver extends BroadcastReceiver {
default:
break;
case BOOT_COMPLETED:
NetInterfaceManager.getInstance().getAlarmClock();
Intent alarmIntent = new Intent(MessageReceiver.SET_ALARMCLOCK);
context.sendBroadcast(alarmIntent);
// NetInterfaceManager.getInstance().getAlarmClock();
// Intent alarmIntent = new Intent(MessageReceiver.SET_ALARMCLOCK);
// context.sendBroadcast(alarmIntent);
case Intent.ACTION_BOOT_COMPLETED:
break;
case Intent.ACTION_BATTERY_CHANGED:
case Intent.ACTION_BATTERY_LOW:

View File

@@ -50,8 +50,7 @@ import okhttp3.RequestBody;
public class MainService extends BaseService implements MainSContact.MainSView, NetworkUtils.OnNetworkStatusChangedListener {
private static final String TAG = MainService.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
public static MainSPresenter mPresenter;
public MainSPresenter mPresenter;
public MainService() {
@@ -64,7 +63,9 @@ public class MainService extends BaseService implements MainSContact.MainSView,
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
mPresenter.getAlarmClock();
if (isScreenOn()) {
mPresenter.getAlarmClock();
}
}
@Override
@@ -73,7 +74,6 @@ public class MainService extends BaseService implements MainSContact.MainSView,
return null;
}
@Override
public void onCreate() {
super.onCreate();
@@ -117,6 +117,12 @@ public class MainService extends BaseService implements MainSContact.MainSView,
}
public boolean isScreenOn() {
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
//true为打开false为关闭
return powerManager.isInteractive();
}
public static final String ALARMWAKEUP = "ALARM_WAKEUP";
private void registerAlarmReceiver() {
@@ -417,7 +423,7 @@ public class MainService extends BaseService implements MainSContact.MainSView,
@Download.onTaskComplete
void taskComplete(DownloadTask task) {
//在这里处理任务完成的状态
Log.e(TAG, "taskComplete: "+task.getFilePath() );
Log.e(TAG, "taskComplete: " + task.getFilePath());
}
@Download.onTaskFail

View File

@@ -16,6 +16,7 @@ import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import com.uiui.aios.network.NetInterfaceManager;
import com.uiui.aios.service.main.MainService;
import com.uiui.aios.tpush.common.NotificationService;
import com.uiui.aios.tpush.po.XGNotification;
@@ -309,6 +310,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
switch (title) {
case JIGUANG_ALARM_CLOCK:
ToastUtil.betaShow("收到推送消息: 设置闹钟");
NetInterfaceManager.getInstance().getAlarmClock();
Intent intent = new Intent(SET_ALARMCLOCK);
mContext.sendBroadcast(intent);
break;

View File

@@ -231,7 +231,7 @@ public class ApkUtils {
}
}
DesktopIcon familyIcon = new DesktopIcon();
familyIcon.setIcon(context.getDrawable(R.drawable.family_space));
familyIcon.setIcon(context.getDrawable(R.drawable.icon_family_space));
familyIcon.setLable("家庭空间");
familyIcon.setPackageName("aios.family");
desktopIcons.add(0, familyIcon);
@@ -343,6 +343,8 @@ public class ApkUtils {
ComponentName cn = new ComponentName(packageName, className);
Intent intent = new Intent();
intent.setComponent(cn);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (context != null) {
context.startActivity(intent);
return true;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.code.HealthCodeActivity">
tools:context=".activity.code.FamilySpaceActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
@@ -32,7 +32,7 @@
android:layout_height="@dimen/dp_20"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/family_space"
android:src="@drawable/icon_family_space"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_back"
app:layout_constraintTop_toTopOf="parent" />

View File

@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.code.HealthCodeActivity">
tools:context=".activity.code.FamilySpaceActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
@@ -32,7 +32,7 @@
android:layout_height="@dimen/dp_20"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/family_space"
android:src="@drawable/icon_family_space"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_back"
app:layout_constraintTop_toTopOf="parent" />