forked from seek4/SilentInstall_AndroidTV
-
Notifications
You must be signed in to change notification settings - Fork 0
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
27 changed files
with
1,210 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.changhong.appcontrol" | ||
android:sharedUserId="android.uid.system" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:minSdkVersion="15" | ||
android:targetSdkVersion="21" /> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
|
||
<receiver android:name=".ControlReceiver" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<receiver | ||
android:name=".TransferReceiver"> | ||
<intent-filter > | ||
<action android:name="android.intent.action.BOOT_COMPLETED"/> | ||
<action android:name="com.changhong.appcontrol.transfer"/> | ||
<action android:name="android.intent.action.BOOT_COMPLETED" /> | ||
<action android:name="com.changhong.action.appcontrol" /> | ||
</intent-filter> | ||
</receiver> | ||
|
||
<service | ||
android:name=".ControlService" | ||
android:exported="false" > | ||
<intent-filter> | ||
<action android:name="com.changhong.service.appcontrol" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
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 |
---|---|---|
|
@@ -12,4 +12,3 @@ | |
|
||
# Project target. | ||
target=android-19 | ||
android.library.reference.1=../appcompat_v7 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="com.changhong.appcontrol.MainActivity" > | ||
|
||
<item | ||
android:id="@+id/action_settings" | ||
android:orderInCategory="100" | ||
android:title="@string/action_settings" | ||
app:showAsAction="never"/> | ||
android:showAsAction="never" | ||
android:title="@string/action_settings"/> | ||
|
||
</menu> |
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
59 changes: 59 additions & 0 deletions
59
AppControl/src/com/changhong/appcontrol/ControlReceiver.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,59 @@ | ||
package com.changhong.appcontrol; | ||
|
||
import com.changhong.appcontrol.transfer.InfoTransfer; | ||
import com.changhong.appcontrol.transfer.TransferCallBack; | ||
import com.changhong.appcontrol.transfer.TransferUtils; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
/** | ||
* AppControl入口 | ||
* @author yangtong | ||
* | ||
*/ | ||
public class ControlReceiver extends BroadcastReceiver implements TransferCallBack{ | ||
|
||
public static final String TAG = "yangtong"; | ||
//public static final String SERVER_IP = "http://192.168.10.107"; | ||
public static final String SERVER_IP = "http://192.168.103.211"; | ||
//public static final String INFO_URL = "http://yangtong.me/control.json"; | ||
|
||
private Context context; | ||
|
||
InfoTransfer transfer; | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Log.i(TAG, "ControlReceiver onReceive"); | ||
this.context = context; | ||
if(!TransferUtils.isNetworkAvaiable(context)){// 无网络时2分钟后再次获取 | ||
TransferUtils.requestAgain(context, TransferUtils.REQUEST_DELAY); | ||
return; | ||
} | ||
transfer = new InfoTransfer(); | ||
transfer.GetControlInfo(SERVER_IP+"/control.json", this); | ||
} | ||
|
||
|
||
|
||
/** | ||
* 从服务器获取json数据结束后触发 | ||
*/ | ||
@Override | ||
public void transferFinish(String controlJson) { | ||
// 判断有效性,如果有效,则StartService进行处理 | ||
Log.i(TAG,"controlInfo >>"+controlJson); | ||
if(transfer.isInfoEffective(controlJson)){ | ||
// 开Service继续接下来的操作 | ||
Intent intent = new Intent(context,ControlService.class); | ||
intent.setAction("com.changhong.service.appcontrol"); | ||
intent.putExtra("info", controlJson); | ||
context.startService(intent); | ||
}else { | ||
// 过一段时间后重新请求数据 | ||
TransferUtils.requestAgain(context, TransferUtils.REQUEST_DELAY); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.