Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -21,7 +21,6 @@
|
||||
<option value="$PROJECT_DIR$/libraries/map-autonavi" />
|
||||
<option value="$PROJECT_DIR$/libraries/mogo-map" />
|
||||
<option value="$PROJECT_DIR$/libraries/mogo-map-api" />
|
||||
<option value="$PROJECT_DIR$/libraries/mogo-tanlu-api" />
|
||||
<option value="$PROJECT_DIR$/libraries/tanlulib" />
|
||||
<option value="$PROJECT_DIR$/main-extensions" />
|
||||
<option value="$PROJECT_DIR$/main-extensions/mogo-module-main-independent" />
|
||||
|
||||
@@ -343,7 +343,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.moduletanlu, {
|
||||
exclude group: 'com.mogo.module', module: 'module-share'
|
||||
}
|
||||
implementation rootProject.ext.dependencies.moduletanluapi
|
||||
implementation rootProject.ext.dependencies.tanluupload
|
||||
implementation rootProject.ext.dependencies.mogomonitor
|
||||
implementation rootProject.ext.dependencies.mogomoduleback
|
||||
implementation rootProject.ext.dependencies.guideshow
|
||||
@@ -359,7 +359,7 @@ dependencies {
|
||||
implementation project(':modules:mogo-module-tanlu'), {
|
||||
exclude group: 'com.mogo.module', module: 'module-share'
|
||||
}
|
||||
implementation project(':libraries:mogo-tanlu-api')
|
||||
implementation project(':libraries:tanlulib')
|
||||
implementation project(':modules:mogo-module-monitor')
|
||||
implementation project(':modules:mogo-module-back')
|
||||
implementation project(':modules:mogo-module-guide')
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.mogo.utils.logger.Logger;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.zhidao.boot.persistent.lib.PersistentManager;
|
||||
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
|
||||
import com.zhidao.mogo.tanlu.api.TanluApiConst;
|
||||
|
||||
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_FRAGMENT;
|
||||
import static com.mogo.module.guide.GuideConstant.PATH_GUIDE_MODULE_NAME;
|
||||
@@ -76,7 +75,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
|
||||
}
|
||||
|
||||
MogoModulePaths.addModule( new MogoModule( TanluApiConst.MODULE_PATH, TanluApiConst.MODULE_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_TANLU_API, "TanluApi" ) );
|
||||
MogoModulePaths.addBaseModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
|
||||
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );
|
||||
|
||||
|
||||
@@ -88,7 +88,6 @@ targetSdkVersion : 22,
|
||||
|
||||
// modules
|
||||
moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}",
|
||||
moduletanluapi : "com.mogo.module:module-tanlu-api:${MOGO_TANLU_API_VERSION}",
|
||||
moduleshare : "com.mogo.module:module-share:${MOGO_MODULE_SHARE_VERSION}",
|
||||
mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}",
|
||||
mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}",
|
||||
|
||||
1
libraries/mogo-tanlu-api/.gitignore
vendored
1
libraries/mogo-tanlu-api/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,52 +0,0 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
compileOnly rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.tanluupload
|
||||
} else {
|
||||
compileOnly project(':modules:mogo-module-common')
|
||||
implementation project(':libraries:tanlulib')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-tanlu-api
|
||||
VERSION_CODE=1
|
||||
21
libraries/mogo-tanlu-api/proguard-rules.pro
vendored
21
libraries/mogo-tanlu-api/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.zhidao.mogo.tanlu.api;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.zhidao.mogo.tanlu.api.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.zhidao.mogo.tanlu.api">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.zhidao.mogo.tanlu.api;
|
||||
|
||||
/**
|
||||
* 探路api相关常量
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class TanluApiConst {
|
||||
public static final String MODULE_NAME = "MogoTanluApi";
|
||||
public static final String MODULE_PATH = "/tanlulib/api";
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.zhidao.mogo.tanlu.api;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,19 @@ apply plugin: 'android-aspectjx'
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
@@ -62,6 +67,9 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.aspectj
|
||||
implementation rootProject.ext.dependencies.analytics
|
||||
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
compileOnly rootProject.ext.dependencies.mogocommons
|
||||
compileOnly rootProject.ext.dependencies.mogomap
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.zhidao.mogo.tanlu.api;
|
||||
package com.zhidao.roadcondition;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.ArrayMap;
|
||||
@@ -13,15 +13,15 @@ import com.zhidao.roadcondition.service.UploadParams;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zhidao.mogo.tanlu.api.TanluApiConst.MODULE_NAME;
|
||||
import static com.zhidao.mogo.tanlu.api.TanluApiConst.MODULE_PATH;
|
||||
import static com.zhidao.roadcondition.constant.ConstKt.API_MODULE_NAME;
|
||||
import static com.zhidao.roadcondition.constant.ConstKt.API_MODULE_PATH;
|
||||
|
||||
/**
|
||||
* 探路api
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = MODULE_PATH)
|
||||
@Route(path = API_MODULE_PATH)
|
||||
public class MogoTanluApiProvider implements IMogoTanluProvider {
|
||||
private Context context;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MogoTanluApiProvider implements IMogoTanluProvider {
|
||||
@Override
|
||||
public void uploadRoadCondition(TanluUploadParams params) {
|
||||
if(params!=null) {
|
||||
Logger.d(MODULE_NAME, "uploadRoadCondition: " + params);
|
||||
Logger.d(API_MODULE_NAME, "uploadRoadCondition: " + params);
|
||||
Map<String, Object> properties = new ArrayMap<>();
|
||||
properties.put("type", params.getEventType());
|
||||
properties.put("from", params.getFromType());
|
||||
@@ -42,7 +42,7 @@ public class MogoTanluApiProvider implements IMogoTanluProvider {
|
||||
params.getFromType(), params.getDuration(), params.getParentId(),
|
||||
params.getLocation().lat, params.getLocation().lon));
|
||||
}else{
|
||||
Logger.e(MODULE_NAME,"params为空,无法上报情报");
|
||||
Logger.e(API_MODULE_NAME,"params为空,无法上报情报");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,13 @@ public class MogoTanluApiProvider implements IMogoTanluProvider {
|
||||
*/
|
||||
@Override
|
||||
public void startTanluService() {
|
||||
Logger.d(MODULE_NAME, "startTanluService");
|
||||
Logger.d(API_MODULE_NAME, "startTanluService");
|
||||
MainService.Companion.launchService(context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
this.context = context;
|
||||
Logger.d(API_MODULE_NAME,"新TanluApi模块 init====");
|
||||
}
|
||||
}
|
||||
@@ -82,3 +82,6 @@ const val DEF_NEWS_LABEL = "拥堵"
|
||||
const val DEF_NEWS_VALUE = "traffic_jam"
|
||||
const val DEF_NEWS_TYPE = "0"
|
||||
|
||||
const val API_MODULE_NAME = "MogoTanluApi"
|
||||
const val API_MODULE_PATH = "/tanlulib/api"
|
||||
|
||||
|
||||
@@ -42,6 +42,17 @@ public class AppFilterImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSelfApp( PackageInfo packageInfo ) {
|
||||
try {
|
||||
if ( packageInfo.packageName.startsWith( "com.mogo.launcher" ) ) {
|
||||
return true;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean sFilter( PackageInfo packageInfo ) {
|
||||
if ( isInExternalFilter( packageInfo ) ) {
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.mogo.module.apps.applaunch;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.apps.AppServiceHandler;
|
||||
import com.mogo.module.apps.R;
|
||||
@@ -21,7 +24,18 @@ public class AppLauncher extends BaseAppLauncher {
|
||||
|
||||
@Override
|
||||
public void launch( Context context, AppInfo appInfo ) {
|
||||
launch( context, appInfo.getPackageName() );
|
||||
if ( !TextUtils.isEmpty( appInfo.getActivityClsName() ) ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent( new ComponentName( appInfo.getPackageName(), appInfo.getActivityClsName() ) );
|
||||
try {
|
||||
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
context.startActivity( intent );
|
||||
} catch ( Exception e ) {
|
||||
launch( context, appInfo.getPackageName() );
|
||||
}
|
||||
} else {
|
||||
launch( context, appInfo.getPackageName() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,15 +15,17 @@ public class AppInfo {
|
||||
|
||||
private final String mName;
|
||||
private final String mPackageName;
|
||||
private final String mActivityClsName;
|
||||
private final String mVersionName;
|
||||
private final int mVersionCode;
|
||||
private final Drawable mIcon;
|
||||
private final int mIconResId;
|
||||
private final int mTrackType; // 埋点类型
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId, int mTrackType ) {
|
||||
public AppInfo( String mName, String mPackageName, String mActivityClsName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId, int mTrackType ) {
|
||||
this.mName = mName;
|
||||
this.mPackageName = mPackageName;
|
||||
this.mActivityClsName = mActivityClsName;
|
||||
this.mVersionName = mVersionName;
|
||||
this.mVersionCode = mVersionCode;
|
||||
this.mIcon = mIcon;
|
||||
@@ -31,8 +33,12 @@ public class AppInfo {
|
||||
this.mTrackType = mTrackType;
|
||||
}
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId, int mTrackType ) {
|
||||
this( mName, mPackageName,"", mVersionName, mVersionCode, mIcon, mIconResId, mTrackType );
|
||||
}
|
||||
|
||||
public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId ) {
|
||||
this( mName, mPackageName, mVersionName, mVersionCode, mIcon, mIconResId, 0 );
|
||||
this( mName, mPackageName,"", mVersionName, mVersionCode, mIcon, mIconResId, 0 );
|
||||
}
|
||||
|
||||
public int getIconResId() {
|
||||
@@ -43,6 +49,10 @@ public class AppInfo {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public String getActivityClsName() {
|
||||
return mActivityClsName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.apps.AppFilterImpl;
|
||||
import com.mogo.module.apps.AppsConst;
|
||||
import com.mogo.module.apps.AppsListChangedLiveData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -69,7 +73,6 @@ public class AppsModel {
|
||||
AppFilterImpl.loadExternalFilterPackagesList();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
List< PackageInfo > packages = packageManager.getInstalledPackages( 0 );
|
||||
@@ -77,23 +80,24 @@ public class AppsModel {
|
||||
for ( int i = 0; i < packages.size(); ++i ) {
|
||||
PackageInfo packageInfo = packages.get( i );
|
||||
if ( AppFilterImpl.sFilter( packageInfo ) ) {
|
||||
if ( DebugConfig.isDebug() ) {
|
||||
if ( AppFilterImpl.isSelfApp( packageInfo ) ) {
|
||||
counter = addSelfLauncher( mContext, packageManager, packageInfo, counter );
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
if ( mPagedApps.get( page ) == null ) {
|
||||
mPagedApps.put( page, new ArrayList<>() );
|
||||
List< ResolveInfo > resolveInfoList = getApkLaunchResolveInfoForInstalled( mContext, packageInfo.packageName );
|
||||
if ( resolveInfoList == null || resolveInfoList.isEmpty() ) {
|
||||
continue;
|
||||
}
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
int iconResId = AppEnumHelper.getCustomizedAppIconResId( packageName );
|
||||
Drawable appIcon = null;
|
||||
if ( iconResId == 0 ) {
|
||||
appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
for ( ResolveInfo resolveInfo : resolveInfoList ) {
|
||||
if ( resolveInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
addApp( packageManager, packageInfo, resolveInfo, page );
|
||||
}
|
||||
AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon, iconResId );
|
||||
mPagedApps.get( page ).add( appInfo );
|
||||
}
|
||||
if ( callback != null ) {
|
||||
callback.onLoaded( mPagedApps );
|
||||
@@ -101,6 +105,82 @@ public class AppsModel {
|
||||
mIsLoaded.set( true );
|
||||
}
|
||||
|
||||
private int addSelfLauncher( Context context,
|
||||
PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
int counter ) {
|
||||
List< ResolveInfo > resolveInfoList = getApkLaunchResolveInfoForInstalled( context, packageInfo.packageName );
|
||||
if ( resolveInfoList == null || resolveInfoList.isEmpty() ) {
|
||||
return counter;
|
||||
}
|
||||
for ( ResolveInfo resolveInfo : resolveInfoList ) {
|
||||
if ( resolveInfo == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( TextUtils.equals( resolveInfo.activityInfo.name,
|
||||
"com.zhidao.mogo.module.main.launcher.MainLauncherActivity" ) ) {
|
||||
continue;
|
||||
}
|
||||
int page = counter++ / AppsConst.TOTAL_SIZE_EACH_PAGE;
|
||||
addApp( packageManager, packageInfo, resolveInfo, page );
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有可以启动的ResolveInfo,其中包含所有activity及其Icon
|
||||
*
|
||||
* @param context context of the operation
|
||||
* @return all app lists
|
||||
*/
|
||||
public static List< ResolveInfo > getApkLaunchResolveInfoForInstalled( Context context,
|
||||
String packageName ) {
|
||||
List< ResolveInfo > apps = null;
|
||||
if ( null != context ) {
|
||||
PackageManager manager = context.getPackageManager();
|
||||
Intent mainIntent = new Intent( Intent.ACTION_MAIN, null );
|
||||
mainIntent.addCategory( Intent.CATEGORY_LAUNCHER );
|
||||
if ( null != packageName && !packageName.isEmpty() ) {
|
||||
mainIntent.setPackage( packageName );
|
||||
}
|
||||
apps = manager.queryIntentActivities( mainIntent, 0 );
|
||||
}
|
||||
return null == apps ? new ArrayList<>() : apps;
|
||||
}
|
||||
|
||||
private void addApp( PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
ResolveInfo resolveInfo,
|
||||
int page ) {
|
||||
if ( mPagedApps.get( page ) == null ) {
|
||||
mPagedApps.put( page, new ArrayList<>() );
|
||||
}
|
||||
mPagedApps.get( page ).add( wrapAppInfo( packageManager, packageInfo, resolveInfo ) );
|
||||
}
|
||||
|
||||
private AppInfo wrapAppInfo( PackageManager packageManager,
|
||||
PackageInfo packageInfo,
|
||||
ResolveInfo resolveInfo ) {
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
int iconResId = AppEnumHelper.getCustomizedAppIconResId( packageName );
|
||||
Drawable appIcon = null;
|
||||
if ( iconResId == 0 ) {
|
||||
if ( resolveInfo != null
|
||||
&& resolveInfo.activityInfo != null
|
||||
&& !TextUtils.equals( packageName, resolveInfo.activityInfo.processName ) ) {
|
||||
appIcon = resolveInfo.activityInfo.loadIcon( packageManager );
|
||||
appName = resolveInfo.activityInfo.loadLabel( packageManager ).toString();
|
||||
}
|
||||
if ( appIcon == null ) {
|
||||
appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
}
|
||||
}
|
||||
return new AppInfo( appName, packageName, resolveInfo != null ? resolveInfo.activityInfo.name : null, versionName, versionCode, appIcon, iconResId, 0 );
|
||||
}
|
||||
|
||||
public void appAdded( String packageName ) {
|
||||
if ( !mIsLoaded.get() ) {
|
||||
return;
|
||||
@@ -115,16 +195,8 @@ public class AppsModel {
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo( packageName, 0 );
|
||||
if ( !AppFilterImpl.sFilter( packageInfo ) ) {
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon, AppEnumHelper.getCustomizedAppIconResId( packageName ) );
|
||||
int pageIndex = getPageIndex( packageName, true );
|
||||
if ( mPagedApps.get( pageIndex ) == null ) {
|
||||
mPagedApps.put( pageIndex, new ArrayList<>() );
|
||||
}
|
||||
mPagedApps.get( pageIndex ).add( appInfo );
|
||||
addApp( packageManager, packageInfo, null, pageIndex );
|
||||
}
|
||||
AppsListChangedLiveData.getInstance().postValue( true );
|
||||
} catch ( PackageManager.NameNotFoundException e ) {
|
||||
|
||||
@@ -16,7 +16,6 @@ include ':skin:mogo-skin-support-noop'
|
||||
include ':skin:mogo-skin-support'
|
||||
include ':modules:mogo-module-widgets'
|
||||
include ':modules:mogo-module-monitor'
|
||||
include ':libraries:mogo-tanlu-api'
|
||||
include ':foudations:mogo-base-services-apk'
|
||||
include ':foudations:mogo-base-services-sdk'
|
||||
include ':modules:mogo-module-splash-noop'
|
||||
|
||||
Reference in New Issue
Block a user