0

I tried adb shell command adb shell date 1318349236 We used below code to execute the above command

   StringBuffer cmdOut = new StringBuffer();
    Process process;
        process = Runtime.getRuntime().exec(cmd);
        InputStreamReader r = new InputStreamReader(process.getInputStream());
        BufferedReader bufReader = new BufferedReader(r);
        char[] buf = new char[4096];
        int nRead = 0;
        while ((nRead = bufReader.read(buf)) > 0) {
            cmdOut.append(buf, 0, nRead);
        }
        bufReader.close();

tried through calender

//set Time to device

  Calendar c = Calendar.getInstance();
c.set(2013, 8, 15, 12, 34, 56);
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
am.setTime(c.getTimeInMillis());

// and set in Manifest.xml

 <!-- Allows applications to set the system time -->
<permission android:name="android.permission.SET_TIME"
    android:protectionLevel="signature/system"
  />

Here, SET_Time permission issue is there, its saying to root the device or to keep app in system/app folder which I do not want.

  • You have clearly used the code from [here](https://stackoverflow.com/a/18104950/9722336) and it is clearly written that the permission `SET_TIME` is only granted to system level apps or to a rooted phone where you have access to the root folder already – gtxtreme Sep 02 '21 at 07:41

0 Answers0