Ver Fonte

Kill BridgeService was added in Activity and setPKISecurityMfgCert was enabled for MFG Cert. VOD Reset description was modified for some reason.

Trishia há 4 anos atrás
pai
commit
6b00934309

+ 1 - 1
app/src/main/assets/pki_certs/key.pem

@@ -2,4 +2,4 @@
 MHcCAQEEICoMBthEi8SempJoOjvLJovdMcO+FsBmUFEm1jxoZvH3oAoGCCqGSM49
 AwEHoUQDQgAE3g+VQ8ibI+5pwTg0bIV4jyEwkCCBfZCvnF5YTRWebo06Jmm+5oCZ
 sg7kz5qrYa+/ZBmvsvLTXIfvaRQbdyydnQ==
------END EC PRIVATE KEY-----
+-----END EC PRIVATE KEY-----

+ 1 - 1
app/src/main/assets/pki_certs/rootca1.pem

@@ -10,4 +10,4 @@ A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBQoSOTlJ1jZ
 CO4JNOSxuz1ZZh/I9TAKBggqhkjOPQQDAgNIADBFAiAlMUwgVeL8d5W4jZdFJ5Zg
 clk7XT66LNMfGkExSjU1ngIhANOvTmd32A0kEtIpHbiKA8+RFDCPJWjN4loxrBC7
 v0JE
------END CERTIFICATE-----
+-----END CERTIFICATE-----

+ 10 - 2
app/src/main/java/org/iotivity/bridge/homeserver/BridgeServer.java

@@ -107,15 +107,23 @@ public class BridgeServer {
         int vod_count = OCBridge.getVirtualDeviceCount();
         Log.d(TAG, "Virtual OCF Device Count = [" + vod_count + "], Core Device Nums = ["+OCCoreRes.getNumDevices()+"] ");
 
-        for(int index = 1; index <= vod_count; index++) {
+        for (int index = 1; index <= vod_count; index++) {
             OCVirtualDevice vod = OCBridge.getVirtualDeviceInfo(index);
-            if(vod != null) {
+            if (vod != null) {
                 OCBridge.removeVirtualDevice(vod.getIndex());
                 OCBridge.deleteVirtualDevice(vod.getIndex()); //  Note :This includes OCMain.resetDevice(index);
                 Log.d(TAG, "Virtual OCF Device [" + vod.getIndex() + "] was reset!");
             }
         }
         bridge.clearVirtualOCFDeviceList();
+
+        /* // For test
+        if(OCCoreRes.getNumDevices() > 1) {
+            for (int index = 1; index <= OCCoreRes.getNumDevices(); index++) {
+                OCMain.resetDevice(index);
+                Log.d(TAG, "OCF Device [" + index + "] was reset!");
+            }
+        }*/
     }
 
     public void resetVirtualOCFDevice(int vod_index) {

+ 28 - 0
app/src/main/java/org/iotivity/bridge/homeserver/BridgeServerActivity.java

@@ -397,6 +397,34 @@ public class BridgeServerActivity extends AppCompatActivity {
                 stopServiceDialog.show();
                 return true;
 
+            }
+            case R.id.action_bridgeservice_kill : {
+
+                AlertDialog.Builder killServiceDialogBuilder = new AlertDialog.Builder(BridgeServerActivity.this);
+                killServiceDialogBuilder.setTitle(getString(R.string.killBridgeService));
+                killServiceDialogBuilder.setMessage(getString(R.string.killBridgeMessage));
+
+                killServiceDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        // kill Bridge Service
+                        stopBridgeService();
+                        Log.d(TAG, "System.exit() will be called");
+                        System.runFinalizersOnExit(true);
+                        System.exit(0);
+                    }
+                });
+
+                killServiceDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                    }
+                });
+
+                Dialog killServiceDialog = killServiceDialogBuilder.create();
+                killServiceDialog.show();
+                return true;
+
             }
             default :
                 return super.onOptionsItemSelected(item) ;

+ 1 - 1
app/src/main/java/org/iotivity/bridge/homeserver/handler/FactoryPresetsHandler.java

@@ -34,7 +34,7 @@ public class FactoryPresetsHandler implements OCFactoryPresetsHandler {
         if (isMfgCertSupport && deviceIndex != 0)
             return; // TODO : Only Bridge will use pki certs in this case
 
-        //setPKISecurityMfgCert(deviceIndex);
+        setPKISecurityMfgCert(deviceIndex);
     }
 
     private void setPKISecurityMfgCert(long deviceIndex) {

+ 4 - 0
app/src/main/res/menu/actionbar_actions.xml

@@ -18,6 +18,10 @@
             android:title="@string/stopBridgeService"
             app:showAsAction="never"/>
 
+        <item
+            android:id="@+id/action_bridgeservice_kill"
+            android:title="@string/killBridgeService"
+            app:showAsAction="never"/>
     <!--
                 <item
                     android:id="@+id/action_settings"

+ 4 - 2
app/src/main/res/values/strings.xml

@@ -10,8 +10,10 @@
     <!--<string name="resetBridge">Reset </string>
     <string name="resetBridgeMessage">Note: This Client including SVRs will be reset.</string>-->
     <string name="resetVods">Reset Vods</string>
-    <string name="resetVodsMessage">Note: All virtual OCF devices will be reset.</string>
+    <string name="resetVodsMessage">Note: All virtual OCF devices will be reset and clear VOD List So you should kill and restart Bridge Service.</string>
     <string name="stopBridgeService">Stop Bridge Service</string>
-    <string name="stopBridgeMessage">Note: Foregrounding Bridge Service and BridgeServer Activity will be killed.</string>
+    <string name="stopBridgeMessage">Note: Service Client Callbacks will be unbind and stop but Bridge Service will not be destroyed.</string>
+    <string name="killBridgeService">Kill Bridge Service</string>
+    <string name="killBridgeMessage">Note: Foregrounding Bridge Service and BridgeServer Activity will be killed.</string>
 
 </resources>