Compare commits
1 Commits
0d2d9020bc
...
screen_fli
| Author | SHA1 | Date | |
|---|---|---|---|
| 10d0dabdfc |
@@ -36,7 +36,6 @@
|
||||
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
|
||||
android:protectionLevel="dangerous" />
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
|
||||
@@ -48,15 +47,6 @@
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
|
||||
|
||||
<!--
|
||||
Permissions required for read/write access to the workspace data. These permission name
|
||||
should not conflict with that defined in other apps, as such an app should embed its package
|
||||
@@ -79,8 +69,8 @@
|
||||
<uses-permission android:name="${packageName}.permission.WRITE_SETTINGS" />
|
||||
|
||||
<application
|
||||
android:name=".base.BaseApplication"
|
||||
android:backupAgent=".LauncherBackupAgent"
|
||||
android:name="com.aoleyun.os.base.MyApplication"
|
||||
android:backupAgent="com.aoleyun.os.LauncherBackupAgent"
|
||||
android:fullBackupContent="@xml/backupscheme"
|
||||
android:fullBackupOnly="true"
|
||||
android:hardwareAccelerated="true"
|
||||
@@ -93,7 +83,7 @@
|
||||
|
||||
<!-- Intent received used to install shortcuts from other applications -->
|
||||
<receiver
|
||||
android:name=".InstallShortcutReceiver"
|
||||
android:name="com.aoleyun.os.InstallShortcutReceiver"
|
||||
android:enabled="@bool/enable_install_shortcut_api"
|
||||
android:permission="com.android.launcher.permission.INSTALL_SHORTCUT">
|
||||
<intent-filter>
|
||||
@@ -102,41 +92,27 @@
|
||||
</receiver>
|
||||
|
||||
<!-- Intent received when a session is committed -->
|
||||
<receiver android:name=".SessionCommitReceiver">
|
||||
<receiver android:name="com.aoleyun.os.SessionCommitReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.pm.action.SESSION_COMMITTED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Intent received used to initialize a restored widget -->
|
||||
<receiver android:name=".AppWidgetsRestoredReceiver">
|
||||
<receiver android:name="com.aoleyun.os.AppWidgetsRestoredReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_HOST_RESTORED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".receiver.NewAppReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.INSTALL_PACKAGES">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
<action android:name="android.intent.action.PACKAGE_CHANGED" />
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
|
||||
android:name="com.aoleyun.os.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:process=":wallpaper_chooser" />
|
||||
|
||||
<service
|
||||
android:name=".notification.NotificationListener"
|
||||
android:name="com.aoleyun.os.notification.NotificationListener"
|
||||
android:enabled="@bool/notification_dots_enabled"
|
||||
android:label="@string/notification_dots_service_title"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
|
||||
@@ -150,7 +126,7 @@
|
||||
android:value="true" />
|
||||
|
||||
<activity
|
||||
android:name=".dragndrop.AddItemActivity"
|
||||
android:name="com.aoleyun.os.dragndrop.AddItemActivity"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:label="@string/action_add_to_workspace"
|
||||
@@ -175,7 +151,7 @@
|
||||
represent the package name.
|
||||
-->
|
||||
<provider
|
||||
android:name=".LauncherProvider"
|
||||
android:name="com.aoleyun.os.LauncherProvider"
|
||||
android:authorities="${packageName}.settings"
|
||||
android:exported="true"
|
||||
android:readPermission="${packageName}.permission.READ_SETTINGS"
|
||||
@@ -186,7 +162,7 @@
|
||||
TODO: Add proper permissions
|
||||
-->
|
||||
<provider
|
||||
android:name=".graphics.GridOptionsProvider"
|
||||
android:name="com.aoleyun.os.graphics.GridOptionsProvider"
|
||||
android:authorities="${packageName}.grid_control"
|
||||
android:enabled="false"
|
||||
android:exported="true" />
|
||||
@@ -195,7 +171,7 @@
|
||||
The settings activity. To extend point settings_fragment_name to appropriate fragment class
|
||||
-->
|
||||
<activity
|
||||
android:name=".settings.SettingsActivity"
|
||||
android:name="com.aoleyun.os.settings.SettingsActivity"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:label="@string/settings_button_text"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Settings">
|
||||
@@ -206,7 +182,7 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".Launcher"
|
||||
android:name="com.aoleyun.os.Launcher"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
|
||||
android:enabled="true"
|
||||
@@ -229,12 +205,165 @@
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name=".testing.TestInformationProvider"
|
||||
android:name="com.aoleyun.os.testing.TestInformationProvider"
|
||||
android:authorities="${packageName}.TestInfo"
|
||||
android:enabled="false"
|
||||
android:exported="true"
|
||||
android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
|
||||
|
||||
<!-- Rich push 核心功能 since 2.0.6-->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/MyDialogStyle"
|
||||
tools:replace="android:exported"></activity>
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PushActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
tools:replace="android:exported">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.ui.PushActivity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Required SDK 核心功能-->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<service
|
||||
android:name="cn.jpush.android.service.PushService"
|
||||
android:exported="false"
|
||||
android:process=":pushcore">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.REGISTER" />
|
||||
<action android:name="cn.jpush.android.intent.REPORT" />
|
||||
<action android:name="cn.jpush.android.intent.PushService" />
|
||||
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- since 3.0.9 Required SDK 核心功能-->
|
||||
<provider
|
||||
android:name="cn.jpush.android.service.DataProvider"
|
||||
android:authorities="${applicationId}.DataProvider"
|
||||
android:exported="false"
|
||||
android:process=":pushcore"
|
||||
tools:replace="android:authorities" />
|
||||
|
||||
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
||||
<service
|
||||
android:name="cn.jpush.android.service.DaemonService"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.DaemonService" />
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
|
||||
</service>
|
||||
|
||||
<!-- since 3.1.0 Required SDK 核心功能-->
|
||||
<provider
|
||||
android:name="cn.jpush.android.service.DownloadProvider"
|
||||
android:authorities="${applicationId}.DownloadProvider"
|
||||
android:exported="true"
|
||||
tools:replace="android:authorities" />
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<receiver
|
||||
android:name="cn.jpush.android.service.PushReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
tools:replace="android:exported">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--Required 显示通知栏 -->
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.USER_PRESENT" />
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
</intent-filter>
|
||||
<!-- Optional -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<receiver
|
||||
android:name="cn.jpush.android.service.AlarmReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
|
||||
<!-- User defined. For test only 用户自定义的广播接收器-->
|
||||
<receiver
|
||||
android:name="com.aoleyun.os.jpush.MyReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户注册SDK的intent-->
|
||||
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK消息的intent-->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent-->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用户打开自定义通知栏的intent-->
|
||||
<action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收网络变化 连接/断开 since 1.6.3 -->
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
|
||||
<!--since 3.3.0 接收JPush相关事件-->
|
||||
<receiver android:name="com.aoleyun.os.jpush.MyJPushMessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="com.aoleyun.os.receiver.InstallResultReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<!--since 3.3.0 Required SDK核心功能-->
|
||||
<activity
|
||||
android:name="cn.jpush.android.service.JNotifyActivity"
|
||||
android:exported="true"
|
||||
android:taskAffinity="jpush.custom"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.JNotifyActivity" />
|
||||
<category android:name="${applicationId}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- since 3.3.0 Required SDK 核心功能-->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<!--User defined. For test only 继承自cn.jpush.android.service.JCommonService-->
|
||||
<service
|
||||
android:name="com.aoleyun.os.jpush.PushService"
|
||||
android:process=":pushcore">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jiguang.user.service.action" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- Required . Enable it you can get statistics data with channel -->
|
||||
<meta-data
|
||||
android:name="JPUSH_CHANNEL"
|
||||
android:value="${JPUSH_CHANNEL}" />
|
||||
<meta-data
|
||||
android:name="JPUSH_APPKEY"
|
||||
android:value="${JPUSH_APPKEY}" /> <!-- </>值来自开发者平台取得的AppKey-->
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
android:targetSdkVersion="29" />
|
||||
|
||||
<application
|
||||
android:name="com.aoleyun.os.base.BaseApplication"
|
||||
android:name="com.aoleyun.os.base.MyApplication"
|
||||
android:backupAgent="com.aoleyun.os.LauncherBackupAgent"
|
||||
android:extractNativeLibs="false"
|
||||
android:fullBackupContent="@xml/backupscheme"
|
||||
|
||||
476
build.gradle
@@ -1,7 +1,7 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://maven.google.com' }
|
||||
maven { url 'https://developer.huawei.com/repo/' }
|
||||
@@ -11,7 +11,6 @@ buildscript {
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath GRADLE_CLASS_PATH
|
||||
classpath PROTOBUF_CLASS_PATH
|
||||
@@ -52,11 +51,11 @@ allprojects {
|
||||
}
|
||||
|
||||
def appName() {
|
||||
return "AoleyunLauncher3"
|
||||
return "奥乐云桌面"
|
||||
}
|
||||
|
||||
def releaseTime() {
|
||||
return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault())
|
||||
return new Date().format("yyyyMMdd", TimeZone.getDefault())
|
||||
}
|
||||
|
||||
final String ANDROID_TOP = "${rootDir}"
|
||||
@@ -74,9 +73,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 28
|
||||
|
||||
versionCode 203
|
||||
versionName "1.6.0526"
|
||||
versionCode 216
|
||||
versionName "1.6.1016"
|
||||
|
||||
ndk {
|
||||
//选择要添加的对应 cpu 类型的 .so 库。
|
||||
@@ -89,6 +87,12 @@ android {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
manifestPlaceholders = [
|
||||
JPUSH_PKGNAME: "com.aoleyun.os",
|
||||
JPUSH_APPKEY : "0c7ba5a1622dba78d5bd00cc", //JPush 上注册的包名对应的 Appkey.
|
||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||
]
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
@@ -107,7 +111,7 @@ android {
|
||||
//签名
|
||||
signingConfigs {
|
||||
zhanRui {
|
||||
storeFile file("keystore/zhanxun.keystore")
|
||||
storeFile file("src/doc/zhanxun.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "zhanxun"
|
||||
keyPassword "123456"
|
||||
@@ -115,315 +119,31 @@ android {
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
zhanRuiUserdebug {
|
||||
storeFile file("keystore/zhanxunUserdebug.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "zhanxunUserdebug"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled false
|
||||
}
|
||||
|
||||
zhanRui12 {
|
||||
storeFile file("keystore/zhanrui12.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "zhanrui12"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
mtk {
|
||||
storeFile file("keystore/xueshibaoos.jks")
|
||||
storeFile file("src/doc/xueshibaoos.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "xueshibaoos"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
TeclastP20S {
|
||||
storeFile file("keystore/MTKP20S.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "MTKP20S"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
|
||||
zhanruiG10Z {
|
||||
storeFile file("keystore/zhanruiG10Z.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "zhanruiG10Z"
|
||||
keyPassword "123456"
|
||||
SM8150 {
|
||||
storeFile file("src/doc/sm8150.jks")
|
||||
storePassword "logan-123456789"
|
||||
keyAlias "platformkey"
|
||||
keyPassword "logan-123456789"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
G10P {
|
||||
storeFile file("keystore/G10PMTK11.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "G10PMTK11"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
G11Userdebug {
|
||||
storeFile file("keystore/G11Userdebug.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "G11Userdebug"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
teclast8183 {
|
||||
storeFile file("keystore/TeclastMTK12.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "TeclastMTK12"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
|
||||
Huaruian8768 {
|
||||
storeFile file("keystore/Huaruian8768.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "Huaruian8768"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
T40Air {
|
||||
storeFile file("keystore/T40Air.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "T40Air"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
P50 {
|
||||
storeFile file("keystore/P50TD.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "P50TD"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
seewo {
|
||||
storeFile file("keystore/aiud.keystore")
|
||||
storePassword "s4HdJuphaiHhU7WY"
|
||||
keyAlias "androidreleasekey"
|
||||
keyPassword "JwUw2oV16rUjWLBC"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
U1302 {
|
||||
storeFile file("keystore/U1302.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "u1302"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
G128T {
|
||||
storeFile file("keystore/HuaruianG128T.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "g128t"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
QualcommDebug.initWith(debug)
|
||||
QualcommDebug {
|
||||
buildConfigField "String", "platform", '"QualcommA"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
zhanRuiRelease.initWith(release)
|
||||
zhanRuiRelease {
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
QualcommRelease.initWith(release)
|
||||
QualcommRelease {
|
||||
buildConfigField "String", "platform", '"QualcommA"'
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
G128TDebug.initWith(debug)
|
||||
G128TDebug {
|
||||
buildConfigField "String", "platform", '"G128T"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.G128T
|
||||
}
|
||||
|
||||
G128TRelease.initWith(release)
|
||||
G128TRelease {
|
||||
buildConfigField "String", "platform", '"G128T"'
|
||||
signingConfig signingConfigs.G128T
|
||||
}
|
||||
|
||||
QZ15Debug.initWith(debug)
|
||||
QZ15Debug {
|
||||
buildConfigField "String", "platform", '"QZA15"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.U1302
|
||||
}
|
||||
|
||||
QZ15Release.initWith(release)
|
||||
QZ15Release {
|
||||
buildConfigField "String", "platform", '"QZA15"'
|
||||
signingConfig signingConfigs.U1302
|
||||
}
|
||||
|
||||
seewoDebug.initWith(debug)
|
||||
seewoDebug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.seewo
|
||||
buildConfigField "String", "platform", '"seewo"'
|
||||
}
|
||||
|
||||
seewoRelease.initWith(release)
|
||||
seewoRelease {
|
||||
signingConfig signingConfigs.seewo
|
||||
buildConfigField "String", "platform", '"seewo"'
|
||||
}
|
||||
|
||||
P50Debug.initWith(debug)
|
||||
P50Debug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.P50
|
||||
buildConfigField "String", "platform", '"P50TD"'
|
||||
}
|
||||
|
||||
P50Release.initWith(release)
|
||||
P50Release {
|
||||
signingConfig signingConfigs.P50
|
||||
buildConfigField "String", "platform", '"P50TD"'
|
||||
}
|
||||
|
||||
T40AirDebug.initWith(debug)
|
||||
T40AirDebug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.T40Air
|
||||
buildConfigField "String", "platform", '"HL500"'
|
||||
}
|
||||
|
||||
T40AirRelease.initWith(release)
|
||||
T40AirRelease {
|
||||
signingConfig signingConfigs.T40Air
|
||||
buildConfigField "String", "platform", '"HL500"'
|
||||
}
|
||||
|
||||
// AiUduDebug.initWith(debug)
|
||||
// AiUduDebug {
|
||||
// versionNameSuffix "-debug"
|
||||
// debuggable true
|
||||
// signingConfig signingConfigs.G10P
|
||||
// buildConfigField "String", "platform", '"AUDG104"'
|
||||
// }
|
||||
//
|
||||
// AiUduRelease.initWith(release)
|
||||
// AiUduRelease {
|
||||
// signingConfig signingConfigs.G10P
|
||||
// buildConfigField "String", "platform", '"AUDG104"'
|
||||
// }
|
||||
|
||||
Huaruian8768Debug.initWith(debug)
|
||||
Huaruian8768Debug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.Huaruian8768
|
||||
buildConfigField "String", "platform", '"MT8768"'
|
||||
}
|
||||
|
||||
Huaruian8768Release.initWith(release)
|
||||
Huaruian8768Release {
|
||||
signingConfig signingConfigs.Huaruian8768
|
||||
buildConfigField "String", "platform", '"MT8768"'
|
||||
}
|
||||
|
||||
G11Debug.initWith(debug)
|
||||
G11Debug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.G11Userdebug
|
||||
buildConfigField "String", "platform", '"MTKG11"'
|
||||
}
|
||||
|
||||
G11Release.initWith(release)
|
||||
G11Release {
|
||||
signingConfig signingConfigs.G11Userdebug
|
||||
buildConfigField "String", "platform", '"MTKG11"'
|
||||
}
|
||||
|
||||
YXPD1Debug.initWith(debug)
|
||||
YXPD1Debug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.G10P
|
||||
buildConfigField "String", "platform", '"YXPD1"'
|
||||
}
|
||||
|
||||
YXPD1Release.initWith(release)
|
||||
YXPD1Release {
|
||||
signingConfig signingConfigs.G10P
|
||||
buildConfigField "String", "platform", '"YXPD1"'
|
||||
}
|
||||
|
||||
c2Debug.initWith(debug)
|
||||
c2Debug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.teclast8183
|
||||
buildConfigField "String", "platform", '"MTK8183"'
|
||||
}
|
||||
|
||||
c2Release.initWith(release)
|
||||
c2Release {
|
||||
signingConfig signingConfigs.teclast8183
|
||||
buildConfigField "String", "platform", '"MTK8183"'
|
||||
}
|
||||
|
||||
G10PDebug.initWith(debug)
|
||||
G10PDebug {
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.G10P
|
||||
buildConfigField "String", "platform", '"G10P"'
|
||||
}
|
||||
|
||||
G10PRelease.initWith(release)
|
||||
G10PRelease {
|
||||
signingConfig signingConfigs.G10P
|
||||
buildConfigField "String", "platform", '"G10P"'
|
||||
}
|
||||
|
||||
G104Debug.initWith(debug)
|
||||
G104Debug {
|
||||
buildConfigField "String", "platform", '"MTK11"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.G10P
|
||||
}
|
||||
|
||||
G104Release.initWith(release)
|
||||
G104Release {
|
||||
buildConfigField "String", "platform", '"MTK11"'
|
||||
signingConfig signingConfigs.G10P
|
||||
}
|
||||
|
||||
zhanRuiDebug.initWith(debug)
|
||||
zhanRuiDebug {
|
||||
versionNameSuffix "-debug"
|
||||
@@ -432,95 +152,28 @@ android {
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
zhanRuiRelease.initWith(release)
|
||||
zhanRuiRelease {
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
//userdebug rom使用这个版本
|
||||
zhanRuiUserdebug.initWith(zhanRuiDebug)
|
||||
zhanRuiUserdebug {
|
||||
versionNameSuffix "-debug"
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
debuggable true
|
||||
signingConfig signingConfigs.zhanRuiUserdebug
|
||||
}
|
||||
|
||||
zhanRui12Debug.initWith(debug)
|
||||
zhanRui12Debug {
|
||||
versionNameSuffix "-debug"
|
||||
buildConfigField "String", "platform", '"AH6016"'
|
||||
debuggable true
|
||||
signingConfig signingConfigs.zhanRui12
|
||||
}
|
||||
|
||||
zhanRui12Release.initWith(release)
|
||||
zhanRui12Release {
|
||||
buildConfigField "String", "platform", '"AH6016"'
|
||||
signingConfig signingConfigs.zhanRui12
|
||||
}
|
||||
|
||||
TeclastP20SDebug.initWith(debug)
|
||||
TeclastP20SDebug {
|
||||
debuggable true
|
||||
versionNameSuffix "-debug"
|
||||
buildConfigField "String", "platform", '"P20S"'
|
||||
signingConfig signingConfigs.TeclastP20S
|
||||
}
|
||||
|
||||
TeclastP20SRelease.initWith(release)
|
||||
TeclastP20SRelease {
|
||||
buildConfigField "String", "platform", '"P20S"'
|
||||
signingConfig signingConfigs.TeclastP20S
|
||||
}
|
||||
|
||||
zhanruiG10ZDebug.initWith(debug)
|
||||
zhanruiG10ZDebug {
|
||||
buildConfigField "String", "platform", '"ZR6016"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.zhanruiG10Z
|
||||
}
|
||||
|
||||
zhanruiG10ZRelease.initWith(release)
|
||||
zhanruiG10ZRelease {
|
||||
buildConfigField "String", "platform", '"ZR6016"'
|
||||
signingConfig signingConfigs.zhanruiG10Z
|
||||
}
|
||||
|
||||
debug {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
debuggable true
|
||||
versionNameSuffix "-debug"
|
||||
versionNameSuffix "_debug"
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.mtk
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null) {
|
||||
def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${productFlavors[0].name}.apk"
|
||||
output.outputFileName = fileName
|
||||
}
|
||||
}
|
||||
}
|
||||
signingConfig signingConfigs.SM8150
|
||||
}
|
||||
|
||||
release {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.mtk
|
||||
//将release版本的包名重命名,加上版本及日期
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = ""
|
||||
if (outputFile != null) {
|
||||
def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${productFlavors[0].name}_${buildType.name}.apk"
|
||||
output.outputFileName = fileName
|
||||
}
|
||||
}
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.SM8150
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.outputs.all { output -> // 改为 all
|
||||
def buildType = variant.buildType.name
|
||||
if (buildType.contains("debug")) {
|
||||
outputFileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
|
||||
} else {
|
||||
outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,12 +189,11 @@ android {
|
||||
testApplicationId 'com.aoleyun.os.tests'
|
||||
}
|
||||
|
||||
/*hide l3go*/
|
||||
// l3go {
|
||||
// dimension "app"
|
||||
// applicationId 'com.aoleyun.os'
|
||||
// testApplicationId 'com.aoleyun.os.tests'
|
||||
// }
|
||||
l3go {
|
||||
dimension "app"
|
||||
applicationId 'com.aoleyun.os'
|
||||
testApplicationId 'com.aoleyun.os.tests'
|
||||
}
|
||||
|
||||
/*withQuickstep {
|
||||
dimension "recents"
|
||||
@@ -602,12 +254,11 @@ android {
|
||||
manifest.srcFile "AndroidManifest.xml"
|
||||
}
|
||||
|
||||
/*hide l3go*/
|
||||
// l3go {
|
||||
// res.srcDirs = ['go/res']
|
||||
// java.srcDirs = ['go/src']
|
||||
// manifest.srcFile "go/AndroidManifest.xml"
|
||||
// }
|
||||
l3go {
|
||||
res.srcDirs = ['go/res']
|
||||
java.srcDirs = ['go/src']
|
||||
manifest.srcFile "go/AndroidManifest.xml"
|
||||
}
|
||||
|
||||
withoutQuickstep {
|
||||
java.srcDirs = ['src_ui_overrides']
|
||||
@@ -630,22 +281,13 @@ android {
|
||||
repositories {
|
||||
maven { url "../../../prebuilts/fullsdk-darwin/extras/android/m2repository" }
|
||||
maven { url "../../../prebuilts/fullsdk-linux/extras/android/m2repository" }
|
||||
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://maven.google.com' }
|
||||
maven { url 'https://developer.huawei.com/repo/' }
|
||||
maven { url 'https://developer.hihonor.com/repo' }
|
||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly files('libs/framework.jar')
|
||||
implementation files('libs/vendor.mediatek.hardware.nvram-V1.0-java.jar')
|
||||
|
||||
implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
|
||||
implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
|
||||
@@ -672,31 +314,25 @@ dependencies {
|
||||
androidTestImplementation 'com.android.support.test:rules:1.0.0'
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
|
||||
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
|
||||
//OkHttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
|
||||
|
||||
//RxJava和Retrofit
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
|
||||
//gson
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
//磁盘缓存
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'com.google.code.gson:gson:2.8.7'
|
||||
//mmkv
|
||||
implementation 'com.tencent:mmkv-static:2.4.0'
|
||||
// //腾讯移动推送 TPNS
|
||||
// implementation 'com.tencent.tpns:tpns:1.3.2.0-release'
|
||||
// //阿里云推送
|
||||
// implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
|
||||
implementation 'com.tencent:mmkv-static:1.2.10'
|
||||
//极光推送
|
||||
implementation 'cn.jiguang.sdk:jpush:3.8.5' // 此处以JPush 3.8.6 版本为例。
|
||||
implementation 'cn.jiguang.sdk:jcore:2.7.8' // 此处以JCore 2.6.0 版本为例。
|
||||
//下载
|
||||
implementation 'me.laoyuyu.aria:core:3.8.16'
|
||||
annotationProcessor 'me.laoyuyu.aria:compiler:3.8.16'
|
||||
//工具类
|
||||
implementation 'com.blankj:utilcodex:1.31.1'
|
||||
// 吐司框架:https://github.com/getActivity/Toaster
|
||||
implementation 'com.github.getActivity:Toaster:12.6'
|
||||
implementation 'com.blankj:utilcodex:1.30.6'
|
||||
}
|
||||
|
||||
// 在 dependencies 之后添加
|
||||
|
||||
@@ -15,44 +15,22 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
QualcommDebug {}
|
||||
QualcommRelease {}
|
||||
G128TDebug {}
|
||||
G128TRelease {}
|
||||
QZ15Debug {}
|
||||
QZ15Release {}
|
||||
seewoDebug {}
|
||||
seewoRelease {}
|
||||
P50Debug {}
|
||||
P50Release {}
|
||||
T40AirDebug {}
|
||||
T40AirRelease {}
|
||||
AiUduDebug {}
|
||||
AiUduRelease {}
|
||||
Huaruian8768Debug {}
|
||||
Huaruian8768Release {}
|
||||
G11Debug {}
|
||||
G11Release {}
|
||||
YXPD1Debug {}
|
||||
YXPD1Release {}
|
||||
c2Debug {}
|
||||
c2Release {}
|
||||
G104Debug {}
|
||||
G104Release {}
|
||||
G10PDebug {}
|
||||
G10PRelease {}
|
||||
zhanRuiDebug {}
|
||||
zhanRuiRelease {}
|
||||
zhanRui12Debug {}
|
||||
zhanRui12Release {}
|
||||
alldocubeDebug {}
|
||||
alldocubeDebugReleas {}
|
||||
TeclastP20SDebug {}
|
||||
TeclastP20SRelease {}
|
||||
zhanruiG10ZDebug {}
|
||||
zhanruiG10ZRelease {}
|
||||
debug {}
|
||||
release {}
|
||||
zhanRuiRelease.initWith(release)
|
||||
zhanRuiRelease {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
zhanRuiDebug.initWith(debug)
|
||||
zhanRuiDebug {
|
||||
minifyEnabled false
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -329,7 +329,7 @@ public class BaseIconFactory implements AutoCloseable {
|
||||
/**
|
||||
* An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size.
|
||||
* This allows the badging to be done based on the action bitmap size rather than
|
||||
* the scaled bitmap size.c
|
||||
* the scaled bitmap size.
|
||||
*/
|
||||
private static class FixedSizeBitmapDrawable extends BitmapDrawable {
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
BIN
res/drawable-hdpi/wallpapers.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 832 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 4.1 KiB |
@@ -20,7 +20,7 @@
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="app_name" msgid="649227358658669779">"Launcher3"</string>
|
||||
<string name="folder_name" msgid="7371454440695724752">文件夹</string>
|
||||
<string name="folder_name" msgid="7371454440695724752"></string>
|
||||
<string name="work_folder_name" msgid="3753320833950115786">"Work"</string>
|
||||
<string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string>
|
||||
<string name="activity_not_available" msgid="7456344436509528827">"应用不可用"</string>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<!-- Extra bottom padding for non-tall devices. -->
|
||||
<dimen name="dynamic_grid_hotseat_bottom_non_tall_padding">0dp</dimen>
|
||||
<dimen name="dynamic_grid_hotseat_extra_vertical_size">34dp</dimen>
|
||||
<dimen name="dynamic_grid_hotseat_extra_vertical_size_aiudu">56dp</dimen>
|
||||
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
|
||||
|
||||
<!-- Hotseat/all-apps scrim -->
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<string name="app_uiui">桌面</string>
|
||||
|
||||
<!-- Default folder name -->
|
||||
<string name="folder_name">文件夹</string>
|
||||
<string name="folder_name"></string>
|
||||
<!-- Work folder name -->
|
||||
<string name="work_folder_name">Work</string>
|
||||
<!-- Displayed when user selects a shortcut for an app that was uninstalled [CHAR_LIMIT=none]-->
|
||||
|
||||
@@ -62,18 +62,10 @@
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MUSIC;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:className="com.aoleyun.browser.activity.main.MainActivity"-->
|
||||
<!-- launcher:packageName="com.aoleyun.browser"-->
|
||||
<!-- launcher:screen="2"-->
|
||||
<!-- launcher:x="2"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
|
||||
<favorite
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.info.activity.main.MainActivity"
|
||||
launcher:packageName="com.aoleyun.info"
|
||||
launcher:className="com.uiui.browser.activity.MainActivity"
|
||||
launcher:packageName="com.uiui.browser"
|
||||
launcher:screen="2"
|
||||
launcher:x="2"
|
||||
launcher:y="0" />
|
||||
@@ -86,38 +78,22 @@
|
||||
launcher:x="3"
|
||||
launcher:y="0" />
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="4"-->
|
||||
<!-- launcher:x="4"-->
|
||||
<!-- launcher:y="0">-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="5"-->
|
||||
<!-- launcher:x="5"-->
|
||||
<!-- launcher:y="0">-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;component=com.android.deskclock/.DeskClock;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<favorite
|
||||
<resolve
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.sn.activity.update.UpdateActivity"
|
||||
launcher:packageName="com.aoleyun.sn"
|
||||
launcher:screen="4"
|
||||
launcher:x="4"
|
||||
launcher:y="0" />
|
||||
launcher:y="0">
|
||||
<favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />
|
||||
<favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />
|
||||
</resolve>
|
||||
|
||||
<favorite
|
||||
<resolve
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.sn.activity.EyeProtectionActivity"
|
||||
launcher:packageName="com.aoleyun.sn"
|
||||
launcher:screen="5"
|
||||
launcher:x="5"
|
||||
launcher:y="0" />
|
||||
launcher:y="0">
|
||||
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;component=com.android.deskclock/.DeskClock;end" />
|
||||
</resolve>
|
||||
|
||||
<!-- Bottom row -->
|
||||
<!-- <resolve-->
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.uiuios">
|
||||
|
||||
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
|
||||
<!-- Dialer, Messaging, [Maps/Music], Browser, Camera -->
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:className="com.aoleyun.sn.activity.SplashActivity"-->
|
||||
<!-- launcher:packageName="com.aoleyun.sn"-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="0"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
|
||||
<favorite
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.appstore.activity.SplashActivity"
|
||||
launcher:packageName="com.aoleyun.appstore"
|
||||
launcher:screen="1"
|
||||
launcher:x="1"
|
||||
launcher:y="0" />
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="0"-->
|
||||
<!-- launcher:y="0" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.DIAL;end" />-->
|
||||
<!-- <favorite launcher:uri="tel:123" />-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.CALL_BUTTON;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="1"-->
|
||||
<!-- launcher:x="1"-->
|
||||
<!-- launcher:y="0" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MESSAGING;end" />-->
|
||||
<!-- <favorite launcher:uri="sms:" />-->
|
||||
<!-- <favorite launcher:uri="smsto:" />-->
|
||||
<!-- <favorite launcher:uri="mms:" />-->
|
||||
<!-- <favorite launcher:uri="mmsto:" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="2"-->
|
||||
<!-- launcher:x="2"-->
|
||||
<!-- launcher:y="0" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MAPS;end" />-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MUSIC;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:className="com.aoleyun.browser.activity.main.MainActivity"-->
|
||||
<!-- launcher:packageName="com.aoleyun.browser"-->
|
||||
<!-- launcher:screen="2"-->
|
||||
<!-- launcher:x="2"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
|
||||
<favorite
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.info.activity.main.MainActivity"
|
||||
launcher:packageName="com.aoleyun.info"
|
||||
launcher:screen="2"
|
||||
launcher:x="2"
|
||||
launcher:y="0" />
|
||||
|
||||
<favorite
|
||||
launcher:container="-101"
|
||||
launcher:className="com.android.settings.Settings"
|
||||
launcher:packageName="com.android.settings"
|
||||
launcher:screen="3"
|
||||
launcher:x="3"
|
||||
launcher:y="0" />
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="4"-->
|
||||
<!-- launcher:x="4"-->
|
||||
<!-- launcher:y="0">-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:screen="5"-->
|
||||
<!-- launcher:x="5"-->
|
||||
<!-- launcher:y="0">-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;component=com.android.deskclock/.DeskClock;end" />-->
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:container="-101"-->
|
||||
<!-- launcher:className="com.aoleyun.sn.activity.update.UpdateActivity"-->
|
||||
<!-- launcher:packageName="com.aoleyun.sn"-->
|
||||
<!-- launcher:screen="4"-->
|
||||
<!-- launcher:x="4"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
|
||||
<favorite
|
||||
launcher:container="-101"
|
||||
launcher:className="com.aoleyun.sn.activity.EyeProtectionActivity"
|
||||
launcher:packageName="com.aoleyun.sn"
|
||||
launcher:screen="4"
|
||||
launcher:x="4"
|
||||
launcher:y="0" />
|
||||
|
||||
<!-- Bottom row -->
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="0"-->
|
||||
<!-- launcher:y="-1" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />-->
|
||||
<!-- <favorite launcher:uri="mailto:" />-->
|
||||
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="1"-->
|
||||
<!-- launcher:y="-1" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />-->
|
||||
<!-- <favorite launcher:uri="#Intent;type=images/*;end" />-->
|
||||
|
||||
<!-- </resolve>-->
|
||||
|
||||
<!-- <resolve-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="4"-->
|
||||
<!-- launcher:y="-1" >-->
|
||||
<!-- <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />-->
|
||||
<!-- <favorite launcher:uri="market://details?id=com.android.launcher" />-->
|
||||
<!-- </resolve>-->
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:className="com.info.sn.activity.MainActivity"-->
|
||||
<!-- launcher:packageName="com.info.sn"-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="0"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
<!-- <favorite-->
|
||||
<!-- launcher:className="com.jiaoguanyi.sysc.activity.MainActivity"-->
|
||||
<!-- launcher:packageName="com.jiaoguanyi.sysc"-->
|
||||
<!-- launcher:screen="0"-->
|
||||
<!-- launcher:x="1"-->
|
||||
<!-- launcher:y="0" />-->
|
||||
</favorites>
|
||||
@@ -149,31 +149,4 @@
|
||||
|
||||
</grid-option>
|
||||
|
||||
<grid-option
|
||||
launcher:name="aiudu"
|
||||
launcher:numRows="4"
|
||||
launcher:numColumns="6"
|
||||
launcher:numFolderRows="3"
|
||||
launcher:numFolderColumns="3"
|
||||
launcher:numHotseatIcons="6"
|
||||
launcher:defaultLayoutId="@xml/default_workspace_aiudu" >
|
||||
|
||||
<display-option
|
||||
launcher:name="AiUDU Phone"
|
||||
launcher:minWidthDps="406"
|
||||
launcher:minHeightDps="694"
|
||||
launcher:iconImageSize="70"
|
||||
launcher:iconTextSize="14.4"
|
||||
launcher:canBeDefault="true" />
|
||||
|
||||
<!-- <display-option-->
|
||||
<!-- launcher:name="Shorter Stubby"-->
|
||||
<!-- launcher:minWidthDps="255"-->
|
||||
<!-- launcher:minHeightDps="400"-->
|
||||
<!-- launcher:iconImageSize="48"-->
|
||||
<!-- launcher:iconTextSize="13.0"-->
|
||||
<!-- launcher:canBeDefault="true" />-->
|
||||
|
||||
</grid-option>
|
||||
|
||||
</profiles>
|
||||
@@ -1,3 +1,2 @@
|
||||
include ':IconLoader'
|
||||
project(':IconLoader').projectDir = new File(rootDir, 'iconloaderlib')
|
||||
rootProject.name='酷比桌面'
|
||||
@@ -4,7 +4,6 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
||||
import com.aoleyun.os.R;
|
||||
import com.aoleyun.os.model.LoaderTask;
|
||||
import com.aoleyun.os.util.ResourceBasedOverride;
|
||||
|
||||
public class AppFilter implements ResourceBasedOverride {
|
||||
@@ -14,9 +13,6 @@ public class AppFilter implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
public boolean shouldShowApp(ComponentName app) {
|
||||
if (LoaderTask.SYSTEM_HIDE_APP.contains(app.getPackageName())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.animation.FloatArrayEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.ColorMatrix;
|
||||
@@ -32,7 +31,6 @@ import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.Property;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -41,12 +39,12 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.aoleyun.os.R;
|
||||
import com.aoleyun.os.anim.Interpolators;
|
||||
import com.aoleyun.os.dragndrop.DragController;
|
||||
import com.aoleyun.os.dragndrop.DragLayer;
|
||||
import com.aoleyun.os.dragndrop.DragOptions;
|
||||
import com.aoleyun.os.dragndrop.DragView;
|
||||
import com.aoleyun.os.uiuiutils.JgyUtils;
|
||||
import com.aoleyun.os.userevent.nano.LauncherLogProto.Target;
|
||||
import com.aoleyun.os.util.Themes;
|
||||
import com.aoleyun.os.util.Thunk;
|
||||
@@ -243,22 +241,12 @@ public abstract class ButtonDropTarget extends TextView
|
||||
@Override
|
||||
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
|
||||
mActive = supportsDrop(dragObject.dragInfo);
|
||||
/*add 2022-01-06 15:28:19 通过info获取包名判断是否为强制应用*/
|
||||
Intent intent = dragObject.dragInfo.getIntent();
|
||||
if (intent != null) {
|
||||
String pkg = intent.getComponent().getPackageName();
|
||||
Log.e("beginDrag", "beginDrag: " + pkg);
|
||||
if (JgyUtils.getInstance().isEnforceApp(pkg)) {
|
||||
mActive = false;
|
||||
}
|
||||
}
|
||||
mDrawable.setColorFilter(null);
|
||||
if (mCurrentColorAnim != null) {
|
||||
mCurrentColorAnim.cancel();
|
||||
mCurrentColorAnim = null;
|
||||
}
|
||||
setTextColor(mOriginalTextColor);
|
||||
Log.e("ButtonDropTarget", "onDragStart: " + mActive);
|
||||
setVisibility(mActive ? View.VISIBLE : View.GONE);
|
||||
|
||||
mAccessibleDrag = options.isAccessibleDrag;
|
||||
|
||||
@@ -34,7 +34,6 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.AttributeSet;
|
||||
@@ -579,11 +578,7 @@ public class CellLayout extends ViewGroup implements Transposable {
|
||||
// Hotseat icons - remove text
|
||||
if (child instanceof BubbleTextView) {
|
||||
BubbleTextView bubbleChild = (BubbleTextView) child;
|
||||
if ("Aiud_A8_ag_1095".equals(Build.MODEL)) {
|
||||
bubbleChild.setTextVisibility(true);
|
||||
} else {
|
||||
bubbleChild.setTextVisibility(mContainerType != HOTSEAT);
|
||||
}
|
||||
bubbleChild.setTextVisibility(mContainerType != HOTSEAT);
|
||||
}
|
||||
|
||||
child.setScaleX(mChildScale);
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.aoleyun.os.R;
|
||||
import com.aoleyun.os.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.aoleyun.os.dragndrop.DragOptions;
|
||||
import com.aoleyun.os.logging.LoggerUtils;
|
||||
@@ -101,6 +102,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
setContentDescription(mText);
|
||||
requestLayout();
|
||||
setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +120,6 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
if (LauncherAppState.isDisableAllApps()) {
|
||||
mControlType = isCanDrop(item) ? ControlType.REMOVE_TARGET
|
||||
: ControlType.CANCEL_TARGET;
|
||||
// Log.e("setControlTypeBasedOnDragSource", "mControlType: " + mControlType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
@@ -207,18 +206,10 @@ public class DeviceProfile {
|
||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
|
||||
// Add a bit of space between nav bar and hotseat in vertical bar layout.
|
||||
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? verticalDragHandleSizePx : 0;
|
||||
if ("Aiud_A8_ag_1095".equals(Build.MODEL)) {
|
||||
hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
|
||||
? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
|
||||
: (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size_aiudu)
|
||||
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
|
||||
} else {
|
||||
hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
|
||||
? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
|
||||
: (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
|
||||
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
|
||||
}
|
||||
|
||||
hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
|
||||
? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
|
||||
: (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
|
||||
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
|
||||
|
||||
// Calculate all of the remaining variables.
|
||||
updateAvailableDimensions(dm, res);
|
||||
|
||||
@@ -213,7 +213,6 @@ public class DropTargetBar extends FrameLayout
|
||||
|
||||
float finalAlpha = mVisible ? 1 : 0;
|
||||
if (Float.compare(getAlpha(), finalAlpha) != 0) {
|
||||
/*控制顶部卸载按钮显示的*/
|
||||
setVisibility(View.VISIBLE);
|
||||
mCurrentAnimation = animate().alpha(finalAlpha)
|
||||
.setInterpolator(DEFAULT_INTERPOLATOR)
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
@@ -55,8 +54,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -185,9 +182,6 @@ public class InvariantDeviceProfile {
|
||||
display.getCurrentSizeRange(smallestSize, largestSize);
|
||||
|
||||
ArrayList<DisplayOption> allOptions = getPredefinedDeviceProfiles(context, gridName);
|
||||
for (DisplayOption displayOption:allOptions){
|
||||
Log.e(TAG, "initGrid: "+displayOption.grid.name);
|
||||
}
|
||||
// This guarantees that width < height
|
||||
float minWidthDps = Utilities.dpiFromPx(Math.min(smallestSize.x, smallestSize.y), dm);
|
||||
float minHeightDps = Utilities.dpiFromPx(Math.min(largestSize.x, largestSize.y), dm);
|
||||
@@ -197,17 +191,8 @@ public class InvariantDeviceProfile {
|
||||
dist(minWidthDps, minHeightDps, b.minWidthDps, b.minHeightDps)));
|
||||
DisplayOption interpolatedDisplayOption =
|
||||
invDistWeightedInterpolate(minWidthDps, minHeightDps, allOptions);
|
||||
GridOption closestProfile;
|
||||
if ("Aiud_A8_ag_1095".equals(Build.MODEL)) {
|
||||
closestProfile = allOptions.stream().filter(new Predicate<DisplayOption>() {
|
||||
@Override
|
||||
public boolean test(DisplayOption displayOption) {
|
||||
return "aiudu".equals(displayOption.grid.name);
|
||||
}
|
||||
}).collect(Collectors.toList()).get(0).grid;
|
||||
}else {
|
||||
closestProfile = allOptions.get(0).grid;
|
||||
}
|
||||
|
||||
GridOption closestProfile = allOptions.get(0).grid;
|
||||
numRows = closestProfile.numRows;
|
||||
numColumns = closestProfile.numColumns;
|
||||
numHotseatIcons = closestProfile.numHotseatIcons;
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.WallpaperManager;
|
||||
import android.app.role.RoleManager;
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -50,7 +49,6 @@ import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Process;
|
||||
import android.os.StrictMode;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.TextKeyListener;
|
||||
@@ -72,12 +70,15 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.aoleyun.os.DropTarget.DragObject;
|
||||
import com.aoleyun.os.TTUtils.APKUtils;
|
||||
import com.aoleyun.os.TTUtils.Utils;
|
||||
import com.aoleyun.os.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.aoleyun.os.allapps.AllAppsContainerView;
|
||||
import com.aoleyun.os.allapps.AllAppsStore;
|
||||
import com.aoleyun.os.allapps.AllAppsTransitionController;
|
||||
import com.aoleyun.os.allapps.DiscoveryBounce;
|
||||
import com.aoleyun.os.anim.PropertyListBuilder;
|
||||
import com.aoleyun.os.base.MyApplication;
|
||||
import com.aoleyun.os.compat.AppWidgetManagerCompat;
|
||||
import com.aoleyun.os.compat.LauncherAppsCompatVO;
|
||||
import com.aoleyun.os.config.FeatureFlags;
|
||||
@@ -90,6 +91,8 @@ import com.aoleyun.os.folder.FolderIcon;
|
||||
import com.aoleyun.os.folder.FolderIconPreviewVerifier;
|
||||
import com.aoleyun.os.graphics.RotationMode;
|
||||
import com.aoleyun.os.icons.IconCache;
|
||||
import com.aoleyun.os.jpush.ExampleUtil;
|
||||
import com.aoleyun.os.jpush.LocalBroadcastManager;
|
||||
import com.aoleyun.os.keyboard.CustomActionsPopup;
|
||||
import com.aoleyun.os.keyboard.ViewGroupFocusHelper;
|
||||
import com.aoleyun.os.logging.FileLog;
|
||||
@@ -98,11 +101,12 @@ import com.aoleyun.os.logging.UserEventDispatcher;
|
||||
import com.aoleyun.os.logging.UserEventDispatcher.UserEventDelegate;
|
||||
import com.aoleyun.os.model.AppLaunchTracker;
|
||||
import com.aoleyun.os.model.ModelWriter;
|
||||
import com.aoleyun.os.network.AppPasswdBean;
|
||||
import com.aoleyun.os.network.BaseResponse;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.network.bean.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.network.NetWorkManager;
|
||||
import com.aoleyun.os.network.NewestAppUpdateResult;
|
||||
import com.aoleyun.os.network.api.AddAppLog;
|
||||
import com.aoleyun.os.notification.NotificationListener;
|
||||
import com.aoleyun.os.pageindicators.PageIndicatorDots;
|
||||
import com.aoleyun.os.popup.PopupContainerWithArrow;
|
||||
@@ -114,10 +118,7 @@ import com.aoleyun.os.states.RotationHelper;
|
||||
import com.aoleyun.os.testing.TestProtocol;
|
||||
import com.aoleyun.os.touch.ItemClickHandler;
|
||||
import com.aoleyun.os.uioverrides.UiFactory;
|
||||
import com.aoleyun.os.uiuiutils.ApkUtils;
|
||||
import com.aoleyun.os.uiuiutils.JgyUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.userevent.nano.LauncherLogProto;
|
||||
import com.aoleyun.os.userevent.nano.LauncherLogProto.Action;
|
||||
import com.aoleyun.os.userevent.nano.LauncherLogProto.ContainerType;
|
||||
@@ -165,11 +166,11 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
@@ -331,14 +332,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
private DeviceProfile mStableDeviceProfile;
|
||||
private RotationMode mRotationMode = RotationMode.NORMAL;
|
||||
|
||||
public static boolean isForeground = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
RaceConditionTracker.onEvent(ON_CREATE_EVT, ENTER);
|
||||
Observable.create(passwdSubscribe)
|
||||
.throttleFirst(1, TimeUnit.HOURS)
|
||||
.subscribe(passwdObserver);
|
||||
Observable.create(updateSubscribe)
|
||||
.throttleFirst(6, TimeUnit.HOURS)
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(1, TimeUnit.MINUTES)
|
||||
.subscribe(updateObserver);
|
||||
startService(new Intent(Launcher.this, MainService.class));
|
||||
if (DEBUG_STRICT_MODE) {
|
||||
@@ -356,7 +356,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
.build());
|
||||
}
|
||||
TraceHelper.beginSection("Launcher-onCreate");
|
||||
Log.e(TAG, "onCreate: " + Utils.getSerial(Launcher.this));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
TraceHelper.partitionSection("Launcher-onCreate", "super call");
|
||||
@@ -421,8 +420,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
|
||||
if (!isDefaultHome()) {
|
||||
// setDefaultL();
|
||||
// setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
setDefaultL();
|
||||
}
|
||||
SharedPreferences sharedPref = getPreferences(MODE_PRIVATE);
|
||||
int i = sharedPref.getInt("SetWallPaper", 0);
|
||||
@@ -470,22 +468,55 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
});
|
||||
JgyUtils.getInstance().wakeUpAppstore();
|
||||
JgyUtils.getInstance().wakeUpDeviceInfo();
|
||||
registerMessageReceiver(); // used for receive msg
|
||||
JPushInterface.init(this);
|
||||
String rid = JPushInterface.getRegistrationID(this);
|
||||
if (!TextUtils.isEmpty(rid)) {
|
||||
Log.e("setJpushAlias", "RegId:" + rid);
|
||||
}
|
||||
JPushInterface.getAlias(this, new Random().nextInt(100));
|
||||
}
|
||||
|
||||
|
||||
//for receive customer msg from jpush server
|
||||
private MessageReceiver mMessageReceiver;
|
||||
public static final String MESSAGE_RECEIVED_ACTION = "com.example.jpushdemo.MESSAGE_RECEIVED_ACTION";
|
||||
public static final String KEY_TITLE = "title";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_EXTRAS = "extras";
|
||||
|
||||
public void registerMessageReceiver() {
|
||||
mMessageReceiver = new MessageReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(MESSAGE_RECEIVED_ACTION);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, filter);
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
if (MESSAGE_RECEIVED_ACTION.equals(intent.getAction())) {
|
||||
String messge = intent.getStringExtra(KEY_MESSAGE);
|
||||
String extras = intent.getStringExtra(KEY_EXTRAS);
|
||||
StringBuilder showMsg = new StringBuilder();
|
||||
showMsg.append(KEY_MESSAGE + " : " + messge + "\n");
|
||||
if (!ExampleUtil.isEmpty(extras)) {
|
||||
showMsg.append(KEY_EXTRAS + " : " + extras + "\n");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetWallPaper() {
|
||||
Log.e(TAG, "SetWallPaper: ");
|
||||
//利用WallpaparManager,添加权限set_wallpaper
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
|
||||
try {
|
||||
if ("Aiud_A8_ag_1095".equals(Build.MODEL)
|
||||
||JgyUtils.getInstance().checkAppPlatform() == JgyUtils.seewoPlatform
|
||||
) {
|
||||
wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.wallpapers_aiudu));
|
||||
}else {
|
||||
wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.wallpapers));
|
||||
}
|
||||
wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.wallpapers));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("TT", e.getMessage());
|
||||
@@ -538,42 +569,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
|
||||
// private void setDefault() {
|
||||
// String mRoleName ="android.app.role.HOME";
|
||||
// final Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP)
|
||||
// .putExtra(Intent.EXTRA_ROLE_NAME, mRoleName);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
|
||||
public void setRoleHolderAsUser(Context context, String packageName) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
String roleName = "android.app.role.HOME";
|
||||
boolean add = true;
|
||||
int flags = 0;
|
||||
UserHandle user = Process.myUserHandle();
|
||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
+ roleName + ", package: " + packageName);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() != JgyUtils.MTKPlatform) {
|
||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||
Executor executor = context.getMainExecutor();
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
||||
} else {
|
||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
||||
+ " package as role holder, role: " + roleName + ", package: "
|
||||
+ packageName);
|
||||
}
|
||||
};
|
||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
//监听时间和日期变化
|
||||
@@ -593,18 +588,17 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
||||
// Log.e("fht", "TimeChangedReceiver:" + "data changed");
|
||||
Log.e("fht", "TimeChangedReceiver:" + "data changed");
|
||||
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
||||
// Log.e("fht", "TimeChangedReceiver:" + "time changed");
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time changed");
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
||||
// Log.e("fht", "TimeChangedReceiver:" + "timezone changed");
|
||||
Log.e("fht", "TimeChangedReceiver:" + "timezone changed");
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
||||
// Log.e("fht", "TimeChangedReceiver:" + "time tick");
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time tick");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnterAnimationComplete() {
|
||||
super.onEnterAnimationComplete();
|
||||
@@ -1096,54 +1090,90 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
RaceConditionTracker.onEvent(ON_START_EVT, ENTER);
|
||||
super.onStart();
|
||||
removeRecentTask();
|
||||
String packagename = MyApplication.getInstance().getAppPackageName();
|
||||
Log.e("SendcloseApp", "packagename=" + packagename);
|
||||
if (packagename != null && packagename.length() > 0) {
|
||||
SendcloseApp(packagename);
|
||||
// if (!APKUtils.isSystemApp(this, packagename) && !Arrays.asList(ItemClickHandler.packages).contains(packagename)) {
|
||||
// try {
|
||||
// AppInformation app = getInfoFromPackageName(packagename);
|
||||
// if (app != null) {
|
||||
// long time = app.getUsedTimebyDay() / 1000;
|
||||
// Log.e("fht", "返回运行时间: " + DateUtils.formatElapsedTime(time));
|
||||
// Log.e("fht", "返回运行时间: " + time);
|
||||
//
|
||||
//// if (userInfo != null) {
|
||||
//// HTTPInterface.sendTimeLog(handler, userInfo, app.getLabel(), 2, time - MyApplication.getInstance().getRunTime());
|
||||
//// } else {
|
||||
//// Log.e("fht", "userInfo = null");
|
||||
//// }
|
||||
// } else {
|
||||
// Log.e("fht", "app = null" + packagename);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// Log.e("fht", e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Log.e("packagename", "packagename is null");
|
||||
}
|
||||
|
||||
if (mLauncherCallbacks != null) {
|
||||
mLauncherCallbacks.onStart();
|
||||
}
|
||||
mAppWidgetHost.setListenIfResumed(true);
|
||||
RaceConditionTracker.onEvent(ON_START_EVT, EXIT);
|
||||
|
||||
/*移除最近任务列表*/
|
||||
TimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
removeRecentTask();
|
||||
String packageName = TimeUtils.getInstance().getAppPackageName();
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
Log.e("onStart", "app = null" + packageName);
|
||||
return;
|
||||
}
|
||||
sendAppUsageRecord(packageName);
|
||||
}
|
||||
|
||||
private void sendAppUsageRecord(String packageName) {
|
||||
Log.e("sendAppUsageRecord", "packageName: " + packageName);
|
||||
String app_name = ApkUtils.getAppNameByPackage(Launcher.this, packageName);
|
||||
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(Launcher.this), packageName, app_name, openTime, closeTime)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAppUsageRecord", "onSubscribe: ");
|
||||
}
|
||||
private static void SendcloseApp(String packageName) {
|
||||
PackageManager pm = MyApplication.getInstance().getPackageManager();
|
||||
PackageInfo appInfo = null;
|
||||
try {
|
||||
appInfo = pm.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != appInfo) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = appInfo.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = appInfo.versionCode;
|
||||
}
|
||||
AddAppLog appLog = NetWorkManager.getInstance().getapplogControl();
|
||||
String sn = Utils.getSerial();
|
||||
appLog.addLog(sn, packageName, appVersionCode, System.currentTimeMillis() / 1000, 2)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAppUsageRecord", "onNext: " + baseResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsageRecord", "onError: " + e.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
Log.e("SendcloseApp", "onNext: " + code + baseResponse.data);
|
||||
} else {
|
||||
Log.e("SendcloseApp", "onNext: " + code + baseResponse.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("SendcloseApp", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsageRecord", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1189,9 +1219,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
Log.e(TAG, "onResume: ");
|
||||
RaceConditionTracker.onEvent(ON_RESUME_EVT, ENTER);
|
||||
TraceHelper.beginSection("ON_RESUME");
|
||||
super.onResume();
|
||||
removeRecentTask();
|
||||
start.onstar(System.currentTimeMillis());
|
||||
TraceHelper.partitionSection("ON_RESUME", "superCall");
|
||||
|
||||
mHandler.removeCallbacks(mHandleDeferredResume);
|
||||
@@ -1212,35 +1245,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
TraceHelper.endSection("ON_RESUME");
|
||||
RaceConditionTracker.onEvent(ON_RESUME_EVT, EXIT);
|
||||
|
||||
Log.e(TAG, "onResume: ");
|
||||
/*打开霸屏应用*/
|
||||
isForeground = true;
|
||||
MyApplication.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
MyApplication.getInstance().setOnClickTime(System.currentTimeMillis());
|
||||
HTTPInterface.getAppPasswd();
|
||||
start.onstar(System.currentTimeMillis());
|
||||
String always_top_packagename = Settings.System.getString(getContentResolver(), "always_top_packagename");
|
||||
if (!TextUtils.isEmpty(always_top_packagename)) {
|
||||
if ("com.tongyi.aistudent".equalsIgnoreCase(always_top_packagename)) {
|
||||
ApkUtils.openPackage(Launcher.this, "com.tongyi.aistudent", "com.tongyi.aistudent.activity.login.SplashActivity");
|
||||
} else {
|
||||
ApkUtils.openPackage(Launcher.this, always_top_packagename);
|
||||
}
|
||||
APKUtils.openPackage(Launcher.this, always_top_packagename);
|
||||
}
|
||||
mUpdate.checkUpdate(System.currentTimeMillis());
|
||||
mPasswd.getPassword(System.currentTimeMillis());
|
||||
TimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
NetInterfaceManager.getInstance().sendRunningApp(Launcher.this);
|
||||
JgyUtils.getInstance().wakeUpAppstore();
|
||||
JgyUtils.getInstance().wakeUpDeviceInfo();
|
||||
checkIsRest();
|
||||
JgyUtils.getInstance().checkAoleyunApp();
|
||||
|
||||
}
|
||||
|
||||
private void checkIsRest() {
|
||||
int desktop_clear = Settings.Global.getInt(getContentResolver(), "desktop_clear", 0);
|
||||
int aihuaUnlock = Settings.Global.getInt(getContentResolver(), "Aihua_unlock_state", 0);
|
||||
if ((!JgyUtils.getInstance().getDeviceIsLocked() || aihuaUnlock == 1) && desktop_clear != 1) {
|
||||
Settings.Global.putInt(getContentResolver(), "desktop_clear", 1);
|
||||
JgyUtils.getInstance().cleanAoleLauncher3Cache();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeRecentTask() {
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@@ -1254,65 +1270,29 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
if (appPasswdBeans != null) {
|
||||
for (AppPasswdBean bean : appPasswdBeans) {
|
||||
Log.e(TAG, "removeRecentTask: " + bean.getApp_package());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
Utils.removeTask(bean.getApp_package());
|
||||
}
|
||||
Utils.removeTask(bean.getApp_package());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private Passwd mPasswd;
|
||||
|
||||
private interface Passwd {
|
||||
void getPassword(long time);
|
||||
private Start start;
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
}
|
||||
|
||||
private ObservableOnSubscribe<Long> passwdSubscribe = new ObservableOnSubscribe<Long>() {
|
||||
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter emitter) throws Exception {
|
||||
mPasswd = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> passwdObserver = new Observer<Long>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("passwdObserver", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("passwdObserver", "onNext: " + aLong);
|
||||
NetInterfaceManager.getInstance().getAppPasswd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("passwdObserver", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("passwdObserver", "onComplete: ");
|
||||
}
|
||||
};
|
||||
|
||||
private Update mUpdate;
|
||||
|
||||
private interface Update {
|
||||
void checkUpdate(long time);
|
||||
}
|
||||
|
||||
private ObservableOnSubscribe<Long> updateSubscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter emitter) throws Exception {
|
||||
mUpdate = emitter::onNext;
|
||||
start = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<Long> updateObserver = new Observer<Long>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("updateObserver", "onSubscribe: ");
|
||||
@@ -1336,11 +1316,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
};
|
||||
|
||||
private void checkUpdate() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getCheckUpdateObservable()
|
||||
NetWorkManager.getInstance().getCheckUpdateObservable()
|
||||
.getCheckUpdate(BuildConfig.APPLICATION_ID,
|
||||
BuildConfig.VERSION_CODE,
|
||||
JgyUtils.getInstance().checkAppPlatform())
|
||||
JGYUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<NewestAppUpdateResult>>() {
|
||||
@@ -1374,7 +1353,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
|
||||
private void checkAppUpdate(NewestAppUpdateResult result) {
|
||||
int version_code = result.getVersion_code();
|
||||
int app_version_code = result.getVersion_code();
|
||||
String app_package = result.getApp_package();
|
||||
String url = result.getUrl();
|
||||
PackageInfo info = null;
|
||||
@@ -1383,13 +1362,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = info.versionCode;
|
||||
}
|
||||
if (info != null && appVersionCode < version_code) {
|
||||
if (info == null || info.versionCode < app_version_code || info.getLongVersionCode() < app_version_code) {
|
||||
Aria.download(this)
|
||||
.load(url)
|
||||
.setExtendField(result.toString())
|
||||
@@ -1418,6 +1391,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
if (mLauncherCallbacks != null) {
|
||||
mLauncherCallbacks.onPause();
|
||||
}
|
||||
isForeground = false;
|
||||
// removeRecentTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1926,6 +1901,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
if (mLauncherCallbacks != null) {
|
||||
mLauncherCallbacks.onDestroy();
|
||||
}
|
||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
|
||||
}
|
||||
|
||||
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
|
||||
@@ -2106,7 +2082,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
FolderIcon addFolder(CellLayout layout, int container, final int screenId, int cellX,
|
||||
int cellY) {
|
||||
final FolderInfo folderInfo = new FolderInfo();
|
||||
/*修改默认文件夹名*/
|
||||
folderInfo.title = getText(R.string.folder_name);
|
||||
|
||||
// Update the model
|
||||
|
||||
@@ -273,7 +273,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (DEBUG_RECEIVER) Log.d(TAG, "onReceive intent=" + intent);
|
||||
// Log.e("fht","onReceive intent=" + intent);
|
||||
Log.e("fht","onReceive intent=" + intent);
|
||||
|
||||
final String action = intent.getAction();
|
||||
if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
|
||||
@@ -317,20 +317,12 @@ public class LauncherModel extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新日历图标
|
||||
* @param user
|
||||
*/
|
||||
void changedData(UserHandle user) {
|
||||
final String calendar = "com.android.calendar";
|
||||
enqueueModelUpdateTask(
|
||||
new PackageUpdatedTask(PackageUpdatedTask.OP_UPDATE, user, calendar));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时钟图标
|
||||
* @param user
|
||||
*/
|
||||
void changedTime(UserHandle user) {
|
||||
final String deskclock = "com.android.deskclock";
|
||||
enqueueModelUpdateTask(
|
||||
|
||||
@@ -164,7 +164,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection,
|
||||
String[] selectionArgs, String sortOrder) {
|
||||
String[] selectionArgs, String sortOrder) {
|
||||
createDbIfNotExists();
|
||||
|
||||
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
|
||||
@@ -245,7 +245,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
|
||||
int appWidgetId = widgetHost.allocateAppWidgetId();
|
||||
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
|
||||
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
|
||||
if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,cn)) {
|
||||
widgetHost.deleteAppWidgetId(appWidgetId);
|
||||
return false;
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
clearFlagEmptyDbCreated();
|
||||
return null;
|
||||
}
|
||||
case LauncherSettings.Settings.METHOD_WAS_EMPTY_DB_CREATED: {
|
||||
case LauncherSettings.Settings.METHOD_WAS_EMPTY_DB_CREATED : {
|
||||
Bundle result = new Bundle();
|
||||
result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
|
||||
Utilities.getPrefs(getContext()).getBoolean(EMPTY_DATABASE_CREATED, false));
|
||||
@@ -381,7 +381,6 @@ public class LauncherProvider extends ContentProvider {
|
||||
}
|
||||
case LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB: {
|
||||
mOpenHelper.createEmptyDB(mOpenHelper.getWritableDatabase());
|
||||
// sanitizeDuplicateItems(mOpenHelper.getWritableDatabase());
|
||||
return null;
|
||||
}
|
||||
case LauncherSettings.Settings.METHOD_LOAD_DEFAULT_FAVORITES: {
|
||||
@@ -407,29 +406,8 @@ public class LauncherProvider extends ContentProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sanitizeDuplicateItems(SQLiteDatabase db) {
|
||||
db.beginTransaction();
|
||||
try {
|
||||
// 查出桌面上所有应用的 intent, screen, cellX, cellY 以及 id
|
||||
// 编写 SQL 删除那些 intent 相同、且 ID 较大的重复行
|
||||
String deleteQuery = "DELETE FROM favorites WHERE id NOT IN (" +
|
||||
"SELECT MIN(id) FROM favorites " +
|
||||
"WHERE itemType = 0 " + // ITEM_TYPE_APPLICATION
|
||||
"GROUP BY intent, container, screen, cellX, cellY" +
|
||||
") AND container = -100"; // -100 代表桌面 WORKSPACE
|
||||
|
||||
db.execSQL(deleteQuery);
|
||||
db.setTransactionSuccessful();
|
||||
} catch (Exception e) {
|
||||
Log.e("LauncherProvider", "Failed to sanitize duplicates", e);
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes any empty folder from the DB.
|
||||
*
|
||||
* @return Ids of deleted folders.
|
||||
*/
|
||||
private IntArray deleteEmptyFolders() {
|
||||
@@ -438,9 +416,9 @@ public class LauncherProvider extends ContentProvider {
|
||||
// Select folders whose id do not match any container value.
|
||||
String selection = LauncherSettings.Favorites.ITEM_TYPE + " = "
|
||||
+ LauncherSettings.Favorites.ITEM_TYPE_FOLDER + " AND "
|
||||
+ LauncherSettings.Favorites._ID + " NOT IN (SELECT " +
|
||||
LauncherSettings.Favorites.CONTAINER + " FROM "
|
||||
+ Favorites.TABLE_NAME + ")";
|
||||
+ LauncherSettings.Favorites._ID + " NOT IN (SELECT " +
|
||||
LauncherSettings.Favorites.CONTAINER + " FROM "
|
||||
+ Favorites.TABLE_NAME + ")";
|
||||
|
||||
IntArray folderIds = LauncherDbUtils.queryIntArray(db, Favorites.TABLE_NAME,
|
||||
Favorites._ID, selection, null, null);
|
||||
@@ -463,8 +441,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
mListenerHandler.sendEmptyMessage(ChangeListenerWrapper.MSG_LAUNCHER_PROVIDER_CHANGED);
|
||||
}
|
||||
|
||||
@Thunk
|
||||
static void addModifiedTime(ContentValues values) {
|
||||
@Thunk static void addModifiedTime(ContentValues values) {
|
||||
values.put(LauncherSettings.Favorites.MODIFIED, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -474,10 +451,10 @@ public class LauncherProvider extends ContentProvider {
|
||||
|
||||
/**
|
||||
* Loads the default workspace based on the following priority scheme:
|
||||
* 1) From the app restrictions
|
||||
* 2) From a package provided by play store
|
||||
* 3) From a partner configuration APK, already in the system image
|
||||
* 4) The default configuration for the particular device
|
||||
* 1) From the app restrictions
|
||||
* 2) From a package provided by play store
|
||||
* 3) From a partner configuration APK, already in the system image
|
||||
* 4) The default configuration for the particular device
|
||||
*/
|
||||
synchronized private void loadDefaultFavoritesIfNecessary() {
|
||||
SharedPreferences sp = Utilities.getPrefs(getContext());
|
||||
@@ -488,7 +465,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
AppWidgetHost widgetHost = mOpenHelper.newLauncherWidgetHost();
|
||||
AutoInstallsLayout loader = createWorkspaceLoaderFromAppRestriction(widgetHost);
|
||||
if (loader == null) {
|
||||
loader = AutoInstallsLayout.get(getContext(), widgetHost, mOpenHelper);
|
||||
loader = AutoInstallsLayout.get(getContext(),widgetHost, mOpenHelper);
|
||||
}
|
||||
if (loader == null) {
|
||||
final Partner partner = Partner.get(getContext().getPackageManager());
|
||||
@@ -561,7 +538,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
ctx.getPackageManager().getResourcesForApplication(pi.applicationInfo),
|
||||
() -> parser, AutoInstallsLayout.TAG_WORKSPACE);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error getting layout stream from: " + authority, e);
|
||||
Log.e(TAG, "Error getting layout stream from: " + authority , e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -866,12 +843,11 @@ public class LauncherProvider extends ContentProvider {
|
||||
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
|
||||
* launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
|
||||
*/
|
||||
@Thunk
|
||||
void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
|
||||
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
|
||||
try (LauncherDbUtils.SQLiteTransaction t = new LauncherDbUtils.SQLiteTransaction(db);
|
||||
// Only consider the primary user as other users can't have a shortcut.
|
||||
Cursor c = db.query(Favorites.TABLE_NAME,
|
||||
new String[]{Favorites._ID, Favorites.INTENT},
|
||||
new String[] { Favorites._ID, Favorites.INTENT},
|
||||
"itemType=" + Favorites.ITEM_TYPE_SHORTCUT +
|
||||
" AND profileId=" + getDefaultUserSerial(),
|
||||
null, null, null, null);
|
||||
@@ -905,8 +881,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Thunk
|
||||
boolean updateFolderItemsRank(SQLiteDatabase db, boolean addRankColumn) {
|
||||
@Thunk boolean updateFolderItemsRank(SQLiteDatabase db, boolean addRankColumn) {
|
||||
try (LauncherDbUtils.SQLiteTransaction t = new LauncherDbUtils.SQLiteTransaction(db)) {
|
||||
if (addRankColumn) {
|
||||
// Insert new column for holding rank
|
||||
@@ -915,14 +890,14 @@ public class LauncherProvider extends ContentProvider {
|
||||
|
||||
// Get a map for folder ID to folder width
|
||||
Cursor c = db.rawQuery("SELECT container, MAX(cellX) FROM favorites"
|
||||
+ " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
|
||||
+ " GROUP BY container;",
|
||||
new String[]{Integer.toString(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)});
|
||||
+ " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
|
||||
+ " GROUP BY container;",
|
||||
new String[] {Integer.toString(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)});
|
||||
|
||||
while (c.moveToNext()) {
|
||||
db.execSQL("UPDATE favorites SET rank=cellX+(cellY*?) WHERE "
|
||||
+ "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
|
||||
new Object[]{c.getLong(1) + 1, c.getLong(0)});
|
||||
+ "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
|
||||
new Object[] {c.getLong(1) + 1, c.getLong(0)});
|
||||
}
|
||||
|
||||
c.close();
|
||||
@@ -1005,8 +980,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
Favorites.CONTAINER_DESKTOP);
|
||||
}
|
||||
|
||||
@Thunk
|
||||
int loadFavorites(SQLiteDatabase db, AutoInstallsLayout loader) {
|
||||
@Thunk int loadFavorites(SQLiteDatabase db, AutoInstallsLayout loader) {
|
||||
// TODO: Use multiple loaders with fall-back and transaction.
|
||||
int count = loader.loadLayout(db, new IntArray());
|
||||
|
||||
@@ -1020,8 +994,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
/**
|
||||
* @return the max _id in the provided table.
|
||||
*/
|
||||
@Thunk
|
||||
static int getMaxId(SQLiteDatabase db, String query, Object... args) {
|
||||
@Thunk static int getMaxId(SQLiteDatabase db, String query, Object... args) {
|
||||
int max = (int) DatabaseUtils.longForQuery(db,
|
||||
String.format(Locale.ENGLISH, query, args),
|
||||
null);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.statistics;
|
||||
package com.aoleyun.os.Statistics;
|
||||
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.statistics;
|
||||
package com.aoleyun.os.Statistics;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.usage.UsageEvents;
|
||||
@@ -14,7 +14,7 @@ import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.aoleyun.os.statistics.AppInformation.bootTime;
|
||||
import static com.aoleyun.os.Statistics.AppInformation.bootTime;
|
||||
|
||||
|
||||
public class StatisticsInfo {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
@@ -17,7 +17,6 @@ import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
import com.aoleyun.os.receiver.InstallResultReceiver;
|
||||
import com.hjq.toast.Toaster;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -27,32 +26,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class ApkUtils {
|
||||
|
||||
private static final String TAG = ApkUtils.class.getSimpleName();
|
||||
|
||||
public static boolean openPackage(Context context, String packageName, String className) {
|
||||
if (TextUtils.isEmpty(className)) {
|
||||
return openPackage(context, packageName);
|
||||
}
|
||||
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) {
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openPackage: " + e.getMessage());
|
||||
Toaster.show("打开失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public class APKUtils {
|
||||
public static boolean openPackage(Context context, String packageName) {
|
||||
Context pkgContext = getPackageContext(context, packageName);
|
||||
Intent intent = getAppOpenIntentByPackageName(context, packageName);
|
||||
@@ -105,20 +79,6 @@ public class ApkUtils {
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查手机上是否安装了指定的软件
|
||||
*/
|
||||
public static boolean isAvailable(Context context, String packageName) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = packageManager.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return info != null;
|
||||
}
|
||||
|
||||
//判断是否为系统应用
|
||||
public static boolean isSystemApp(Context context, String pkgName) {
|
||||
boolean isSystemApp = false;
|
||||
@@ -141,16 +101,7 @@ public class ApkUtils {
|
||||
return isSystemApp;
|
||||
}
|
||||
|
||||
public static boolean isDisable(Context context, String pkg) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (pm.getApplicationEnabledSetting(pkg) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//获取APP版本号
|
||||
//获取教管易版本号
|
||||
public static String getAPPVersionName(Context context, String packageName) {
|
||||
String versionName = "0";
|
||||
|
||||
@@ -167,18 +118,6 @@ public class ApkUtils {
|
||||
return versionName;
|
||||
}
|
||||
|
||||
public static String getAppNameByPackage(Context context, String pkg) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
try {
|
||||
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(pkg, PackageManager.GET_META_DATA);
|
||||
String packageName = packageManager.getApplicationLabel(applicationInfo).toString();
|
||||
return packageName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void installApp(Context context, String filePath) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
installAppatPie(context, filePath);
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
@@ -24,7 +23,7 @@ public class BitmapUtils {
|
||||
public static Drawable getRoundedBitmap(Drawable drawable, Context context) {
|
||||
Bitmap mBitmap= drawable2bitmap(drawable);
|
||||
|
||||
// Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
Bitmap mask = BitmapFactory.decodeResource(context.getResources(), R.drawable.mask);
|
||||
int width = mask.getWidth();
|
||||
@@ -220,21 +219,7 @@ public class BitmapUtils {
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
} else {
|
||||
// 对于AdaptiveIconDrawable和其他Drawable,尝试绘制到Bitmap
|
||||
int width = drawable.getIntrinsicWidth();
|
||||
int height = drawable.getIntrinsicHeight();
|
||||
// 如果尺寸无效,使用默认尺寸
|
||||
if (width <= 0 || height <= 0) {
|
||||
// 设置一个默认尺寸,例如48dp
|
||||
float density = Resources.getSystem().getDisplayMetrics().density;
|
||||
width = (int) (48 * density);
|
||||
height = (int) (48 * density);
|
||||
}
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
106
src/com/aoleyun/os/TTUtils/ToastUtil.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
import com.aoleyun.os.R;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.blankj.utilcode.util.ColorUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Created by haoge on 2017/3/2.
|
||||
*/
|
||||
|
||||
public class ToastUtil {
|
||||
private static final String TAG = ToastUtil.class.getSimpleName();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context mContext;
|
||||
private static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
private static Toast debugToast;
|
||||
private static Toast toast;
|
||||
|
||||
|
||||
@SuppressLint("ShowToast")
|
||||
public static void init(Context context) {
|
||||
mContext = context;
|
||||
toast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
debugToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
|
||||
}
|
||||
|
||||
private static long time1 = 0L;
|
||||
private static long time2 = 0L;
|
||||
|
||||
public static void show(final String msg) {
|
||||
ToastUtils.make()
|
||||
// .setBgColor(ColorUtils.getColor(R.color.toast_color))
|
||||
.setTextColor(Color.DKGRAY)
|
||||
// .setGravity(Gravity.CENTER, 0, 0)
|
||||
.setNotUseSystemToast()
|
||||
.show(msg);
|
||||
}
|
||||
|
||||
public static void betaShow(final String msg) {
|
||||
if (JGYUtils.isBetaVersion() || BuildConfig.DEBUG) {
|
||||
ToastUtils.make()
|
||||
// .setBgColor(ColorUtils.getColor(R.color.toast_color))
|
||||
.setTextColor(Color.RED)
|
||||
// .setGravity(Gravity.CENTER, 0, 0)
|
||||
.setNotUseSystemToast()
|
||||
.setDurationIsLong(true)
|
||||
.show(msg);
|
||||
} else {
|
||||
Log.e(TAG, "debugShow: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showCenter(final String msg) {
|
||||
ToastUtils.make()
|
||||
.setBgColor(ColorUtils.getColor(R.color.toast_color))
|
||||
.setTextColor(Color.WHITE)
|
||||
.setGravity(Gravity.CENTER, 0, 0)
|
||||
.setNotUseSystemToast()
|
||||
.show(msg);
|
||||
}
|
||||
|
||||
private static Toast mToast = null;
|
||||
|
||||
//android 8.0以后限制
|
||||
//https://www.jianshu.com/p/d9813ad03d59
|
||||
//https://www.jianshu.com/p/050ce052b873
|
||||
public static void showToast(Context context, String text, int duration) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
|
||||
Toast.makeText(context, text, duration).show();
|
||||
} else {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, text, duration);
|
||||
} else {
|
||||
mToast.setText(text);
|
||||
mToast.setDuration(duration);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void showInCenter(String msg) {
|
||||
// mainHandler.post(() -> {
|
||||
// if (toast != null) {
|
||||
// toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
// toast.setText(msg);
|
||||
// toast.show();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
123
src/com/aoleyun/os/TTUtils/Utils.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.aoleyun.os.TTUtils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
public class Utils {
|
||||
private static String TAG = Utils.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 获取设备序列号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint({"MissingPermission", "NewApi"})
|
||||
public static String getSerial() {
|
||||
String serial = "unknow";
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
|
||||
serial = Build.getSerial();
|
||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
|
||||
serial = Build.SERIAL;
|
||||
} else {//8.0-
|
||||
Class<?> c = Class.forName("android.os.SystemProperties");
|
||||
Method get = c.getMethod("get", String.class);
|
||||
serial = (String) get.invoke(c, "ro.serialno");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("e", "读取设备序列号异常:" + e.toString());
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清除所有最近记录
|
||||
*/
|
||||
public void removeAllTask(Context context) {
|
||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
if (info.realActivity != null) {
|
||||
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
//排除自身
|
||||
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ActivityManagerNative.getDefault().removeTask(info.id);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeAllTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
||||
*/
|
||||
public static void removeTask(String packageName) {
|
||||
if (TextUtils.isEmpty(packageName)) return;
|
||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
HashMap<String, Integer> taskMap = new HashMap<>();
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
taskMap.put(info.realActivity.getPackageName(), info.id);
|
||||
}
|
||||
try {
|
||||
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of the recents tasks.
|
||||
* 获取近期任务列表
|
||||
*/
|
||||
public static List<ActivityManager.RecentTaskInfo> getRecentTasks(int numTasks, int userId) {
|
||||
try {
|
||||
return ActivityTaskManager.getService().getRecentTasks(numTasks,
|
||||
RECENT_IGNORE_UNAVAILABLE, userId).getList();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to get recent tasks " + e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current user's id.
|
||||
* 获取userId
|
||||
*/
|
||||
public static int getCurrentUserId() {
|
||||
UserInfo ui;
|
||||
try {
|
||||
ui = ActivityManager.getService().getCurrentUser();
|
||||
return ui != null ? ui.id : 0;
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.aoleyun.os.base;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.manager.ConnectManager;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.uiuiutils.JgyUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "onCreate: " + rootDir);
|
||||
|
||||
JgyUtils.init(this);
|
||||
TimeUtils.init(this);
|
||||
Aria.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
// 初始化 Toast 框架
|
||||
Toaster.init(this);
|
||||
ConnectManager.init(this);
|
||||
}
|
||||
}
|
||||
365
src/com/aoleyun/os/base/MyApplication.java
Normal file
@@ -0,0 +1,365 @@
|
||||
package com.aoleyun.os.base;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
import com.aoleyun.os.TTUtils.ToastUtil;
|
||||
import com.aoleyun.os.TTUtils.Utils;
|
||||
import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.network.NetWorkManager;
|
||||
import com.aoleyun.os.network.URLPath;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class MyApplication extends Application {
|
||||
private static final String TAG = MyApplication.class.getSimpleName();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static MyApplication app;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context;
|
||||
|
||||
public static MyApplication getInstance() {
|
||||
return app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
context = this;
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "onCreate: " + rootDir);
|
||||
JGYUtils.init(this);
|
||||
Aria.init(this);
|
||||
NetWorkManager.init(this);
|
||||
ToastUtil.init(this);
|
||||
|
||||
initJPush();
|
||||
}
|
||||
|
||||
private void initJPush() {
|
||||
JPushInterface.setDebugMode(BuildConfig.DEBUG); // 设置开启日志,发布时请关闭日志
|
||||
JPushInterface.init(this);
|
||||
initAliasObservable();
|
||||
initTagObservable();
|
||||
setJpushAlias();
|
||||
setJpushTags();
|
||||
}
|
||||
|
||||
private String appPackageName;
|
||||
private long runTime = 0;
|
||||
private long onClickTime = 0;
|
||||
|
||||
public void setOnClickTime(long time) {
|
||||
this.onClickTime = time;
|
||||
}
|
||||
|
||||
public long getOnClickTime() {
|
||||
return onClickTime;
|
||||
}
|
||||
|
||||
public void setAppPackageName(String name) {
|
||||
this.appPackageName = name;
|
||||
}
|
||||
|
||||
public String getAppPackageName() {
|
||||
return appPackageName;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.runTime = time;
|
||||
}
|
||||
|
||||
public long getRunTime() {
|
||||
return runTime;
|
||||
}
|
||||
|
||||
|
||||
private void initAliasObservable() {
|
||||
Log.e(TAG, "initAliasObservable: ");
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
onAliasResult = new OnAliasResult() {
|
||||
@Override
|
||||
public void onResult(int code) {
|
||||
Log.e("initAliasObservable", "onResult: " + code);
|
||||
emitter.onNext(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
}).throttleLast(1, TimeUnit.HOURS)
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Integer integer) {
|
||||
Log.e("initAliasObservable", "onNext: " + integer);
|
||||
String s = "alias:\t";
|
||||
switch (integer) {
|
||||
case 0:
|
||||
Log.e("jiguangInterface", s + "Alias绑定成功");
|
||||
break;
|
||||
case 6001:
|
||||
Log.e("jiguangInterface", s + "无效的设置");
|
||||
break;
|
||||
case 6011:
|
||||
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
|
||||
break;
|
||||
case 6013:
|
||||
Log.e("jiguangInterface", s + "用户设备时间轴异常");
|
||||
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + s + "code:6013");
|
||||
break;
|
||||
case 6022:
|
||||
Log.e("jiguangInterface", s + "alias 操作正在进行中");
|
||||
break;
|
||||
//需要重新设置
|
||||
case 6002:
|
||||
Log.e("jiguangInterface", s + "设置超时,请重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6014:
|
||||
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6020:
|
||||
Log.e("jiguangInterface", s + "建议过一段时间再设置");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6024:
|
||||
Log.e("jiguangInterface", s + "服务器内部错误");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6017:
|
||||
case 6027:
|
||||
Log.e("jiguangInterface", s + "别名绑定的设备数超过限制");
|
||||
cleanJpushAlias();
|
||||
setJpushAlias();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onAliasOperatorResult(JPushMessage jPushMessage) {
|
||||
if (jPushMessage == null) {
|
||||
return;
|
||||
}
|
||||
int errorCode = jPushMessage.getErrorCode();
|
||||
onAliasResult.onResult(errorCode);
|
||||
}
|
||||
|
||||
public static void setJpushAlias() {
|
||||
Log.e("jiguangInterface", "30s后重新设置alias");
|
||||
JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
|
||||
}
|
||||
|
||||
private void initTagObservable() {
|
||||
Log.e(TAG, "initTagObservable: ");
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) {
|
||||
onTagResult = new OnTagResult() {
|
||||
@Override
|
||||
public void onResult(int code) {
|
||||
Log.e("initTagObservable", "onResult: " + code);
|
||||
emitter.onNext(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
}).throttleLast(1, TimeUnit.HOURS)
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Integer integer) {
|
||||
Log.e("initTagObservable", "onNext: " + integer);
|
||||
String s = "tags:\t";
|
||||
switch (integer) {
|
||||
case 0:
|
||||
Log.e("jiguangInterface", s + "Tag绑定成功");
|
||||
break;
|
||||
case 6001:
|
||||
Log.e("jiguangInterface", s + "无效的设置");
|
||||
break;
|
||||
case 6005:
|
||||
Log.e("jiguangInterface", s + "某一个 tag 字符串不合法");
|
||||
ToastUtil.show("设备标签不合法,联系管理员修改\t" + "code:6005");
|
||||
break;
|
||||
case 6006:
|
||||
Log.e("jiguangInterface", s + "某一个 tag 超长");
|
||||
ToastUtil.show("设备标签过长,联系管理员修改\t" + "code:6006");
|
||||
break;
|
||||
case 6007:
|
||||
Log.e("jiguangInterface", s + "tags 数量超出限制");
|
||||
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6007");
|
||||
break;
|
||||
case 6008:
|
||||
Log.e("jiguangInterface", s + "tag 超出总长度限制");
|
||||
ToastUtil.show("设备标签超出总长度限制,联系管理员修改\t" + "code:6008");
|
||||
break;
|
||||
case 6011:
|
||||
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
|
||||
break;
|
||||
case 6013:
|
||||
Log.e("jiguangInterface", s + "用户设备时间轴异常");
|
||||
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + "code:6013");
|
||||
break;
|
||||
case 6018:
|
||||
Log.e("jiguangInterface", s + "Tags 过多");
|
||||
cleanJpushTag();
|
||||
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6018");
|
||||
break;
|
||||
case 6021:
|
||||
Log.e("jiguangInterface", s + "tags 操作正在进行中");
|
||||
break;
|
||||
//需要重新设置
|
||||
case 6002:
|
||||
Log.e("jiguangInterface", s + "设置超时,请重试");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6014:
|
||||
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6020:
|
||||
Log.e("jiguangInterface", s + "建议过一段时间再设置");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6024:
|
||||
Log.e("jiguangInterface", s + "服务器内部错误");
|
||||
setJpushTags();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onTagOperatorResult(JPushMessage jPushMessage) {
|
||||
if (jPushMessage == null) {
|
||||
return;
|
||||
}
|
||||
int errorCode = jPushMessage.getErrorCode();
|
||||
onTagResult.onResult(errorCode);
|
||||
}
|
||||
|
||||
public static void setJpushTags() {
|
||||
Log.e("jiguangInterface", "30s后重新设置tags");
|
||||
HTTPInterface.setJpushTags(context);
|
||||
}
|
||||
|
||||
private static OnAliasResult onAliasResult;
|
||||
|
||||
interface OnAliasResult {
|
||||
void onResult(int code);
|
||||
}
|
||||
|
||||
private static OnTagResult onTagResult;
|
||||
|
||||
interface OnTagResult {
|
||||
void onResult(int code);
|
||||
}
|
||||
|
||||
private String key = "MGM3YmE1YTE2MjJkYmE3OGQ1YmQwMGNjOjFjOTJiODVjZjM0ODhiNTJkNDQyNDJlOA==";
|
||||
|
||||
synchronized public void cleanJpushAlias() {
|
||||
//alias的绑定的设备超过10个,但是alias应该是一个设备对应一个,在重置设备后jpush的regid会变动,所以需要清除
|
||||
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(URLPath.DELETE_JPUSH_ALIAS + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushAlias", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushAlias", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Alias成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public void cleanJpushTag() {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(URLPath.DELETE_JPUSH_TAG + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushTag", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushTag", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Tag成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.aoleyun.os.comm;
|
||||
|
||||
public class CommonConfig {
|
||||
public static final String MMKV_ID = "InterProcessKV";
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.aoleyun.os.comm;
|
||||
|
||||
public class JGYActions {
|
||||
|
||||
/*锁定解锁设备 后台1是锁定,底层0是锁定*/
|
||||
public final static String ACTION_QCH_UNLOCK_IPAD = "qch_unlock_ipad";
|
||||
/*后台锁定*/
|
||||
public final static int NET_CODE_LOCKED = 1;
|
||||
/*后台解锁*/
|
||||
public final static int NET_CODE_UNLOCKED = 0;
|
||||
/*底层锁定*/
|
||||
public final static int FRAME_CODE_LOCKED = 0;
|
||||
/*底层解锁*/
|
||||
public final static int FRAME_CODE_UNLOCKED = 1;
|
||||
|
||||
/*
|
||||
* 需要写到底层的数据
|
||||
* */
|
||||
|
||||
/*应用管理-允许联网*/
|
||||
public final static String ACTION_HRRECEIVER_JGY = "qch_jgy_network_allow";
|
||||
/*应用管理-禁止联网*/
|
||||
public final static String ACTION_HRRECEIVER_JGY_DIS = "qch_jgy_network_disallow";
|
||||
/*状态栏*/
|
||||
public final static String ACTION_STATUSBAR_STATUS = "jgy_statusbar_status";
|
||||
|
||||
|
||||
/*
|
||||
* 应用内部的数据
|
||||
* */
|
||||
|
||||
//后台上传所有应用包名 将添加到桌面
|
||||
// TODO: 2021/10/13
|
||||
public final static String ACTION_JGY_SHORTCUTLIST = "only_jgy_shortcut_list";
|
||||
}
|
||||
@@ -1,461 +0,0 @@
|
||||
package com.aoleyun.os.disklrucache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jakewharton.disklrucache.DiskLruCache;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 磁盘缓存帮助类
|
||||
*/
|
||||
public class CacheHelper {
|
||||
private static final String TAG = "DiskLruCacheHelper";
|
||||
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private static final String DIR_NAME = "diskCache";
|
||||
private static final int MAX_COUNT = 5 * 1024 * 1024;
|
||||
private static final int DEFAULT_APP_VERSION = 1;
|
||||
|
||||
private DiskLruCache mDiskLruCache;
|
||||
|
||||
public CacheHelper(Context context) {
|
||||
mDiskLruCache = generateCache(context, DIR_NAME, MAX_COUNT);
|
||||
}
|
||||
|
||||
public CacheHelper(Context context, String dirName) {
|
||||
mDiskLruCache = generateCache(context, dirName, MAX_COUNT);
|
||||
}
|
||||
|
||||
public CacheHelper(Context context, String dirName, int maxCount) {
|
||||
mDiskLruCache = generateCache(context, dirName, maxCount);
|
||||
}
|
||||
|
||||
//custom cache dir
|
||||
public CacheHelper(File dir) {
|
||||
mDiskLruCache = generateCache(null, dir, MAX_COUNT);
|
||||
}
|
||||
|
||||
public CacheHelper(Context context, File dir) {
|
||||
mDiskLruCache = generateCache(context, dir, MAX_COUNT);
|
||||
}
|
||||
|
||||
public CacheHelper(Context context, File dir, int maxCount) {
|
||||
mDiskLruCache = generateCache(context, dir, maxCount);
|
||||
}
|
||||
|
||||
private DiskLruCache generateCache(Context context, File dir, int maxCount) {
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
throw new IllegalArgumentException(
|
||||
dir + " is not a directory or does not exists. ");
|
||||
}
|
||||
|
||||
int appVersion = context == null ? DEFAULT_APP_VERSION : Utils.getAppVersion(context);
|
||||
|
||||
DiskLruCache diskLruCache = null;
|
||||
try {
|
||||
diskLruCache = DiskLruCache.open(
|
||||
dir,
|
||||
appVersion,
|
||||
DEFAULT_APP_VERSION,
|
||||
maxCount);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return diskLruCache;
|
||||
}
|
||||
|
||||
private DiskLruCache generateCache(Context context, String dirName, int maxCount) {
|
||||
DiskLruCache diskLruCache = null;
|
||||
try {
|
||||
diskLruCache = DiskLruCache.open(
|
||||
getDiskCacheDir(context, dirName),
|
||||
Utils.getAppVersion(context),
|
||||
DEFAULT_APP_VERSION,
|
||||
maxCount);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return diskLruCache;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============== String 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
public void put(String key, String value) {
|
||||
Log.e(TAG, "put: " + key);
|
||||
mMMKV.encode(key, System.currentTimeMillis());
|
||||
|
||||
DiskLruCache.Editor edit = null;
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
edit = editor(key);
|
||||
if (edit == null) {
|
||||
return;
|
||||
}
|
||||
OutputStream os = edit.newOutputStream(0);
|
||||
bw = new BufferedWriter(new OutputStreamWriter(os));
|
||||
bw.write(value);
|
||||
edit.commit();//write CLEAN
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
//s
|
||||
edit.abort();//write REMOVE
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (bw != null) {
|
||||
bw.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAsString(String key) {
|
||||
Log.e(TAG, "getAsString: " + key);
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
//write READ
|
||||
inputStream = get(key);
|
||||
if (inputStream == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = 0;
|
||||
byte[] buf = new byte[128];
|
||||
while ((len = inputStream.read(buf)) != -1) {
|
||||
sb.append(new String(buf, 0, len));
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void put(String key, JSONObject jsonObject) {
|
||||
put(key, jsonObject.toString());
|
||||
}
|
||||
|
||||
public JSONObject getAsJson(String key) {
|
||||
String val = getAsString(key);
|
||||
try {
|
||||
if (val != null) {
|
||||
return new JSONObject(val);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============ JSONArray 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
public void put(String key, JSONArray jsonArray) {
|
||||
put(key, jsonArray.toString());
|
||||
}
|
||||
|
||||
public JSONArray getAsJSONArray(String key) {
|
||||
String JSONString = getAsString(key);
|
||||
try {
|
||||
JSONArray obj = new JSONArray(JSONString);
|
||||
return obj;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============== byte 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* 保存 byte数据 到 缓存中
|
||||
*
|
||||
* @param key 保存的key
|
||||
* @param value 保存的数据
|
||||
*/
|
||||
public void put(String key, byte[] value) {
|
||||
OutputStream out = null;
|
||||
DiskLruCache.Editor editor = null;
|
||||
try {
|
||||
editor = editor(key);
|
||||
if (editor == null) {
|
||||
return;
|
||||
}
|
||||
out = editor.newOutputStream(0);
|
||||
out.write(value);
|
||||
out.flush();
|
||||
editor.commit();//write CLEAN
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
editor.abort();//write REMOVE
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] getAsBytes(String key) {
|
||||
byte[] res = null;
|
||||
InputStream is = get(key);
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
byte[] buf = new byte[256];
|
||||
int len = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
baos.write(buf, 0, len);
|
||||
}
|
||||
res = baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ============== 序列化 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Serializable value) {
|
||||
DiskLruCache.Editor editor = editor(key);
|
||||
ObjectOutputStream oos = null;
|
||||
if (editor == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
OutputStream os = editor.newOutputStream(0);
|
||||
oos = new ObjectOutputStream(os);
|
||||
oos.writeObject(value);
|
||||
oos.flush();
|
||||
editor.commit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
editor.abort();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (oos != null) {
|
||||
oos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getAsSerializable(String key) {
|
||||
T t = null;
|
||||
InputStream is = get(key);
|
||||
ObjectInputStream ois = null;
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
ois = new ObjectInputStream(is);
|
||||
t = (T) ois.readObject();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (ois != null) {
|
||||
ois.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============== bitmap 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Bitmap bitmap) {
|
||||
put(key, Utils.bitmap2Bytes(bitmap));
|
||||
}
|
||||
|
||||
public Bitmap getAsBitmap(String key) {
|
||||
byte[] bytes = getAsBytes(key);
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
return Utils.bytes2Bitmap(bytes);
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============= drawable 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Drawable value) {
|
||||
put(key, Utils.drawable2Bitmap(value));
|
||||
}
|
||||
|
||||
public Drawable getAsDrawable(String key) {
|
||||
byte[] bytes = getAsBytes(key);
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
return Utils.bitmap2Drawable(Utils.bytes2Bitmap(bytes));
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============= other methods =============
|
||||
// =======================================
|
||||
public boolean remove(String key) {
|
||||
try {
|
||||
key = Utils.hashKeyForDisk(key);
|
||||
return mDiskLruCache.remove(key);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
mDiskLruCache.close();
|
||||
}
|
||||
|
||||
public void delete() throws IOException {
|
||||
mDiskLruCache.delete();
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
mDiskLruCache.flush();
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return mDiskLruCache.isClosed();
|
||||
}
|
||||
|
||||
public long size() {
|
||||
return mDiskLruCache.size();
|
||||
}
|
||||
|
||||
public void setMaxSize(long maxSize) {
|
||||
mDiskLruCache.setMaxSize(maxSize);
|
||||
}
|
||||
|
||||
public File getDirectory() {
|
||||
return mDiskLruCache.getDirectory();
|
||||
}
|
||||
|
||||
public long getMaxSize() {
|
||||
return mDiskLruCache.getMaxSize();
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ===遇到文件比较大的,可以直接通过流读写 =====
|
||||
// =======================================
|
||||
//basic editor
|
||||
public DiskLruCache.Editor editor(String key) {
|
||||
try {
|
||||
key = Utils.hashKeyForDisk(key);
|
||||
//wirte DIRTY
|
||||
DiskLruCache.Editor edit = mDiskLruCache.edit(key);
|
||||
//edit maybe null :the entry is editing
|
||||
if (edit == null) {
|
||||
Log.w(TAG, "the entry spcified key:" + key + " is editing by other . ");
|
||||
}
|
||||
return edit;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//basic get
|
||||
public InputStream get(String key) {
|
||||
try {
|
||||
DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key));
|
||||
if (snapshot == null) //not find entry , or entry.readable = false
|
||||
{
|
||||
Log.e(TAG, "not find entry , or entry.readable = false");
|
||||
return null;
|
||||
}
|
||||
//write READ
|
||||
return snapshot.getInputStream(0);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ============== 序列化 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
private File getDiskCacheDir(Context context, String uniqueName) {
|
||||
String cachePath;
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|
||||
|| !Environment.isExternalStorageRemovable()) {
|
||||
cachePath = context.getExternalCacheDir().getPath();
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
return new File(cachePath + File.separator + uniqueName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,427 +0,0 @@
|
||||
package com.aoleyun.os.disklrucache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jakewharton.disklrucache.DiskLruCache;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 磁盘缓存帮助类
|
||||
*/
|
||||
public class DiskLruCacheHelper {
|
||||
private static final String DIR_NAME = "diskCache";
|
||||
private static final int MAX_COUNT = 5 * 1024 * 1024;
|
||||
private static final int DEFAULT_APP_VERSION = 1;
|
||||
|
||||
private static final String TAG = "DiskLruCacheHelper";
|
||||
|
||||
private DiskLruCache mDiskLruCache;
|
||||
|
||||
public DiskLruCacheHelper(Context context) throws IOException {
|
||||
mDiskLruCache = generateCache(context, DIR_NAME, MAX_COUNT);
|
||||
}
|
||||
|
||||
public DiskLruCacheHelper(Context context, String dirName) throws IOException {
|
||||
mDiskLruCache = generateCache(context, dirName, MAX_COUNT);
|
||||
}
|
||||
|
||||
public DiskLruCacheHelper(Context context, String dirName, int maxCount) throws IOException {
|
||||
mDiskLruCache = generateCache(context, dirName, maxCount);
|
||||
}
|
||||
|
||||
//custom cache dir
|
||||
public DiskLruCacheHelper(File dir) throws IOException {
|
||||
mDiskLruCache = generateCache(null, dir, MAX_COUNT);
|
||||
}
|
||||
|
||||
public DiskLruCacheHelper(Context context, File dir) throws IOException {
|
||||
mDiskLruCache = generateCache(context, dir, MAX_COUNT);
|
||||
}
|
||||
|
||||
public DiskLruCacheHelper(Context context, File dir, int maxCount) throws IOException {
|
||||
mDiskLruCache = generateCache(context, dir, maxCount);
|
||||
}
|
||||
|
||||
private DiskLruCache generateCache(Context context, File dir, int maxCount) throws IOException {
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
throw new IllegalArgumentException(
|
||||
dir + " is not a directory or does not exists. ");
|
||||
}
|
||||
|
||||
int appVersion = context == null ? DEFAULT_APP_VERSION : Utils.getAppVersion(context);
|
||||
|
||||
DiskLruCache diskLruCache = DiskLruCache.open(
|
||||
dir,
|
||||
appVersion,
|
||||
DEFAULT_APP_VERSION,
|
||||
maxCount);
|
||||
|
||||
return diskLruCache;
|
||||
}
|
||||
|
||||
private DiskLruCache generateCache(Context context, String dirName, int maxCount) throws IOException {
|
||||
DiskLruCache diskLruCache = DiskLruCache.open(
|
||||
getDiskCacheDir(context, dirName),
|
||||
Utils.getAppVersion(context),
|
||||
DEFAULT_APP_VERSION,
|
||||
maxCount);
|
||||
return diskLruCache;
|
||||
}
|
||||
// =======================================
|
||||
// ============== String 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
public void put(String key, String value) {
|
||||
DiskLruCache.Editor edit = null;
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
edit = editor(key);
|
||||
if (edit == null) return;
|
||||
OutputStream os = edit.newOutputStream(0);
|
||||
bw = new BufferedWriter(new OutputStreamWriter(os));
|
||||
bw.write(value);
|
||||
edit.commit();//write CLEAN
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
//s
|
||||
edit.abort();//write REMOVE
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (bw != null)
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAsString(String key) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
//write READ
|
||||
inputStream = get(key);
|
||||
if (inputStream == null) return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = 0;
|
||||
byte[] buf = new byte[128];
|
||||
while ((len = inputStream.read(buf)) != -1) {
|
||||
sb.append(new String(buf, 0, len));
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (inputStream != null)
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void put(String key, JSONObject jsonObject) {
|
||||
put(key, jsonObject.toString());
|
||||
}
|
||||
|
||||
public JSONObject getAsJson(String key) {
|
||||
String val = getAsString(key);
|
||||
try {
|
||||
if (val != null)
|
||||
return new JSONObject(val);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============ JSONArray 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
public void put(String key, JSONArray jsonArray) {
|
||||
put(key, jsonArray.toString());
|
||||
}
|
||||
|
||||
public JSONArray getAsJSONArray(String key) {
|
||||
String JSONString = getAsString(key);
|
||||
try {
|
||||
JSONArray obj = new JSONArray(JSONString);
|
||||
return obj;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============== byte 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* 保存 byte数据 到 缓存中
|
||||
*
|
||||
* @param key 保存的key
|
||||
* @param value 保存的数据
|
||||
*/
|
||||
public void put(String key, byte[] value) {
|
||||
OutputStream out = null;
|
||||
DiskLruCache.Editor editor = null;
|
||||
try {
|
||||
editor = editor(key);
|
||||
if (editor == null) {
|
||||
return;
|
||||
}
|
||||
out = editor.newOutputStream(0);
|
||||
out.write(value);
|
||||
out.flush();
|
||||
editor.commit();//write CLEAN
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
editor.abort();//write REMOVE
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] getAsBytes(String key) {
|
||||
byte[] res = null;
|
||||
InputStream is = get(key);
|
||||
if (is == null) return null;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
byte[] buf = new byte[256];
|
||||
int len = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
baos.write(buf, 0, len);
|
||||
}
|
||||
res = baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ============== 序列化 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Serializable value) {
|
||||
DiskLruCache.Editor editor = editor(key);
|
||||
ObjectOutputStream oos = null;
|
||||
if (editor == null) return;
|
||||
try {
|
||||
OutputStream os = editor.newOutputStream(0);
|
||||
oos = new ObjectOutputStream(os);
|
||||
oos.writeObject(value);
|
||||
oos.flush();
|
||||
editor.commit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
editor.abort();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (oos != null)
|
||||
oos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getAsSerializable(String key) {
|
||||
T t = null;
|
||||
InputStream is = get(key);
|
||||
ObjectInputStream ois = null;
|
||||
if (is == null) return null;
|
||||
try {
|
||||
ois = new ObjectInputStream(is);
|
||||
t = (T) ois.readObject();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (ois != null)
|
||||
ois.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============== bitmap 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Bitmap bitmap) {
|
||||
put(key, Utils.bitmap2Bytes(bitmap));
|
||||
}
|
||||
|
||||
public Bitmap getAsBitmap(String key) {
|
||||
byte[] bytes = getAsBytes(key);
|
||||
if (bytes == null) return null;
|
||||
return Utils.bytes2Bitmap(bytes);
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============= drawable 数据 读写 =============
|
||||
// =======================================
|
||||
public void put(String key, Drawable value) {
|
||||
put(key, Utils.drawable2Bitmap(value));
|
||||
}
|
||||
|
||||
public Drawable getAsDrawable(String key) {
|
||||
byte[] bytes = getAsBytes(key);
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
}
|
||||
return Utils.bitmap2Drawable(Utils.bytes2Bitmap(bytes));
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// ============= other methods =============
|
||||
// =======================================
|
||||
public boolean remove(String key) {
|
||||
try {
|
||||
key = Utils.hashKeyForDisk(key);
|
||||
return mDiskLruCache.remove(key);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
mDiskLruCache.close();
|
||||
}
|
||||
|
||||
public void delete() throws IOException {
|
||||
mDiskLruCache.delete();
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
mDiskLruCache.flush();
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return mDiskLruCache.isClosed();
|
||||
}
|
||||
|
||||
public long size() {
|
||||
return mDiskLruCache.size();
|
||||
}
|
||||
|
||||
public void setMaxSize(long maxSize) {
|
||||
mDiskLruCache.setMaxSize(maxSize);
|
||||
}
|
||||
|
||||
public File getDirectory() {
|
||||
return mDiskLruCache.getDirectory();
|
||||
}
|
||||
|
||||
public long getMaxSize() {
|
||||
return mDiskLruCache.getMaxSize();
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ===遇到文件比较大的,可以直接通过流读写 =====
|
||||
// =======================================
|
||||
//basic editor
|
||||
public DiskLruCache.Editor editor(String key) {
|
||||
try {
|
||||
key = Utils.hashKeyForDisk(key);
|
||||
//wirte DIRTY
|
||||
DiskLruCache.Editor edit = mDiskLruCache.edit(key);
|
||||
//edit maybe null :the entry is editing
|
||||
if (edit == null) {
|
||||
Log.w(TAG, "the entry spcified key:" + key + " is editing by other . ");
|
||||
}
|
||||
return edit;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//basic get
|
||||
public InputStream get(String key) {
|
||||
try {
|
||||
DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key));
|
||||
if (snapshot == null) //not find entry , or entry.readable = false
|
||||
{
|
||||
Log.e(TAG, "not find entry , or entry.readable = false");
|
||||
return null;
|
||||
}
|
||||
//write READ
|
||||
return snapshot.getInputStream(0);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
// ============== 序列化 数据 读写 =============
|
||||
// =======================================
|
||||
|
||||
private File getDiskCacheDir(Context context, String uniqueName) {
|
||||
String cachePath;
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|
||||
|| !Environment.isExternalStorageRemovable()) {
|
||||
cachePath = context.getExternalCacheDir().getPath();
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
return new File(cachePath + File.separator + uniqueName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.aoleyun.os.disklrucache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class Utils {
|
||||
public static int getAppVersion(Context context) {
|
||||
try {
|
||||
PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
return info.versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public static String hashKeyForDisk(String key) {
|
||||
String cacheKey;
|
||||
try {
|
||||
final MessageDigest mDigest = MessageDigest.getInstance("MD5");
|
||||
mDigest.update(key.getBytes());
|
||||
cacheKey = bytesToHexString(mDigest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
cacheKey = String.valueOf(key.hashCode());
|
||||
}
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
public static String bytesToHexString(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
String hex = Integer.toHexString(0xFF & bytes[i]);
|
||||
if (hex.length() == 1) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(hex);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static byte[] bitmap2Bytes(Bitmap bm) {
|
||||
if (bm == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public static Bitmap bytes2Bitmap(byte[] bytes) {
|
||||
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drawable → Bitmap
|
||||
*/
|
||||
public static Bitmap drawable2Bitmap(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
// 取 drawable 的长宽
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
// 取 drawable 的颜色格式
|
||||
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
|
||||
// 建立对应 bitmap
|
||||
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
|
||||
// 建立对应 bitmap 的画布
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, w, h);
|
||||
// 把 drawable 内容画到画布中
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitmap → Drawable
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Drawable bitmap2Drawable(Bitmap bm) {
|
||||
if (bm == null) {
|
||||
return null;
|
||||
}
|
||||
BitmapDrawable bd = new BitmapDrawable(bm);
|
||||
bd.setTargetDensity(bm.getDensity());
|
||||
return new BitmapDrawable(bm);
|
||||
}
|
||||
}
|
||||
@@ -479,7 +479,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
}
|
||||
return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
|
||||
}
|
||||
|
||||
public Bitmap blur(Bitmap image) {
|
||||
int width = Math.round(image.getWidth() * 0.4f);
|
||||
int height = Math.round(image.getHeight() * 0.4f);
|
||||
@@ -529,13 +528,15 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Opens the user folder described by the specified tag. The opening of the folder
|
||||
* is animated relative to the specified View. If the View is null, no animation
|
||||
* is played.
|
||||
*/
|
||||
public void animateOpen() {
|
||||
// Bitmap bm = blur(getWallpaperBg());
|
||||
Bitmap bm = blur(getWallpaperBg());
|
||||
Folder openFolder = getOpen(mLauncher);
|
||||
if (openFolder != null && openFolder != this) {
|
||||
// Close any open folder before opening a folder.
|
||||
@@ -545,7 +546,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
mIsOpen = true;
|
||||
|
||||
DragLayer dragLayer = mLauncher.getDragLayer();
|
||||
// dragLayer.setBackground(new BitmapDrawable(bm));
|
||||
dragLayer.setBackground(new BitmapDrawable(bm));
|
||||
// Just verify that the folder hasn't already been added to the DragLayer.
|
||||
// There was a one-off crash where the folder had a parent already.
|
||||
if (getParent() == null) {
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.aoleyun.os.LauncherFiles;
|
||||
import com.aoleyun.os.LauncherModel;
|
||||
import com.aoleyun.os.MainThreadExecutor;
|
||||
import com.aoleyun.os.R;
|
||||
import com.aoleyun.os.uiuiutils.BitmapUtils;
|
||||
import com.aoleyun.os.TTUtils.BitmapUtils;
|
||||
import com.aoleyun.os.WorkspaceItemInfo;
|
||||
import com.aoleyun.os.Utilities;
|
||||
import com.aoleyun.os.compat.LauncherAppsCompat;
|
||||
@@ -120,16 +120,15 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
/**
|
||||
* Fetches high-res icon for the provided ItemInfo and updates the caller when done.
|
||||
*
|
||||
* @return a request ID that can be used to cancel the request.
|
||||
*/
|
||||
public IconLoadRequest updateIconInBackground(final ItemInfoUpdateReceiver caller,
|
||||
final ItemInfoWithIcon info) {
|
||||
final ItemInfoWithIcon info) {
|
||||
Preconditions.assertUIThread();
|
||||
if (mPendingIconRequestCount <= 0) {
|
||||
LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_FOREGROUND);
|
||||
}
|
||||
mPendingIconRequestCount++;
|
||||
mPendingIconRequestCount ++;
|
||||
|
||||
IconLoadRequest request = new IconLoadRequest(mWorkerHandler, this::onIconRequestEnd) {
|
||||
@Override
|
||||
@@ -150,7 +149,7 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
|
||||
private void onIconRequestEnd() {
|
||||
mPendingIconRequestCount--;
|
||||
mPendingIconRequestCount --;
|
||||
if (mPendingIconRequestCount <= 0) {
|
||||
LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||
}
|
||||
@@ -172,7 +171,7 @@ public class IconCache extends BaseIconCache {
|
||||
* Fill in {@param info} with the icon and label for {@param activityInfo}
|
||||
*/
|
||||
public synchronized void getTitleAndIcon(ItemInfoWithIcon info,
|
||||
LauncherActivityInfo activityInfo, boolean useLowResIcon) {
|
||||
LauncherActivityInfo activityInfo, boolean useLowResIcon) {
|
||||
// If we already have activity info, no need to use package icon
|
||||
getTitleAndIcon(info, () -> activityInfo, false, useLowResIcon);
|
||||
}
|
||||
@@ -230,41 +229,37 @@ public class IconCache extends BaseIconCache {
|
||||
info.contentDescription = entry.contentDescription;
|
||||
info.applyFrom((entry.icon == null) ? getDefaultIcon(info.user) : entry);
|
||||
}
|
||||
|
||||
private List<String> appClassNameList = new ArrayList<String>() {{
|
||||
this.add("com.android.calculator2.Calculator");//计算器
|
||||
this.add("com.android.calendar.AllInOneActivity");//日历
|
||||
this.add("com.android.camera.CameraLauncher");//相机
|
||||
this.add("com.mediatek.camera.CameraLauncher");//相机
|
||||
this.add("com.android.contacts.activities.PeopleActivity");//通讯录
|
||||
this.add("com.android.deskclock.DeskClock");//时钟
|
||||
this.add("com.android.dialer.DialtactsActivity");//电话
|
||||
this.add("com.android.dialer.app.DialtactsActivity");//电话
|
||||
this.add("com.android.dialer.main.impl.MainActivity");//电话
|
||||
this.add("com.android.gallery3d.v2.app.GalleryActivity2");//图库
|
||||
this.add("com.android.gallery3d.app.GalleryActivity");//图库
|
||||
this.add("com.android.messaging.ui.conversationlist.ConversationListActivity");//信息
|
||||
this.add("com.android.mms.ui.BootActivity");//信息
|
||||
this.add("com.android.music.MusicBrowserActivity");//音乐
|
||||
this.add("com.android.providers.downloads.ui.DownloadList");//下载
|
||||
this.add("com.android.quicksearchbox.SearchActivity");//搜索
|
||||
this.add("com.android.settings.Settings");//设置
|
||||
this.add("com.sprd.soundrecorder.RecorderActivity");//录音机
|
||||
this.add("com.android.soundrecorder.SoundRecorder");//录音机
|
||||
this.add("com.android.stk.StkMain");//sim卡
|
||||
this.add("com.sprd.gallery3d.app.NewVideoActivity");//视频
|
||||
this.add("com.mediatek.filemanager.FileManagerOperationActivity");//文件管理
|
||||
this.add("com.android.documentsui.LauncherActivity");//下载
|
||||
this.add("com.mediatek.fmradio.FmRadioActivity");//收音机
|
||||
this.add("com.android.fmradio.FmMainActivity");//收音机
|
||||
this.add("com.android.email.activity.Welcome");//电子邮件
|
||||
this.add("com.android.dialer.app.calllog.CallLogActivity");//通话记录
|
||||
this.add("com.aoleyun.sn.activity.EyeProtectionActivity");//护眼模式
|
||||
this.add("com.aoleyun.sn.activity.CleanupActivity");//一键加速
|
||||
this.add("com.aoleyun.sn.activity.update.UpdateActivity");//检查更新
|
||||
|
||||
}};
|
||||
private List<String> appClassNameList = new ArrayList<String>() {
|
||||
{
|
||||
this.add("com.android.appstore");//应用市场
|
||||
this.add("com.android.browser.BrowserActivity");//浏览器
|
||||
this.add("com.android.calculator2.Calculator");//计算器
|
||||
this.add("com.android.calendar.AllInOneActivity");//日历
|
||||
this.add("com.android.camera.CameraLauncher");//相机
|
||||
this.add("com.mediatek.camera.CameraLauncher");//相机
|
||||
this.add("com.android.contacts.activities.PeopleActivity");//通讯录
|
||||
this.add("com.android.deskclock.DeskClock");//时钟
|
||||
this.add("com.android.dialer.DialtactsActivity");//电话
|
||||
this.add("com.android.dialer.main.impl.MainActivity");//电话
|
||||
this.add("com.android.gallery3d.v2.app.GalleryActivity2");//图库
|
||||
this.add("com.android.messaging.ui.conversationlist.ConversationListActivity");//信息
|
||||
this.add("com.android.music.MusicBrowserActivity");//音乐
|
||||
this.add("com.android.providers.downloads.ui.DownloadList");//下载
|
||||
this.add("com.android.quicksearchbox.SearchActivity");//搜索
|
||||
this.add("com.android.settings.Settings");//设置
|
||||
this.add("com.sprd.soundrecorder.RecorderActivity");//录音机
|
||||
this.add("com.android.stk.StkMain");//sim卡
|
||||
this.add("com.sprd.gallery3d.app.NewVideoActivity");//视频
|
||||
this.add("com.mediatek.filemanager.FileManagerOperationActivity");//文件管理
|
||||
this.add("com.android.documentsui.LauncherActivity");//下载
|
||||
this.add("com.mediatek.fmradio.FmRadioActivity");//收音机
|
||||
this.add("com.android.fmradio.FmMainActivity");//收音机
|
||||
this.add("com.android.email.activity.Welcome");//电子邮件
|
||||
}
|
||||
};
|
||||
private List<String> appIconList = new ArrayList<String>() {{
|
||||
this.add("com_android_appstore");
|
||||
this.add("com_android_browser");
|
||||
this.add("com_android_calculator2");
|
||||
this.add("com_android_calendar");
|
||||
this.add("com_android_camera");
|
||||
@@ -273,17 +268,13 @@ public class IconCache extends BaseIconCache {
|
||||
this.add("com_android_deskclock");
|
||||
this.add("com_android_dialer");
|
||||
this.add("com_android_dialer");
|
||||
this.add("com_android_dialer");
|
||||
this.add("com_android_gallery3d_app");
|
||||
this.add("com_android_gallery3d_app");
|
||||
this.add("com_android_mms_ui");
|
||||
this.add("com_android_mms_ui");
|
||||
this.add("com_android_music");
|
||||
this.add("com_android_providers_downloads_ui");
|
||||
this.add("com_android_quicksearchbox");
|
||||
this.add("com_android_settings");
|
||||
this.add("com_android_soundrecorder");
|
||||
this.add("com_android_soundrecorder");
|
||||
this.add("com_android_stk_stkmain");
|
||||
this.add("com_android_vdieo");
|
||||
this.add("com_mediatek_filemanager");
|
||||
@@ -291,10 +282,6 @@ public class IconCache extends BaseIconCache {
|
||||
this.add("com_mediatek_fmradio");
|
||||
this.add("com_mediatek_fmradio");//收音机
|
||||
this.add("com_android_email");
|
||||
this.add("com_android_calllog");
|
||||
this.add("com_system_huyan");
|
||||
this.add("com_system_clean");
|
||||
this.add("com_aoleyun_update");
|
||||
}};
|
||||
|
||||
public Drawable getFullResIcon(LauncherActivityInfo info) {
|
||||
@@ -307,24 +294,24 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
if (null != info) {
|
||||
String name = info.getComponentName().getClassName();
|
||||
Log.e("getFullResIcon", "getDeskClockIcon: " + name);
|
||||
Log.e("fht", "getDeskClockIcon:"+name);
|
||||
if (appClassNameList.indexOf(info.getComponentName().getClassName()) == -1) {
|
||||
icon = BitmapUtils.getRoundedBitmap(mIconProvider.getIcon(info, mIconDpi, flattenDrawable), mContext);
|
||||
} else {
|
||||
// if ("com.android.calendar.AllInOneActivity".equals(name)) {
|
||||
// icon = BitmapUtils.createCalendarIconBitmap(mContext.getResources().getDrawable(R.drawable.mask), mContext);
|
||||
// } else if ("com.android.deskclock.DeskClock".equals(name)) {
|
||||
// icon = BitmapUtils.getDeskClockIcon(mContext);
|
||||
// } else {
|
||||
int i = appClassNameList.indexOf(name);
|
||||
String val = appIconList.get(i);
|
||||
int resID = mContext.getResources().getIdentifier(val, "drawable", "com.aoleyun.os");
|
||||
if (resID == 0) {
|
||||
icon = mIconProvider.getIcon(info, mIconDpi, flattenDrawable);
|
||||
if (name.equals("com.android.calendar.AllInOneActivity")) {
|
||||
icon = BitmapUtils.createCalendarIconBitmap(mContext.getResources().getDrawable(R.drawable.mask), mContext);
|
||||
} else if (name.equals("com.android.deskclock.DeskClock")) {
|
||||
icon = BitmapUtils.getDeskClockIcon(mContext);
|
||||
} else {
|
||||
icon = mContext.getResources().getDrawable(resID);
|
||||
int i = appClassNameList.indexOf(name);
|
||||
String val = appIconList.get(i);
|
||||
int resID = mContext.getResources().getIdentifier(val, "drawable", "com.aoleyun.os");
|
||||
if (resID == 0) {
|
||||
icon = mIconProvider.getIcon(info, mIconDpi, flattenDrawable);
|
||||
} else {
|
||||
icon = mContext.getResources().getDrawable(resID);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
// return mIconProvider.getIcon(info, mIconDpi, flattenDrawable);
|
||||
|
||||
22
src/com/aoleyun/os/jpush/ExampleApplication.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.app.Application;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
/**
|
||||
* For developer startup JPush SDK
|
||||
*
|
||||
* 一般建议在自定义 Application 类里初始化。也可以在主 Activity 里。
|
||||
*/
|
||||
public class ExampleApplication extends Application {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Logger.d(TAG, "[ExampleApplication] onCreate");
|
||||
super.onCreate();
|
||||
|
||||
JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
|
||||
JPushInterface.init(this); // 初始化 JPush
|
||||
}
|
||||
}
|
||||
132
src/com/aoleyun/os/jpush/ExampleUtil.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class ExampleUtil {
|
||||
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
||||
public static final String PREFS_DAYS = "JPUSH_EXAMPLE_DAYS";
|
||||
public static final String PREFS_START_TIME = "PREFS_START_TIME";
|
||||
public static final String PREFS_END_TIME = "PREFS_END_TIME";
|
||||
public static final String KEY_APP_KEY = "JPUSH_APPKEY";
|
||||
|
||||
public static boolean isEmpty(String s) {
|
||||
if (null == s)
|
||||
return true;
|
||||
if (s.length() == 0)
|
||||
return true;
|
||||
if (s.trim().length() == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 只能以 “+” 或者 数字开头;后面的内容只能包含 “-” 和 数字。
|
||||
* */
|
||||
private final static String MOBILE_NUMBER_CHARS = "^[+0-9][-0-9]{1,}$";
|
||||
public static boolean isValidMobileNumber(String s) {
|
||||
if(TextUtils.isEmpty(s)) return true;
|
||||
Pattern p = Pattern.compile(MOBILE_NUMBER_CHARS);
|
||||
Matcher m = p.matcher(s);
|
||||
return m.matches();
|
||||
}
|
||||
// 校验Tag Alias 只能是数字,英文字母和中文
|
||||
public static boolean isValidTagAndAlias(String s) {
|
||||
Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
|
||||
Matcher m = p.matcher(s);
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
// 取得AppKey
|
||||
public static String getAppKey(Context context) {
|
||||
Bundle metaData = null;
|
||||
String appKey = null;
|
||||
try {
|
||||
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
|
||||
context.getPackageName(), PackageManager.GET_META_DATA);
|
||||
if (null != ai)
|
||||
metaData = ai.metaData;
|
||||
if (null != metaData) {
|
||||
appKey = metaData.getString(KEY_APP_KEY);
|
||||
if ((null == appKey) || appKey.length() != 24) {
|
||||
appKey = null;
|
||||
}
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
}
|
||||
return appKey;
|
||||
}
|
||||
|
||||
// 取得版本号
|
||||
public static String GetVersion(Context context) {
|
||||
try {
|
||||
PackageInfo manager = context.getPackageManager().getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
return manager.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static void showToast(final String toast, final Context context)
|
||||
{
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
// Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
|
||||
Looper.loop();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = conn.getActiveNetworkInfo();
|
||||
return (info != null && info.isConnected());
|
||||
}
|
||||
|
||||
public static String getImei(Context context, String imei) {
|
||||
String ret = null;
|
||||
try {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
ret = telephonyManager.getDeviceId();
|
||||
} catch (Exception e) {
|
||||
Logger.e(ExampleUtil.class.getSimpleName(), e.getMessage());
|
||||
}
|
||||
if (isReadableASCII(ret)){
|
||||
return ret;
|
||||
} else {
|
||||
return imei;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isReadableASCII(CharSequence string){
|
||||
if (TextUtils.isEmpty(string)) return false;
|
||||
try {
|
||||
Pattern p = Pattern.compile("[\\x20-\\x7E]+");
|
||||
return p.matcher(string).matches();
|
||||
} catch (Throwable e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDeviceId(Context context) {
|
||||
return JPushInterface.getUdid(context);
|
||||
}
|
||||
}
|
||||
263
src/com/aoleyun/os/jpush/LocalBroadcastManager.java
Normal file
@@ -0,0 +1,263 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by efan on 2017/4/14.
|
||||
*/
|
||||
|
||||
public final class LocalBroadcastManager {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
private static final boolean DEBUG = false;
|
||||
private final Context mAppContext;
|
||||
private final HashMap<BroadcastReceiver, ArrayList<IntentFilter>> mReceivers = new HashMap<BroadcastReceiver, ArrayList<IntentFilter>>();
|
||||
private final HashMap<String, ArrayList<ReceiverRecord>> mActions = new HashMap<String, ArrayList<ReceiverRecord>>();
|
||||
private final ArrayList<BroadcastRecord> mPendingBroadcasts = new ArrayList<BroadcastRecord>();
|
||||
static final int MSG_EXEC_PENDING_BROADCASTS = 1;
|
||||
private final Handler mHandler;
|
||||
private static final Object mLock = new Object();
|
||||
private static LocalBroadcastManager mInstance;
|
||||
|
||||
public static LocalBroadcastManager getInstance(Context context) {
|
||||
Object var1 = mLock;
|
||||
synchronized (mLock) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new LocalBroadcastManager(context.getApplicationContext());
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private LocalBroadcastManager(Context context) {
|
||||
this.mAppContext = context;
|
||||
this.mHandler = new Handler(context.getMainLooper()) {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
LocalBroadcastManager.this.executePendingBroadcasts();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||
HashMap var3 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
ReceiverRecord entry = new ReceiverRecord(filter, receiver);
|
||||
ArrayList filters = (ArrayList) this.mReceivers.get(receiver);
|
||||
if (filters == null) {
|
||||
filters = new ArrayList(1);
|
||||
this.mReceivers.put(receiver, filters);
|
||||
}
|
||||
|
||||
filters.add(filter);
|
||||
|
||||
for (int i = 0; i < filter.countActions(); ++i) {
|
||||
String action = filter.getAction(i);
|
||||
ArrayList entries = (ArrayList) this.mActions.get(action);
|
||||
if (entries == null) {
|
||||
entries = new ArrayList(1);
|
||||
this.mActions.put(action, entries);
|
||||
}
|
||||
|
||||
entries.add(entry);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterReceiver(BroadcastReceiver receiver) {
|
||||
HashMap var2 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
ArrayList filters = (ArrayList) this.mReceivers.remove(receiver);
|
||||
if (filters != null) {
|
||||
for (int i = 0; i < filters.size(); ++i) {
|
||||
IntentFilter filter = (IntentFilter) filters.get(i);
|
||||
|
||||
for (int j = 0; j < filter.countActions(); ++j) {
|
||||
String action = filter.getAction(j);
|
||||
ArrayList receivers = (ArrayList) this.mActions.get(action);
|
||||
if (receivers != null) {
|
||||
for (int k = 0; k < receivers.size(); ++k) {
|
||||
if (((ReceiverRecord) receivers.get(k)).receiver == receiver) {
|
||||
receivers.remove(k);
|
||||
--k;
|
||||
}
|
||||
}
|
||||
|
||||
if (receivers.size() <= 0) {
|
||||
this.mActions.remove(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendBroadcast(Intent intent) {
|
||||
HashMap var2 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
String action = intent.getAction();
|
||||
String type = intent.resolveTypeIfNeeded(this.mAppContext.getContentResolver());
|
||||
Uri data = intent.getData();
|
||||
String scheme = intent.getScheme();
|
||||
Set categories = intent.getCategories();
|
||||
boolean debug = (intent.getFlags() & 8) != 0;
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Resolving type " + type + " scheme " + scheme + " of intent " + intent);
|
||||
}
|
||||
|
||||
ArrayList entries = (ArrayList) this.mActions.get(intent.getAction());
|
||||
if (entries != null) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Action list: " + entries);
|
||||
}
|
||||
|
||||
ArrayList receivers = null;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < entries.size(); ++i) {
|
||||
ReceiverRecord receiver = (ReceiverRecord) entries.get(i);
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Matching against filter " + receiver.filter);
|
||||
}
|
||||
|
||||
if (receiver.broadcasting) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", " Filter\'s target already added");
|
||||
}
|
||||
} else {
|
||||
int match = receiver.filter.match(action, type, scheme, data, categories, "LocalBroadcastManager");
|
||||
if (match >= 0) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", " Filter matched! match=0x" + Integer.toHexString(match));
|
||||
}
|
||||
|
||||
if (receivers == null) {
|
||||
receivers = new ArrayList();
|
||||
}
|
||||
|
||||
receivers.add(receiver);
|
||||
receiver.broadcasting = true;
|
||||
} else if (debug) {
|
||||
String reason;
|
||||
switch (match) {
|
||||
case -4:
|
||||
reason = "category";
|
||||
break;
|
||||
case -3:
|
||||
reason = "action";
|
||||
break;
|
||||
case -2:
|
||||
reason = "data";
|
||||
break;
|
||||
case -1:
|
||||
reason = "type";
|
||||
break;
|
||||
default:
|
||||
reason = "unknown reason";
|
||||
}
|
||||
|
||||
Logger.v("LocalBroadcastManager", " Filter did not match: " + reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (receivers != null) {
|
||||
for (i = 0; i < receivers.size(); ++i) {
|
||||
((ReceiverRecord) receivers.get(i)).broadcasting = false;
|
||||
}
|
||||
|
||||
this.mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
|
||||
if (!this.mHandler.hasMessages(1)) {
|
||||
this.mHandler.sendEmptyMessage(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendBroadcastSync(Intent intent) {
|
||||
if (this.sendBroadcast(intent)) {
|
||||
this.executePendingBroadcasts();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executePendingBroadcasts() {
|
||||
while (true) {
|
||||
BroadcastRecord[] brs = null;
|
||||
HashMap i = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
int br = this.mPendingBroadcasts.size();
|
||||
if (br <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
brs = new BroadcastRecord[br];
|
||||
this.mPendingBroadcasts.toArray(brs);
|
||||
this.mPendingBroadcasts.clear();
|
||||
}
|
||||
|
||||
for (int var6 = 0; var6 < brs.length; ++var6) {
|
||||
BroadcastRecord var7 = brs[var6];
|
||||
|
||||
for (int j = 0; j < var7.receivers.size(); ++j) {
|
||||
((ReceiverRecord) var7.receivers.get(j)).receiver.onReceive(this.mAppContext, var7.intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class BroadcastRecord {
|
||||
final Intent intent;
|
||||
final ArrayList<ReceiverRecord> receivers;
|
||||
|
||||
BroadcastRecord(Intent _intent, ArrayList<ReceiverRecord> _receivers) {
|
||||
this.intent = _intent;
|
||||
this.receivers = _receivers;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReceiverRecord {
|
||||
final IntentFilter filter;
|
||||
final BroadcastReceiver receiver;
|
||||
boolean broadcasting;
|
||||
|
||||
ReceiverRecord(IntentFilter _filter, BroadcastReceiver _receiver) {
|
||||
this.filter = _filter;
|
||||
this.receiver = _receiver;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(128);
|
||||
builder.append("Receiver{");
|
||||
builder.append(this.receiver);
|
||||
builder.append(" filter=");
|
||||
builder.append(this.filter);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/com/aoleyun/os/jpush/Logger.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by efan on 2017/4/13.
|
||||
*/
|
||||
|
||||
public class Logger {
|
||||
|
||||
//设为false关闭日志
|
||||
private static final boolean LOG_ENABLE = true;
|
||||
|
||||
public static void i(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.i(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void v(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.v(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void d(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.d(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void w(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.w(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void e(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.e(tag, msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
src/com/aoleyun/os/jpush/MyJPushMessageReceiver.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.aoleyun.os.base.MyApplication;
|
||||
|
||||
import cn.jpush.android.api.CustomMessage;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
import cn.jpush.android.service.JPushMessageReceiver;
|
||||
|
||||
/**
|
||||
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
|
||||
* */
|
||||
public class MyJPushMessageReceiver extends JPushMessageReceiver {
|
||||
|
||||
@Override
|
||||
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
|
||||
super.onTagOperatorResult(context, jPushMessage);
|
||||
MyApplication.getInstance().onTagOperatorResult(jPushMessage);
|
||||
}
|
||||
@Override
|
||||
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||
TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
|
||||
super.onCheckTagOperatorResult(context, jPushMessage);
|
||||
}
|
||||
@Override
|
||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
|
||||
super.onAliasOperatorResult(context, jPushMessage);
|
||||
MyApplication.getInstance().onAliasOperatorResult(jPushMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
|
||||
super.onMobileNumberOperatorResult(context, jPushMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Context context, CustomMessage customMessage) {
|
||||
super.onMessage(context, customMessage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
193
src/com/aoleyun/os/jpush/MyReceiver.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.base.MyApplication;
|
||||
import com.aoleyun.os.TTUtils.APKUtils;
|
||||
import com.aoleyun.os.network.AppPasswdBean;
|
||||
import com.aoleyun.os.network.BaseResponse;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.network.NetWorkManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 自定义接收器
|
||||
* <p>
|
||||
* 如果不定义这个 Receiver,则:
|
||||
* 1) 默认用户会打开主界面
|
||||
* 2) 接收不到自定义消息
|
||||
*/
|
||||
public class MyReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
Bundle bundle = intent.getExtras();
|
||||
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
||||
|
||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
||||
//send the Registration Id to your server...
|
||||
|
||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
||||
processCustomMessage(context, bundle);
|
||||
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
||||
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
||||
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
||||
|
||||
//打开自定义的Activity
|
||||
Intent i = new Intent(context, TestActivity.class);
|
||||
i.putExtras(bundle);
|
||||
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(i);
|
||||
|
||||
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
||||
Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
||||
} else {
|
||||
Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 打印所有的 intent extra 数据
|
||||
private static String printBundle(Bundle bundle) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key : bundle.keySet()) {
|
||||
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
||||
sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
|
||||
} else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
|
||||
sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
|
||||
} else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
|
||||
if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
|
||||
Logger.i(TAG, "This message has no Extra data");
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||
Iterator<String> it = json.keys();
|
||||
|
||||
while (it.hasNext()) {
|
||||
String myKey = it.next();
|
||||
sb.append("\nkey:" + key + ", value: [" +
|
||||
myKey + " - " + json.optString(myKey) + "]");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Logger.e(TAG, "Get message extra JSON error!");
|
||||
}
|
||||
|
||||
} else {
|
||||
sb.append("\nkey:" + key + ", value:" + bundle.get(key));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static final String SEND_RUNNING_APP = "2";
|
||||
//应用锁
|
||||
private static final String UPDATE_APP_LOCK = "39";
|
||||
|
||||
|
||||
//send msg to MainActivity
|
||||
private void processCustomMessage(Context context, Bundle bundle) {
|
||||
// if (Launcher.isForeground) {
|
||||
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
// Intent msgIntent = new Intent(Launcher.MESSAGE_RECEIVED_ACTION);
|
||||
// msgIntent.putExtra(Launcher.KEY_MESSAGE, message);
|
||||
// if (!ExampleUtil.isEmpty(extras)) {
|
||||
// try {
|
||||
// JSONObject extraJson = new JSONObject(extras);
|
||||
// if (extraJson.length() > 0) {
|
||||
// msgIntent.putExtra(Launcher.KEY_EXTRAS, extras);
|
||||
// }
|
||||
// } catch (JSONException e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
|
||||
// }
|
||||
|
||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||
|
||||
switch (message) {
|
||||
case SEND_RUNNING_APP:
|
||||
sendRunningApp(context);
|
||||
break;
|
||||
case UPDATE_APP_LOCK:
|
||||
HTTPInterface.getAppPasswd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void sendRunningApp(Context context) {
|
||||
String packageName = MyApplication.getInstance().getAppPackageName();
|
||||
long time = MyApplication.getInstance().getOnClickTime();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", packageName);
|
||||
jsonObject.addProperty("version_name", APKUtils.getAPPVersionName(context, packageName));
|
||||
jsonObject.addProperty("start_time", time / 1000);
|
||||
String jsonString = jsonObject.toString();
|
||||
NetWorkManager.getInstance().getRunningAppObservable(jsonString)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e(TAG, "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e(TAG, "onSubscribe: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG, "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
7
src/com/aoleyun/os/jpush/PushService.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import cn.jpush.android.service.JCommonService;
|
||||
|
||||
public class PushService extends JCommonService {
|
||||
|
||||
}
|
||||
345
src/com/aoleyun/os/jpush/TagAliasOperatorHelper.java
Normal file
@@ -0,0 +1,345 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.aoleyun.os.TTUtils.ToastUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
|
||||
/**
|
||||
* 处理tagalias相关的逻辑
|
||||
* */
|
||||
public class TagAliasOperatorHelper {
|
||||
private static final String TAG = "JIGUANG-TagAliasHelper";
|
||||
public static int sequence = 1;
|
||||
/**增加*/
|
||||
public static final int ACTION_ADD = 1;
|
||||
/**覆盖*/
|
||||
public static final int ACTION_SET = 2;
|
||||
/**删除部分*/
|
||||
public static final int ACTION_DELETE = 3;
|
||||
/**删除所有*/
|
||||
public static final int ACTION_CLEAN = 4;
|
||||
/**查询*/
|
||||
public static final int ACTION_GET = 5;
|
||||
|
||||
public static final int ACTION_CHECK = 6;
|
||||
|
||||
public static final int DELAY_SEND_ACTION = 1;
|
||||
|
||||
public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
|
||||
|
||||
private Context context;
|
||||
|
||||
private static TagAliasOperatorHelper mInstance;
|
||||
private TagAliasOperatorHelper(){
|
||||
}
|
||||
public static TagAliasOperatorHelper getInstance(){
|
||||
if(mInstance == null){
|
||||
synchronized (TagAliasOperatorHelper.class){
|
||||
if(mInstance == null){
|
||||
mInstance = new TagAliasOperatorHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
public void init(Context context){
|
||||
if(context != null) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
}
|
||||
private SparseArray<Object> setActionCache = new SparseArray<Object>();
|
||||
|
||||
public Object get(int sequence){
|
||||
return setActionCache.get(sequence);
|
||||
}
|
||||
public Object remove(int sequence){
|
||||
return setActionCache.get(sequence);
|
||||
}
|
||||
public void put(int sequence, Object tagAliasBean){
|
||||
setActionCache.put(sequence,tagAliasBean);
|
||||
}
|
||||
private Handler delaySendHandler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what){
|
||||
case DELAY_SEND_ACTION:
|
||||
if(msg.obj !=null && msg.obj instanceof TagAliasBean){
|
||||
Logger.i(TAG,"on delay time");
|
||||
sequence++;
|
||||
TagAliasBean tagAliasBean = (TagAliasBean) msg.obj;
|
||||
setActionCache.put(sequence, tagAliasBean);
|
||||
if(context!=null) {
|
||||
handleAction(context, sequence, tagAliasBean);
|
||||
}else{
|
||||
Logger.e(TAG,"#unexcepted - context was null");
|
||||
}
|
||||
}else{
|
||||
Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||
}
|
||||
break;
|
||||
case DELAY_SET_MOBILE_NUMBER_ACTION:
|
||||
if(msg.obj !=null && msg.obj instanceof String) {
|
||||
Logger.i(TAG, "retry set mobile number");
|
||||
sequence++;
|
||||
String mobileNumber = (String) msg.obj;
|
||||
setActionCache.put(sequence, mobileNumber);
|
||||
if(context !=null) {
|
||||
handleAction(context, sequence, mobileNumber);
|
||||
}else {
|
||||
Logger.e(TAG, "#unexcepted - context was null");
|
||||
}
|
||||
}else{
|
||||
Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
public void handleAction(Context context, int sequence, String mobileNumber){
|
||||
put(sequence,mobileNumber);
|
||||
Logger.d(TAG,"sequence:"+sequence+",mobileNumber:"+mobileNumber);
|
||||
JPushInterface.setMobileNumber(context,sequence,mobileNumber);
|
||||
}
|
||||
/**
|
||||
* 处理设置tag
|
||||
* */
|
||||
public void handleAction(Context context, int sequence, TagAliasBean tagAliasBean){
|
||||
init(context);
|
||||
if(tagAliasBean == null){
|
||||
Logger.w(TAG,"tagAliasBean was null");
|
||||
return;
|
||||
}
|
||||
put(sequence,tagAliasBean);
|
||||
if(tagAliasBean.isAliasAction){
|
||||
switch (tagAliasBean.action){
|
||||
case ACTION_GET:
|
||||
JPushInterface.getAlias(context,sequence);
|
||||
break;
|
||||
case ACTION_DELETE:
|
||||
JPushInterface.deleteAlias(context,sequence);
|
||||
break;
|
||||
case ACTION_SET:
|
||||
JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
|
||||
break;
|
||||
default:
|
||||
Logger.w(TAG,"unsupport alias action type");
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
switch (tagAliasBean.action) {
|
||||
case ACTION_ADD:
|
||||
JPushInterface.addTags(context, sequence, tagAliasBean.tags);
|
||||
break;
|
||||
case ACTION_SET:
|
||||
JPushInterface.setTags(context, sequence, tagAliasBean.tags);
|
||||
break;
|
||||
case ACTION_DELETE:
|
||||
JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
|
||||
break;
|
||||
case ACTION_CHECK:
|
||||
//一次只能check一个tag
|
||||
String tag = (String)tagAliasBean.tags.toArray()[0];
|
||||
JPushInterface.checkTagBindState(context,sequence,tag);
|
||||
break;
|
||||
case ACTION_GET:
|
||||
JPushInterface.getAllTags(context, sequence);
|
||||
break;
|
||||
case ACTION_CLEAN:
|
||||
JPushInterface.cleanTags(context, sequence);
|
||||
break;
|
||||
default:
|
||||
Logger.w(TAG,"unsupport tag action type");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private boolean RetryActionIfNeeded(int errorCode,TagAliasBean tagAliasBean){
|
||||
if(!ExampleUtil.isConnected(context)){
|
||||
Logger.w(TAG,"no network");
|
||||
return false;
|
||||
}
|
||||
//返回的错误码为6002 超时,6014 服务器繁忙,都建议延迟重试
|
||||
if(errorCode == 6002 || errorCode == 6014){
|
||||
Logger.d(TAG,"need retry");
|
||||
if(tagAliasBean!=null){
|
||||
Message message = new Message();
|
||||
message.what = DELAY_SEND_ACTION;
|
||||
message.obj = tagAliasBean;
|
||||
delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||
String logs =getRetryStr(tagAliasBean.isAliasAction, tagAliasBean.action,errorCode);
|
||||
ExampleUtil.showToast(logs, context);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean RetrySetMObileNumberActionIfNeeded(int errorCode, String mobileNumber){
|
||||
if(!ExampleUtil.isConnected(context)){
|
||||
Logger.w(TAG,"no network");
|
||||
return false;
|
||||
}
|
||||
//返回的错误码为6002 超时,6024 服务器内部错误,建议稍后重试
|
||||
if(errorCode == 6002 || errorCode == 6024){
|
||||
Logger.d(TAG,"need retry");
|
||||
Message message = new Message();
|
||||
message.what = DELAY_SET_MOBILE_NUMBER_ACTION;
|
||||
message.obj = mobileNumber;
|
||||
delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||
String str = "Failed to set mobile number due to %s. Try again after 60s.";
|
||||
str = String.format(Locale.ENGLISH,str,(errorCode == 6002 ? "timeout" : "server internal error”"));
|
||||
ExampleUtil.showToast(str, context);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
private String getRetryStr(boolean isAliasAction, int actionType, int errorCode){
|
||||
String str = "Failed to %s %s due to %s. Try again after 60s.";
|
||||
str = String.format(Locale.ENGLISH,str,getActionStr(actionType),(isAliasAction? "alias" : " tags") ,(errorCode == 6002 ? "timeout" : "server too busy"));
|
||||
return str;
|
||||
}
|
||||
|
||||
private String getActionStr(int actionType){
|
||||
switch (actionType){
|
||||
case ACTION_ADD:
|
||||
return "add";
|
||||
case ACTION_SET:
|
||||
return "set";
|
||||
case ACTION_DELETE:
|
||||
return "delete";
|
||||
case ACTION_GET:
|
||||
return "get";
|
||||
case ACTION_CLEAN:
|
||||
return "clean";
|
||||
case ACTION_CHECK:
|
||||
return "check";
|
||||
}
|
||||
return "unkonw operation";
|
||||
}
|
||||
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
int sequence = jPushMessage.getSequence();
|
||||
Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
||||
Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
||||
init(context);
|
||||
//根据sequence从之前操作缓存中获取缓存记录
|
||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
if(tagAliasBean == null){
|
||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
return;
|
||||
}
|
||||
if(jPushMessage.getErrorCode() == 0){
|
||||
Logger.i(TAG,"action - modify tag Success,sequence:"+sequence);
|
||||
setActionCache.remove(sequence);
|
||||
String logs = getActionStr(tagAliasBean.action)+" tags success";
|
||||
Logger.i(TAG,logs);
|
||||
Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
||||
ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}else{
|
||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
||||
if(jPushMessage.getErrorCode() == 6018){
|
||||
//tag数量超过限制,需要先清除一部分再add
|
||||
logs += ", tags is exceed limit need to clean";
|
||||
}
|
||||
logs += ", errorCode:" + jPushMessage.getErrorCode();
|
||||
Logger.e(TAG, logs);
|
||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||
int sequence = jPushMessage.getSequence();
|
||||
Logger.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
|
||||
init(context);
|
||||
//根据sequence从之前操作缓存中获取缓存记录
|
||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
if(tagAliasBean == null){
|
||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
return;
|
||||
}
|
||||
if(jPushMessage.getErrorCode() == 0){
|
||||
Logger.i(TAG,"tagBean:"+tagAliasBean);
|
||||
setActionCache.remove(sequence);
|
||||
String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
||||
Logger.i(TAG,logs);
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}else{
|
||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
||||
Logger.e(TAG, logs);
|
||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
int sequence = jPushMessage.getSequence();
|
||||
Logger.i(TAG,"action - onAliasOperatorResult, sequence:"+sequence+",alias:"+jPushMessage.getAlias());
|
||||
init(context);
|
||||
//根据sequence从之前操作缓存中获取缓存记录
|
||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
if(tagAliasBean == null){
|
||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
return;
|
||||
}
|
||||
if(jPushMessage.getErrorCode() == 0){
|
||||
Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
||||
setActionCache.remove(sequence);
|
||||
String logs = getActionStr(tagAliasBean.action)+" alias success";
|
||||
Logger.i(TAG,logs);
|
||||
Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
||||
ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}else{
|
||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
|
||||
Logger.e(TAG, logs);
|
||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
//设置手机号码回调
|
||||
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
int sequence = jPushMessage.getSequence();
|
||||
Logger.i(TAG,"action - onMobileNumberOperatorResult, sequence:"+sequence+",mobileNumber:"+jPushMessage.getMobileNumber());
|
||||
init(context);
|
||||
if(jPushMessage.getErrorCode() == 0){
|
||||
Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
||||
setActionCache.remove(sequence);
|
||||
}else{
|
||||
String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
|
||||
Logger.e(TAG, logs);
|
||||
if(!RetrySetMObileNumberActionIfNeeded(jPushMessage.getErrorCode(),jPushMessage.getMobileNumber())){
|
||||
ExampleUtil.showToast(logs, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class TagAliasBean{
|
||||
public int action;
|
||||
public Set<String> tags;
|
||||
public String alias;
|
||||
public boolean isAliasAction;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TagAliasBean{" +
|
||||
"action=" + action +
|
||||
", tags=" + tags +
|
||||
", alias='" + alias + '\'' +
|
||||
", isAliasAction=" + isAliasAction +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
src/com/aoleyun/os/jpush/TestActivity.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class TestActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
TextView tv = new TextView(this);
|
||||
tv.setText("用户自定义打开的Activity");
|
||||
Intent intent = getIntent();
|
||||
if (null != intent) {
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
String title = null;
|
||||
String content = null;
|
||||
if(bundle!=null){
|
||||
title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||
content = bundle.getString(JPushInterface.EXTRA_ALERT);
|
||||
}
|
||||
tv.setText("Title : " + title + " " + "Content : " + content);
|
||||
}
|
||||
addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.aoleyun.os.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
public class ConnectManager {
|
||||
private static final String TAG = ConnectManager.class.getSimpleName();
|
||||
|
||||
|
||||
public static final long ONE_MINUTES_TIME = 60 * 1000;
|
||||
public static final long FIFTEEN_MINUTES_TIME = ONE_MINUTES_TIME * 15;
|
||||
public static final long HALF_HOUR_TIME = FIFTEEN_MINUTES_TIME * 2;
|
||||
public static final long ONE_HOUR_TIME = HALF_HOUR_TIME * 2;
|
||||
public static final long SIX_HOUR_TIME = ONE_HOUR_TIME * 6;
|
||||
public static final long HALF_DAY_TIME = SIX_HOUR_TIME * 2;
|
||||
public static final long ONE_DAY_TIME = HALF_DAY_TIME * 2;
|
||||
public static final long TWO_DAY_TIME = ONE_DAY_TIME * 2;
|
||||
public static final long FOUR_DAY_TIME = TWO_DAY_TIME * 2;
|
||||
public static final long A_WEEK_TIME = ONE_DAY_TIME * 7;
|
||||
|
||||
/*重启后连接成功的时间*/
|
||||
public static final String REBOOT_LAST_ONNECT_TIME = "reboot_last_connect_time";
|
||||
/*WiFi连接后连接成功的时间*/
|
||||
public static final String WIFI_LAST_CONNECT_TIME = "WiFi_last_connect_time";
|
||||
/*打开设备信息连接成功的时间*/
|
||||
public static final String OPENINFO_LAST_ONNECT_TIME = "opneinfo_last_connect_time";
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static ConnectManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private ConnectManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
Log.e(TAG, "init: ");
|
||||
sInstance = new ConnectManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static ConnectManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init ConnectManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public long getConnectModeTime(ConnectMode connectMode) {
|
||||
long time = 0;
|
||||
switch (connectMode) {
|
||||
case DEFAULT:
|
||||
time = 0;
|
||||
break;
|
||||
case ONE_MINUTE:
|
||||
time = ONE_MINUTES_TIME;
|
||||
break;
|
||||
case FIFTEEN_MINUTES:
|
||||
time = FIFTEEN_MINUTES_TIME;
|
||||
break;
|
||||
case HALF_HOUR:
|
||||
time = HALF_HOUR_TIME;
|
||||
break;
|
||||
case ONE_HOUR:
|
||||
time = ONE_HOUR_TIME;
|
||||
break;
|
||||
case SIX_HOUR:
|
||||
time = SIX_HOUR_TIME;
|
||||
break;
|
||||
case HALF_DAY:
|
||||
time = HALF_DAY_TIME;
|
||||
break;
|
||||
case ONE_DAY:
|
||||
time = ONE_DAY_TIME;
|
||||
break;
|
||||
case TWO_DAY:
|
||||
time = TWO_DAY_TIME;
|
||||
break;
|
||||
case FOUR_DAY:
|
||||
time = FOUR_DAY_TIME;
|
||||
break;
|
||||
case A_WEEK:
|
||||
time = A_WEEK_TIME;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean isNeedConnect(String key, ConnectMode connectMode) {
|
||||
if (connectMode == ConnectMode.ONCE) {
|
||||
return false;
|
||||
}
|
||||
long nowTime = System.currentTimeMillis();
|
||||
long lastTime = mMMKV.decodeLong(key, 0);
|
||||
long intervalTime = getConnectModeTime(connectMode);
|
||||
//防止一分钟内重复请求
|
||||
return nowTime - lastTime > intervalTime && nowTime - lastTime > ONE_MINUTES_TIME;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 重启后是否连接
|
||||
*/
|
||||
public boolean isRebootFistConnect() {
|
||||
long rebootTime = mMMKV.decodeLong(REBOOT_LAST_ONNECT_TIME, 0);
|
||||
//只在开机后15内连接,其他情况为service重启
|
||||
long time = System.currentTimeMillis() - rebootTime;
|
||||
return time < 15 * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 今天WiFi连接是否有连接
|
||||
*/
|
||||
public boolean isWiFiFistConnect() {
|
||||
long time = mMMKV.decodeLong(WIFI_LAST_CONNECT_TIME, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 今天打开设备信息后是否连接
|
||||
*/
|
||||
public boolean isOpenInfoFistConnect() {
|
||||
long time = mMMKV.decodeLong(OPENINFO_LAST_ONNECT_TIME, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WiFiAlias
|
||||
* @return 今天切换WiFi后是否连接
|
||||
*/
|
||||
public boolean isWiFiCutoverFistConnect(String WiFiAlias) {
|
||||
long time = mMMKV.decodeLong(WiFiAlias, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||