-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
636 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/gudong/appkit/adapter/AppInfoAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.gudong.appkit.adapter; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* Created by GuDong on 2016/12/25 18:53. | ||
* Contact with [email protected]. | ||
*/ | ||
|
||
public class AppInfoAdapter extends RecyclerView.Adapter<AppInfoListAdapter.ViewHolder> { | ||
final static int TYPE_BASIC = 0; | ||
final static int TYPE_PERMISSION = 1; | ||
final static int TYPE_ACTIVITY = 2; | ||
|
||
@Override | ||
public AppInfoListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(AppInfoListAdapter.ViewHolder holder, int position) { | ||
|
||
} | ||
|
||
@Override | ||
public int getItemViewType(int position) { | ||
switch (position){ | ||
case 0: | ||
return TYPE_BASIC; | ||
case 1: | ||
return TYPE_PERMISSION; | ||
case 2: | ||
return TYPE_ACTIVITY; | ||
} | ||
return super.getItemViewType(position); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 0; | ||
} | ||
|
||
static class ViewHolder extends RecyclerView.ViewHolder{ | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.gudong.appkit.dao; | ||
|
||
import com.jaredrummler.apkparser.model.UseFeature; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by GuDong on 2016/12/25 19:10. | ||
* Contact with [email protected]. | ||
*/ | ||
|
||
public class AppDetail { | ||
public AppEntity entity; | ||
List<UseFeature> usesFeatures; | ||
List<String> requestedPermissions; | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/gudong/appkit/dao/AppMetaCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.gudong.appkit.dao; | ||
|
||
/** | ||
* Created by GuDong on 2016/12/25 21:18. | ||
* Contact with [email protected]. | ||
*/ | ||
|
||
public class AppMetaCompat extends AppEntity { | ||
public AppEntity appEntity; | ||
public String maxSdkVersion; | ||
public String minSdkVersion; | ||
public String targetSdkVersion; | ||
public String installLocation; | ||
public AppMetaCompat(AppEntity entity ){ | ||
this.appEntity = entity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
app/src/main/java/com/gudong/appkit/ui/activity/AppInfoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.gudong.appkit.ui.activity; | ||
|
||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.os.Bundle; | ||
import android.widget.LinearLayout; | ||
|
||
import com.gudong.appkit.R; | ||
import com.gudong.appkit.dao.AppEntity; | ||
import com.gudong.appkit.dao.AppMetaCompat; | ||
import com.gudong.appkit.dao.DataHelper; | ||
import com.gudong.appkit.ui.controller.AppComponentViewController; | ||
import com.gudong.appkit.ui.controller.AppBasicViewController; | ||
import com.gudong.appkit.ui.controller.AppPermissionViewController; | ||
import com.jaredrummler.apkparser.ApkParser; | ||
import com.jaredrummler.apkparser.model.AndroidComponent; | ||
import com.jaredrummler.apkparser.model.AndroidManifest; | ||
import com.jaredrummler.apkparser.model.ApkMeta; | ||
import com.jaredrummler.apkparser.model.UseFeature; | ||
|
||
import java.io.IOException; | ||
import java.text.ParseException; | ||
import java.util.List; | ||
|
||
public class AppInfoActivity extends BaseActivity { | ||
private LinearLayout llContainer; | ||
private AppBasicViewController basicViewController; | ||
private AppPermissionViewController permissionViewController; | ||
private AppComponentViewController activityViewController; | ||
private AppComponentViewController serviceViewController; | ||
private AppComponentViewController receiverViewController; | ||
private AppComponentViewController providerViewController; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
initView(); | ||
basicViewController = new AppBasicViewController(this); | ||
permissionViewController = new AppPermissionViewController(this); | ||
activityViewController = new AppComponentViewController(this,AppComponentViewController.KEY_ACTIVITY); | ||
serviceViewController = new AppComponentViewController(this,AppComponentViewController.KEY_SERVICE); | ||
receiverViewController = new AppComponentViewController(this,AppComponentViewController.KEY_RECEIVER); | ||
providerViewController = new AppComponentViewController(this,AppComponentViewController.KEY_PROVIDER); | ||
|
||
basicViewController.attachRoot(llContainer); | ||
permissionViewController.attachRoot(llContainer); | ||
activityViewController.attachRoot(llContainer); | ||
|
||
String packageName = getIntent().getStringExtra("package"); | ||
fillData(packageName); | ||
|
||
} | ||
|
||
private void fillData(String packageName) { | ||
PackageManager pm = getPackageManager(); | ||
ApplicationInfo appInfo = null; | ||
try { | ||
appInfo = pm.getApplicationInfo(packageName, 0); | ||
AppEntity entity = DataHelper.getAppByPackageName(packageName); | ||
AppMetaCompat appMetaCompat = new AppMetaCompat(entity); | ||
|
||
ApkParser apkParser = ApkParser.create(appInfo); | ||
ApkMeta meta = apkParser.getApkMeta(); | ||
appMetaCompat.maxSdkVersion = meta.maxSdkVersion; | ||
appMetaCompat.minSdkVersion = meta.minSdkVersion; | ||
appMetaCompat.targetSdkVersion = meta.targetSdkVersion; | ||
appMetaCompat.installLocation = meta.installLocation; | ||
List<UseFeature> usesFeatures = meta.usesFeatures; | ||
List<String> requestedPermissions = meta.usesPermissions; | ||
|
||
AndroidManifest androidManifest = apkParser.getAndroidManifest(); | ||
List<AndroidComponent> activities = androidManifest.activities; | ||
List<AndroidComponent> services = androidManifest.services; | ||
List<AndroidComponent> reveivers = androidManifest.receivers; | ||
List<AndroidComponent> providers = androidManifest.providers; | ||
|
||
basicViewController.fillData(appMetaCompat); | ||
permissionViewController.fillData(requestedPermissions); | ||
|
||
activityViewController.fillData(activities); | ||
// serviceViewController.fillData(services); | ||
// receiverViewController.fillData(reveivers); | ||
// providerViewController.fillData(providers); | ||
|
||
|
||
|
||
} catch (PackageManager.NameNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
protected int initLayout() { | ||
return R.layout.activity_app_info; | ||
} | ||
|
||
private void initView() { | ||
llContainer = (LinearLayout) findViewById(R.id.ll_container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.